在 CentOS 系统中,ifconfig 命令用于配置、激活和查询网络接口。以下是一些常用的 ifconfig 命令示例:
查看所有网络接口:
ifconfig
这个命令会列出系统中所有的网络接口及其状态。
查看特定网络接口:
ifconfig eth0
将 eth0 替换为你想要查看的网络接口名称,例如 ens33 或 wlan0。
激活网络接口:
ifconfig eth0 up
这个命令会激活名为 eth0 的网络接口。
停用网络接口:
ifconfig eth0 down
这个命令会停用名为 eth0 的网络接口。
配置IP地址:
ifconfig eth0 192.168.1.100 netmask 255.255.255.0
这个命令会为名为 eth0 的网络接口配置 IP 地址 192.168.1.100 和子网掩码 255.255.255.0。
删除IP地址:
ifconfig eth0 192.168.1.100 netmask 255.255.255.0 del
这个命令会删除名为 eth0 的网络接口上的 IP 地址 192.168.1.100 和子网掩码 255.255.255.0。
查看网络接口的广播地址:
ifconfig eth0 broadcast
这个命令会显示名为 eth0 的网络接口的广播地址。
查看网络接口的MAC地址:
ifconfig eth0 hw ether
这个命令会显示名为 eth0 的网络接口的硬件(MAC)地址。
请注意,ifconfig 命令在较新的 CentOS 版本中可能已被弃用,推荐使用 ip 命令来替代。例如,要查看所有网络接口,可以使用 ip addr show 命令。