在 CentOS 系统中,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 1003411 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
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 64 bytes 5760 (5.6 KiB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 64 bytes 5760 (5.6 KiB)
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。此外,还可以查看接收和发送的数据包数量、字节数等信息。
请注意,ifconfig
命令在某些 CentOS 版本中可能已被弃用,建议使用 ip
命令替代。要使用 ip
命令查看网络配置,请输入:
ip addr
这将显示与 ifconfig
类似的网络接口信息。