ifconfig
是一个用于配置和显示 Linux 内核中网络接口的命令行实用程序。在 CentOS 系统中,它同样适用。以下是 ifconfig
命令的详细解释:
查看所有网络接口:
ifconfig
或者
ifconfig -a
这将显示系统中所有活动的网络接口及其相关信息。
查看特定网络接口:
ifconfig eth0
将显示名为 eth0
的网络接口的详细信息。
-a
或 --all
:显示所有网络接口,包括未启动的。-i
或 --interface=INTERFACE
:指定要操作的网络接口。-s
或 --summary
:显示网络接口的摘要信息。-v
或 --verbose
:显示详细的配置信息。-h
或 --help
:显示帮助信息。ifconfig
命令的输出通常包括以下字段:
eth0
、wlan0
等。启动网络接口:
sudo ifconfig eth0 up
关闭网络接口:
sudo ifconfig eth0 down
为网络接口分配 IP 地址:
sudo ifconfig eth0 192.168.1.100 netmask 255.255.255.0
删除网络接口的 IP 地址:
sudo ifconfig eth0 0.0.0.0
请注意,ifconfig
命令在较新的 Linux 发行版中可能已被 ip
命令取代。尽管如此,ifconfig
仍然在许多系统中广泛使用。