ifconfig
是一个用于配置和显示 Linux 内核中网络接口的命令行实用程序。在 CentOS 中,ifconfig
命令的常用参数如下:
ifconfig
:不带任何参数运行 ifconfig 将显示所有活动网络接口的详细信息。
ifconfig interface
:显示指定网络接口的信息。将 “interface” 替换为您要查看的网络接口名称,例如 ifconfig eth0
。
ifconfig interface up
:启用指定的网络接口。将 “interface” 替换为您要启用的网络接口名称,例如 ifconfig eth0 up
。
ifconfig interface down
:禁用指定的网络接口。将 “interface” 替换为您要禁用的网络接口名称,例如 ifconfig eth0 down
。
ifconfig interface hw ether address
:更改指定网络接口的 MAC 地址。将 “interface” 替换为您要更改的网络接口名称,将 “address” 替换为您要设置的新 MAC 地址,例如 ifconfig eth0 hw ether 00:11:22:33:44:55
。
ifconfig interface mtu size
:更改指定网络接口的最大传输单元 (MTU)。将 “interface” 替换为您要更改的网络接口名称,将 “size” 替换为您要设置的新 MTU 值,例如 ifconfig eth0 mtu 1500
。
ifconfig interface broadcast address
:设置指定网络接口的广播地址。将 “interface” 替换为您要设置的网络接口名称,将 “address” 替换为您要设置的广播地址,例如 ifconfig eth0 broadcast 192.168.1.255
。
请注意,ifconfig
命令在某些 Linux 发行版中可能已被弃用,建议使用 ip
命令替代。