ifconfig 是一个用于配置和显示 Linux 内核中网络接口的命令行实用程序。通过使用 ifconfig 命令,您可以查看网络接口的状态、IP 地址、子网掩码、广播地址等信息。
要使用 ifconfig 命令查看网络状态,请按照以下步骤操作:
打开终端(Terminal)。
输入 ifconfig 命令,然后按 Enter 键。这将显示系统中所有活动网络接口的详细信息。例如:
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 100341 bytes 12345678 (11.7 MiB) RX errors 0 dropped 0 overruns 0 frame 0 TX packets 98765 bytes 1234567 (1.1 MiB) TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0 在这个例子中,eth0 是一个活动的网络接口。以下是一些关键信息:
flags:显示网络接口的状态,如 UP(启用)、BROADCAST(广播)、RUNNING(运行)和 MULTICAST(多播)。inet:显示IPv4地址和子网掩码。inet6:显示IPv6地址和前缀长度。ether:显示MAC地址。RX packets 和 TX packets:分别显示接收和发送的数据包数量。RX bytes 和 TX bytes:分别显示接收和发送的数据字节数。要查看特定网络接口的状态,只需在 ifconfig 命令后添加接口名称,例如 ifconfig eth0。
请注意,ifconfig 命令在某些 Linux 发行版中可能已被弃用,建议使用 ip 命令替代。要使用 ip 命令查看网络状态,请输入 ip addr 或 ip a。