How to know that my IP is invalid

Posted by PeterMmm on Server Fault See other posts from Server Fault or by PeterMmm
Published on 2010-04-20T11:04:41Z Indexed on 2010/04/20 11:14 UTC
Read the original article Hit count: 213

Filed under:
|
|

I have a script running that will start up an interface with a new IP.

If the script comes up with an IP that is already in use i am in trouble.

Is it possible that the script set up the new Ip, detects that this IP is already in use and then check the next one, until it finds an ip that works ?

B=192.168.1.
I=1
while [ "$I" != "256" ]
do
ifconfig eth0:1 $B.$I
# check here that IP is Ok !
let "I=I+1"
done

© Server Fault or respective owner

Related posts about linux

Related posts about networking