在 CentOS 系统中,ifconfig 命令用于配置、激活和查询网络接口的参数。以下是 ifconfig 命令的基本使用方法:
ifconfig [interface] [options]
interface:指定要操作的网络接口名称,例如 eth0、wlan0 等。options:可选参数,用于配置接口。-a 或 --all:显示所有网络接口的信息,包括未启动的接口。-i:指定接口名称。-s:显示每个接口的统计信息。-v:显示详细信息。-h:以人类可读的格式显示信息。-r:显示路由表信息。-n:以数字形式显示地址和端口。查看所有网络接口的信息
ifconfig -a
查看特定网络接口的信息
ifconfig eth0
查看所有网络接口的统计信息
ifconfig -s
以人类可读的格式查看特定网络接口的信息
ifconfig eth0 -h
查看路由表信息
ifconfig -r
以数字形式查看特定网络接口的信息
ifconfig eth0 -n
ifconfig 命令也可以用于配置网络接口的 IP 地址、子网掩码等参数。以下是一些示例:
设置 IP 地址和子网掩码
ifconfig eth0 192.168.1.100 netmask 255.255.255.0
启用网络接口
ifconfig eth0 up
禁用网络接口
ifconfig eth0 down
ifconfig 命令在较新的 CentOS 版本中可能已被弃用,推荐使用 ip 命令来管理网络接口。ipip 命令是 ifconfig 的替代品,提供了更强大的功能。以下是一些常用的 ip 命令示例:
查看所有网络接口的信息
ip addr show
查看特定网络接口的信息
ip addr show eth0
设置 IP 地址和子网掩码
ip addr add 192.168.1.100/24 dev eth0
启用网络接口
ip link set eth0 up
禁用网络接口
ip link set eth0 down
希望这些信息对你有所帮助!如果你有任何其他问题,请随时提问。