Linux如何查看網關Gateway


Linux下如何查看網關Gateway地址

ifconfig -a 和 cat /etc/resolv.conf  #(主要查看ip/netmask和dns)

netstat -rn

cat /etc/sysconfig/network

cat /etc/sysconfig/network-scripts/ifcfg-eth0

traceroute # 第一行就是自己的網關

ip route show

route -n
  • 以上幾個是比較常用的查詢網關的命令。下面是范例:
[root@www.ctohome.com]# netstat -rn
Kernel IP routing table
Destination   Gateway     Genmask     Flags  MSS Window irtt Iface
184.82.152.96  0.0.0.0     255.255.255.248 U     0 0     0 eth0
169.254.0.0   0.0.0.0     255.255.0.0   U     0 0     0 eth0
0.0.0.0     184.82.152.97  0.0.0.0     UG    0 0     0 eth0


[root@www.ctohome.com]# cat /etc/sysconfig/network-scripts/ifcfg-eth0
\# Intel Corporation 82567V-2 Gigabit Network Connection
DEVICE=eth0
BOOTPROTO=none
HWADDR=00:1c:c0:f8:a1:ac
ONBOOT=yes
NETMASK=255.255.255.248
IPADDR=184.82.152.98
GATEWAY=184.82.152.97
TYPE=Ethernet


[root@www.ctohome.com]# ip route show
184.82.152.96/29 dev eth0 proto kernel scope link src 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 table
Destination   Gateway     Genmask     Flags Metric Ref  Use Iface
184.82.152.96  0.0.0.0     255.255.255.248 U   0   0    0 eth0
169.254.0.0   0.0.0.0     255.255.0.0   U   0   0    0 eth0
0.0.0.0     184.82.152.97  0.0.0.0     UG  0   0    0 eth0



[root@www.ctohome.com]# ifconfig -a
eth0   Link encap:Ethernet HWaddr 00:1C:C0:F8:A1:AC  
    inet addr:184.82.152.98 Bcast:184.82.152.103 Mask:255.255.255.248


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM