What is the Linux command to clear IP addresses of an interface without bringing it down and/or restarting network services?
Seems strange that ifconfig is able to change IP addresses but has no option to remove them, or am I wrong?
What is the Linux command to clear IP addresses of an interface without bringing it down and/or restarting network services?
Seems strange that ifconfig is able to change IP addresses but has no option to remove them, or am I wrong?
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
sudo ip addr del 192.168.0.1/24 dev weave. See https://unix.stackexchange.com/questions/646326/how-do-i-remove-an-ip-address-from-an-interface
– PatS
Apr 23 '21 at 02:45
As simple as ifconfig eth0 0.0.0.0. They should have put it in the manual.
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
Perhaps you are just looking to get a new IP from the [DHCP-enabled] router? In this case call
dhclient eth0
dhclient just asks for one more IP not checking if one is already there nor deleting the old ips. So delete the unused IP first before you call dhclient
– sebisnow
Jul 01 '20 at 08:08
0.0.0.0-- it's just how it is done withifconfig. – u1686_grawity Jun 17 '10 at 10:36upyou can useip addr flush up– ws6079 May 19 '20 at 09:19