天天看点

batch configure ip address

RETVAL=0

oper(){

if [ "$1" == "del" ];then

list=<code>echo{10..1}</code>

else

list=<code>echo{1..10}</code>

fi

for ip in $list;do

if [ $ip -eq 5 ];then

continue

ip addr $1 192.168.1.$ip/14 dev eth0 label eth0:$ip &amp;&gt;/dev/null

RETVAL=$?

if [ $RETVAL -eq 0 ];then

action "$1 $ip" /bin/true

action "$1 $ip" /bin/false

done

return $RETVAL

}

case "$1" in

start)

oper add

;;

stop)

oper del

restart)

oper del

sleep 2

*)

printf "USAGE:$0 {start|stop|restart}\n"

esac

exit $RETVAL

继续阅读