使用ifconfig或ip命令可查看Linux网络接口状态,包括IP地址、MAC地址、数据收发统计及错误信息,结合ip、ping、netstat、ss、traceroute和dig等工具可全面诊断网络问题。

在Linux系统里,想快速了解你的机器网络状况,比如网卡是不是正常工作,有没有分配到IP地址,最直接的办法就是使用一些命令行工具。其中,
ifconfig
要查看网络状态,特别是网络接口信息,你只需在终端中输入
ifconfig
如果你想看所有接口,包括那些当前没有激活(down)的接口,可以加上
-a
ifconfig -a
通常情况下,执行
ifconfig
eth0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet 192.168.1.100 netmask 255.255.255.0 broadcast 192.168.1.255
inet6 fe80::a00:27ff:fe0d:a02 prefixlen 64 scopeid 0x20<link>
ether 08:00:27:0d:0a:02 txqueuelen 1000 (Ethernet)
RX packets 12345 bytes 12345678 (12.3 MB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 9876 bytes 9876543 (9.8 MB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
lo: flags=73<UP,LOOPBACK,RUNNING> mtu 65536
inet 127.0.0.1 netmask 255.0.0.0
inet6 ::1 prefixlen 128 scopeid 0x10<host>
loop txqueuelen 1000 (Local Loopback)
RX packets 123 bytes 12345 (12.3 KB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 123 bytes 12345 (12.3 KB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0在这个输出中,
eth0
lo
eth0
lo
ifconfig
第一次接触
ifconfig
eth0
wlan0
首先,
flags
<UP,BROADCAST,RUNNING,MULTICAST>
UP
mtu
接着,
inet
netmask
broadcast
inet6
ether
txqueuelen
最后,也是我个人在排查网络问题时最关注的,是
RX packets/bytes
TX packets/bytes
RX
TX
RX errors/dropped
TX errors/dropped
RX errors
ifconfig
这事儿我可没少遇到,尤其是在一些较新的Linux发行版上。你满怀希望地敲下
ifconfig
ifconfig
ip
ifconfig
net-tools
net-tools
iproute2
ip
ip
如果你确实想在这些新系统上使用
ifconfig
net-tools
sudo apt update sudo apt install net-tools
sudo yum install net-tools # 或者 sudo dnf install net-tools
安装完成后,
ifconfig
ip
ip a
ip addr show
ifconfig
ip a
ifconfig
网络这东西,光看接口肯定不够,得从多个角度去摸排,才能真正做到心中有数。除了
ifconfig
ip a
首先,
ip r
ip route show
ifconfig
其次,
ping
ping
ping google.com
再来,
netstat
ss
netstat -tulnp
ss
netstat
ss -tulnp
如果你需要追踪数据包在网络中的路径,
traceroute
tracepath
最后,对于DNS解析问题,
dig
nslookup
这些命令各有侧重,但结合起来使用,就能像一个经验丰富的网络侦探一样,把网络的“脉搏”摸得一清二楚。它们是我在面对各种网络疑难杂症时,最信赖的“武器库”。
以上就是如何在Linux中查看网络状态?使用ifconfig命令检查网络接口信息的详细内容,更多请关注php中文网其它相关文章!
每个人都需要一台速度更快、更稳定的 PC。随着时间的推移,垃圾文件、旧注册表数据和不必要的后台进程会占用资源并降低性能。幸运的是,许多工具可以让 Windows 保持平稳运行。
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号