|
|
发表于 2006-8-25 12:12:57
|
显示全部楼层
- for i in 192.168.1.{1..254}; do
- if ! ping -c2 $i 2>/dev/null 1>/dev/null; then
- ifconfig eth0 $i netmask 255.255.255.0 broadcast 192.168.1.255
- route add default gw xxxx
- if ping -c2 www.google.com; then
- echo $i
- break
- else
- route del default
- fi
- fi
- done
复制代码 replace the default gw with your gw ip. Also, instead of using ifconfig and route, you can use ip cmd suite. |
|