익명 16:24

temporarily set eth0 to dhcp linux

temporarily set eth0 to dhcp linux

My ip address on a beaglebone is set to:

$ ip address show dev eth0
4: eth0: <BROADCAST,MULTICAST,DYNAMIC,UP,LOWER_UP> mtu 1500 qdisc mq state UP group default qlen 1000
    link/ether 64:33:db:27:e9:d2 brd ff:ff:ff:ff:ff:ff
    inet 192.168.1.132/24 brd 192.168.1.255 scope global eth0
       valid_lft forever preferred_lft forever
    inet6 fe80::6633:dbff:fe27:e9d2/64 scope link 
       valid_lft forever preferred_lft forever


I can temporarily add a second address for 100 seconds with the command:

sudo ip addr add 192.168.4.244/23 dev eth0 valid_lft 100 preferred_lft 100 

I would like to do the same thing only instead of the second address being static, I would like it assigned by the router (dhcp?/dynamic?) but for the life of me I can't figure out the syntax. any ideas?

I was told that:

ifconfig eth0 0.0.0.0 0.0.0.0 && dhclient

would work but is that ok to do considering my static IP address was set with connman? Also if ifconfig is ok to use how do add the timeout???

TIA



Top Answer/Comment:
   dhclient eth0:dynamic

here dynamic is just a name for an aliased net interface (you can use any other name here if you want)

dhclient will create an aliased interface on hardware eth0 (assuming eth0:dynamic is not already defined) and then call out on it to get an address using DHCP leaving your existing eth0 configuration untouched.

상단 광고의 [X] 버튼을 누르면 내용이 보입니다