在 Debian(以及其他 Linux 发行版)里,ifconfig 本身不能直接看网关。
ifconfig 只能显示:
不包含路由表信息,而网关是路由表里的内容。
routeroute -n
输出示例:
Destination Gateway Genmask Flags Metric Ref Use Iface
0.0.0.0 192.168.1.1 0.0.0.0 UG 0 0 0 eth0
UG 那一行,Gateway 就是网关。
ip 命令(推荐)ip route
或
ip route show default
示例:
default via 192.168.1.1 dev eth0
via 后面就是网关。
nmcli dev show | grep GATEWAY
ifconfig:不能看网关ip route 或 route -n如果你是在 老版本 Debian(无 ip 命令) 或 容器环境,我也可以按具体环境给你命令。