温馨提示×

如何通过ifconfig查看Ubuntu网络状态

小樊
45
2025-12-09 03:57:57
栏目: 智能运维

在 Ubuntu 系统中,ifconfig 命令用于配置、激活和查询网络接口的参数。要使用 ifconfig 查看网络状态,请按照以下步骤操作:

  1. 打开终端(Terminal):点击左上角的 Ubuntu 图标,然后输入 “Terminal” 并按 Enter 键。

  2. 在终端中输入以下命令并按 Enter 键:

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 100345  bytes 12345678 (12.3 MB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 98765  bytes 87654321 (87.6 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 640  bytes 524288 (524.2 KB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 640  bytes 524288 (524.2 KB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

在这个例子中,eth0 是一个活动的网络接口,它的 IP 地址是 192.168.1.100,子网掩码是 255.255.255.0,广播地址是 192.168.1.255。lo 是一个本地回环接口,用于测试网络连接。

请注意,ifconfig 命令在某些 Ubuntu 版本中可能已被弃用,取而代之的是 ip 命令。要使用 ip 命令查看网络状态,请输入以下命令:

ip addr

这将显示与 ifconfig 类似的网络接口信息。

0