linux

ifconfig命令如何查看网络状态

小樊
46
2025-04-26 04:23:44
栏目: 编程语言

ifconfig 是一个用于配置和显示 Linux 内核中网络接口的命令行实用程序。通过使用 ifconfig 命令,您可以查看网络接口的状态、IP 地址、子网掩码、广播地址等信息。

要使用 ifconfig 命令查看网络状态,请按照以下步骤操作:

  1. 打开终端(Terminal)。

  2. 输入 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 是一个活动的网络接口。以下是一些关键信息:

要查看特定网络接口的状态,只需在 ifconfig 命令后添加接口名称,例如 ifconfig eth0

请注意,ifconfig 命令在某些 Linux 发行版中可能已被弃用,建议使用 ip 命令替代。要使用 ip 命令查看网络状态,请输入 ip addrip a

0
看了该问题的人还看了