检验真理的办法是实践,我亲测了下你的脚本,不知道你说的是哪里不行?
# sh ipcon.sh
please input ip address
134.1.2.3
please input netmask
255.255.255.3
please input gateway
134.1.2.1
ifconfig eth0 134.1.2.3 netmask 255.255.255.3
route add default gw 134.1.2.1
#sh ipcon.sh
please input ip address
a.3.3.256
please input netmask
1.2.2.2
please input gateway
1.1.1.1
ipcon.sh: line 11: [: a: integer expression expected
Wrong IP configuration, please reset
#sh ipcon.sh
please input ip address
123.1.2.256
please input netmask
123.1.2.1
please input gateway
123.1.2.0
Wrong IP configuration, please reset
我看下来应该没有问题。
你是每次运行都提示:"Wrong IP configuration, please reset" 这个吗?
把你设置的ip地址贴上来看看。
checkip $ipaddr && checkip $netmask && checkip $gateway //感觉有问题