温馨提示×

debian ifconfig怎样查看网关

小樊
52
2026-09-12 11:15:33
栏目: 智能运维

在 Debian 中,ifconfig 本身不能查看网关,ifconfig 只能看 IP 地址、掩码、MAC 等网络接口信息。

查看网关的正确方式

方法 1:使用 ip 命令(推荐)

ip route

或只看默认网关:

ip route show default

示例输出:

default via 192.168.1.1 dev eth0

其中 192.168.1.1 就是网关。


方法 2:使用 route 命令

route -n

示例:

Kernel IP routing table
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

Gateway 列里 0.0.0.0 对应的就是默认网关。


方法 3:旧版 netstat

netstat -rn

总结

  • ifconfig ❌ 看不到网关
  • ip route ✅ 最推荐
  • route -n ✅ 传统方式

如果你是在 无网络/最小化 Debian 环境,也可以告诉我,我可以给你更合适的命令。

0 踩