Centos/linux How to view the gateway address/gateway address? There are many commands to view the gateway under Linux, but if the IP is obtained by DHCP, then some commands are not applicable, and there are also common query gateway commands.
1.ifconfig-a and cat/etc/resolv.conf (main view ip/netmask and DNS)
2.netstat-rn
3.cat/etc/sysconfig/network
4.cat/etc/sysconfig/network-scripts/ifcfg-eth0
5.traceroute the first line is your own gateway
6.ip Route Show
7.route-n
These are the more common commands for querying gateways. Here's an example:
[[Email protected]]# 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
[[Email protected]]# 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
[[Email protected]]# 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
[[Email protected]]# 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
[[Email protected]]# 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
This article from "Flat Light is true" blog, please be sure to keep this source http://ucode.blog.51cto.com/10837891/1893181
Centos/linux How to view the gateway address/gateway address