Take the 2-minute tour ×
Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

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.

share|improve this question
    
that regex has a lot of problems, but I'm sure you get the idea. –  devin Jul 13 '12 at 22:38
    
what's wrong with this question? –  devin Dec 18 '12 at 3:21

1 Answer 1

up vote 5 down vote accepted

Does the flush command not do what you want

ip addr flush eth0
share|improve this answer
    
yes it does, I must have missed it in the man page... –  devin Jul 13 '12 at 22:51

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.