Alpine Linux is not sending hostname to dhcp server

When alpine linux asks for ipv4 address from dhcp server, it is not sending hostname to dhcp server. So I cant access by server’s hostname in LAN. Here is my setup

I am using Alpine Linux 3.12 on my VM (not container), and arch is aarch64.

The router runs openwrt 19.07.3 and BusyBox is v1.31.1

My config:

nodeprealp99:~# cat /etc/network/interfaces 
auto lo
iface lo inet loopback

auto eth0
iface eth0 inet dhcp
        hostname nodeprealp99 

I also tried with this:

nodeprealp99:~# cat /etc/network/interfaces 
auto lo
iface lo inet loopback

auto eth0
iface eth0 inet dhcp
        hostname nodeprealp99
        udhcpc_opts -h $HOSTNAME

I appreciate your help

Answer

I have ended up using dhclient, which is also very lightweight

apk add dhclient coreutils

create a config file at /etc/dhcp/dhclient.conf

send host-name = gethostname();
prepend domain-name-servers 127.0.0.1;
request subnet-mask, broadcast-address, time-offset, routers,
        domain-name, domain-name-servers, host-name;
require subnet-mask, domain-name-servers;
timeout 60;
retry 60;
reboot 10;
select-timeout 7;
script "/etc/dhclient-script";

lease {
  interface "eth0";
}

and reboot

reboot

Attribution
Source : Link , Question Author : ozkolonur , Answer Author : ozkolonur

Leave a Comment