1.cat /etc/resolv.conf (看DNS)
2.netstat –r
3.cat /etc/sysconfig/network(Ubuntu10.04不行)
4.cat /etc/sysconfig/network-scripts/ifcfg-eth0(Ubuntu10.04不行)
5.traceroute 第一行就是自己的网关
6.ip route show
7.route -n
以上几个是比较常用的查询网关的命令
脚本实现
Mask :
ifconfig |grep inet| sed -n '1p'|awk '{print $4}'|awk -F ':' '{print $2}'
IP :
ifconfig |grep inet| sed -n '1p'|awk '{print $2}'|awk -F ':' '{print $2}'
MAC :
ifconfig |grep eth0|awk '{print $5}'
DNS :
cat /etc/resolv.conf | awk '{print $2}'
GW :
route -n | grep eth0 | grep UG | awk '{print $2}'
本文转自:
http://blog.sina.com.cn/s/blog_674d87000100pzmh.html
http://blog..net/chenbang110/article/details/7719881