在 Debian 系统中,查看网络状态的方法有很多,取决于你想看网卡状态、IP 地址、路由、连通性还是流量。下面按常见需求分类说明。
ip addr
或简写:
ip a
查看内容:
eth0, ens33, wlan0)示例:
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
cat /etc/resolv.conf
ping -c 4 8.8.8.8
ping -c 4 www.baidu.com
ip -s linkip -s link
可看到收发字节数、错误包等。
iftop(需安装)sudo apt install iftop
sudo iftop
nloadsudo apt install nload
nload
ss -lntup
ss -antup
ifconfig
需要安装
net-tools:
sudo apt install net-tools
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
如果你愿意,可以告诉我:
cat /etc/debian_version)我可以给你针对性的排查步骤。