ip route命令
执行下面命令,同样可以查看默认网关地址:
ip route show
输出示例:
192.168.2.0/24 dev wlan0 proto kernel scope link src 192.168.2.3 metric 2 192.168.1.0/24 dev eth0 proto kernel scope link src 192.168.1.254 metric 1 192.168.122.0/24 dev virbr0 proto kernel scope link src 192.168.122.1 169.254.0.0/16 dev wlan0 scope link metric 1000 default via 192.168.2.1 dev wlan0 proto static
如何查看Ubuntu Linux上默认网关IP地址?
解决方案
使用route或ip命令获取Ubuntu Linux的默认路由表。
route -n
输出示例:
Kernel IP routing table Destination Gateway Genmask Flags Metric Ref Use Iface 192.168.2.0 0.0.0.0 255.255.255.0 U 2 0 0 wlan0 192.168.1.0 0.0.0.0 255.255.255.0 U 1 0 0 eth0 192.168.122.0 0.0.0.0 255.255.255.0 U 0 0 0 virbr0 169.254.0.0 0.0.0.0 255.255.0.0 U 1000 0 0 wlan0 0.0.0.0 192.168.2.1 0.0.0.0 UG 0 0 0 wlan0
192.168.2.1是默认网关。
route
输出示例:
Kernel IP routing table Destination Gateway Genmask Flags Metric Ref Use Iface 192.168.2.0 * 255.255.255.0 U 2 0 0 wlan0 192.168.1.0 * 255.255.255.0 U 1 0 0 eth0 192.168.122.0 * 255.255.255.0 U 0 0 0 virbr0 link-local * 255.255.0.0 U 1000 0 0 wlan0 default 192.168.2.1 0.0.0.0 UG 0 0 0 wlan0
日期:2020-03-23 08:03:51 来源:oir作者:oir