温馨提示×

怎么查看Debian网络状态

小樊
106
2026-08-05 13:28:52
栏目: 智能运维

在 Debian 系统中,查看网络状态的方法有很多,取决于你想看网卡状态、IP 地址、路由、连通性还是流量。下面按常见需求分类说明。


一、查看网卡与 IP 状态(最常用)

✅ 推荐(现代方式)

ip addr

或简写:

ip a

查看内容:

  • 网卡名称(如 eth0, ens33, wlan0)
  • IPv4 / IPv6 地址
  • 是否 UP

示例:

2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500
    inet 192.168.1.100/24 brd 192.168.1.255 scope global eth0

✅ 查看是否启用

ip link

二、查看网络连接状态(路由 / 网关)

查看路由表

ip route

示例:

default via 192.168.1.1 dev eth0
192.168.1.0/24 dev eth0 proto kernel scope link src 192.168.1.100

查看 DNS

cat /etc/resolv.conf

三、查看网络是否连通

ping 测试

ping -c 4 8.8.8.8

测试 DNS

ping -c 4 www.baidu.com

四、查看实时网络流量(推荐)

使用 ip -s link

ip -s link

可看到收发字节数、错误包等。


使用 iftop(需安装)

sudo apt install iftop
sudo iftop

使用 nload

sudo apt install nload
nload

五、查看监听端口 / 网络连接

查看监听端口

ss -lntup

查看当前连接

ss -antup

六、旧命令(不推荐但可用)

ifconfig

需要安装 net-tools:

sudo apt install net-tools

七、查看 NetworkManager 状态(桌面或笔记本常见)

nmcli device status
nmcli connection show

八、常见问题排查速查表

问题 命令
网卡没起来 ip link set eth0 up
没有 IP dhclient eth0
无法上网 ip route + ping
DNS 不生效 cat /etc/resolv.conf
端口被占用 ss -lntup

九、推荐组合(快速诊断)

ip a
ip route
ping -c 3 8.8.8.8

如果你愿意,可以告诉我:

  • ✅ Debian 版本(cat /etc/debian_version)
  • ✅ 是服务器还是桌面
  • ✅ 有线 / 无线
  • ✅ 具体问题(连不上网 / 没 IP / 慢)

我可以给你针对性的排查步骤。

0 踩