ifconfig(interface config)是 Linux/Unix 下查看和配置网络接口的经典命令。虽然在新系统中更推荐用 ip addr,但理解 ifconfig 输出依然很有用。
下面我用一个典型输出示例,逐段解释含义。
eth0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet 192.168.1.10 netmask 255.255.255.0 broadcast 192.168.1.255
inet6 fe80::20c:29ff:fe12:3456 prefixlen 64 scopeid 0x20<link>
ether 00:0c:29:12:34:56 txqueuelen 1000 (Ethernet)
RX packets 123456 bytes 98765432 (94.1 MiB)
TX packets 654321 bytes 123456789 (117.7 MiB)
RX errors 0 dropped 0 overruns 0 frame 0
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
eth0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
UP:接口已启用BROADCAST:支持广播RUNNING:网卡已连接(有网线/激活)MULTICAST:支持组播inet 192.168.1.10 netmask 255.255.255.0 broadcast 192.168.1.255
inet6 fe80::20c:29ff:fe12:3456 prefixlen 64 scopeid 0x20<link>
<link>:链路本地地址(只在局域网有效)ether 00:0c:29:12:34:56
txqueuelen 1000 (Ethernet)
(Ethernet):接口类型RX packets 123456 bytes 98765432
TX packets 654321 bytes 123456789
RX errors 0 dropped 0 overruns 0 frame 0
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
| 名称 | 含义 |
|---|---|
| lo | 回环接口(127.0.0.1) |
| eth0 | 第一块以太网卡 |
| ens33 | 新命名规则下的网卡 |
| wlan0 | 无线网卡 |
ifconfig -a
ifconfig eth0
ifconfig | grep inet
| 命令 | 状态 |
|---|---|
| ifconfig | 老旧(仍可用) |
| ip addr | 推荐 |
ip addr show
如果你愿意,可以把你自己的 ifconfig 输出贴出来,我可以帮你逐行分析,或者判断是否有网络异常。