How can I clear the IP address of Ethernet interface without cycling the interface up/down or restarting it

What is the Linux command to clear IP address of an interface without bringing it down and/or restarting network services. Seems strange ifconfig is able to change IP address but has no option to clear it, or am I wrong?


Solution 1:

Use ip from iproute2. (You need to also specify the prefix length though.)

ip addr del 10.22.30.44/16 dev eth0

To remove all addresses (in case you have multiple):

ip addr flush dev eth0

Solution 2:

As simple as ifconfig eth0 0.0.0.0. They should have put it in the manual.

Solution 3:

To remove all adreses from all interfaces i used for loop:

for i in $(ls /sys/class/net/) ; do
    /usr/sbin/ip addr flush $i &
done

Solution 4:

Perhaps you are just looking to get a new IP from the [DHCP-enabled] router? In this case call

dhclient eth0