如何在Centos/Linux上显示网关地址/网关地址? 在Linux上,查看网关的命令还很多,但IP获取DHCP时,某些命令不适用。 当然,还有通用的查询网关命令。
1.ifconfig -a和cat /etc/resolv.conf (主要看ip/netmask和dns ) )。
2.netstat -rn
3.cat /etc/sysconfig/network
4.cat/etc/sys config/network-scripts/if CFG-eth 0
5.traceroute的第一行是自己的网关
6.IP路演
7.route -n
以上几个是比较常用的查询网关命令。 以下是一些示例。
[ root @ www.CTO home.com ] # netstat-rn
kernel IP routing表
destinationgatewaygenmaskflagsmswindowirttiface
184.82.152.960.0.0.0255.255.255.248 u00 eth 0
169.254.0.0.0.0255.255.0.0 u 00 eth 0
0.0.0.0184.82.152.970.0.0.0 ug00 eth 0
[ root @ www.CTO home.com ] # cat/etc/sys config/network-scripts/if CFG-eth 0
#Intelcorporation82567v-2千兆位网络连接
DEVICE=eth0
BOOTPROTO=none
had dr=00:1 c : c 0: f 8: a 1: AC
on boot=是
NETMASK=255.255.255.248
IPADDR=184.82.152.98
GATEWAY=184.82.152.97
type=以太网
[ root @ www.CTO home.com ] # IP route show
184.82.152.96/29 deveth0protokernelscopelinksrc 184.82.152.98
169.254.0.0/16 dev eth0 scope link
default via 184.82.152.97 dev eth0
[root@www.ctohome.com]# route -n
kernel IP routing表
destinationgatewaygenmaskflagsmetricrefuseiface
184.82.152.960.0.0.0255.255.255.248 u00 eth 0
169.254.0.0.0.0255.255.0.0 u 00 eth 0
0.0.0.0184.82.152.970.0.0.0 ug00 eth 0
[ root @ www.CTO home.com ] # ifconfig-a
eth0link encap :以太网hwaddr 0033601 c : c 0: f 8: a 1: AC
inetaddr 3360184.82.152.98 bcast :184.82.152.103 mask 3360255.255.255.255.248