0

I have an interface that I setup like this

ip addr add 192.168.1.1/24 dev eth0
ip addr add 192.168.1.2/24 dev eth0
ip addr add 192.168.1.3/24 dev eth0

etc.

Is there an easy way to delete all of the IPs I add with out doing

ip addr del 192.168.1.1/24 dev eth0
ip addr del 192.168.1.2/24 dev eth0
ip addr del 192.168.1.3/24 dev eth0

or doing something like

ips=`ip addr show dev eth0 | grep -oe '192\.168\1\.[0-2][0-9]{1,2}'`
for ii in $ips; do
   ip addr del $ii dev eth0
done

There must be a more elegant way to do this.

3

1 Answer 1

8

Does the flush command not do what you want

ip addr flush eth0
2
  • yes it does, I must have missed it in the man page...
    – devin
    Jul 13, 2012 at 22:51
  • Interesting for me that there is really no need to put dev before iface name (eth0).
    – pevik
    Jul 17, 2017 at 9:01

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .