在 Linux 系统中,ifconfig 命令用于配置和显示网络接口的信息。要查看网络接口的状态,可以使用以下命令:
ifconfig
这将显示系统中所有活动的网络接口及其相关信息,如 IP 地址、子网掩码、广播地址等。输出示例:
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:fe4e:66a1 prefixlen 64 scopeid 0x20<link>
ether 08:00:27:4e:66:a1 txqueuelen 1000 (Ethernet)
RX packets 1003421 bytes 123456789 (117.7 MiB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 987654 bytes 987654321 (941.5 MiB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
在这个示例中,我们可以看到 eth0 接口的状态是 UP(运行中),并且它是 MULTICAST(多播)和 BROADCAST(广播)的。
如果你只想查看特定网络接口的状态,可以在 ifconfig 命令后指定接口名称,例如:
ifconfig eth0
这将仅显示 eth0 接口的相关信息。
需要注意的是,ifconfig 命令在一些较新的 Linux 发行版中可能已被弃用,建议使用 ip 命令替代。要使用 ip 命令查看网络接口状态,可以使用以下命令:
ip addr show
或者查看特定网络接口的状态:
ip addr show eth0