centos

CentOS 中如何用 ifconfig 进行网络诊断

小樊
92
2025-02-08 13:06:05
栏目: 智能运维

在 CentOS 中,ifconfig 是一个用于配置和显示网络接口的命令行工具

  1. 查看所有网络接口及其状态:
ifconfig
  1. 查看特定网络接口的状态(例如,查看名为 eth0 的接口):
ifconfig eth0
  1. 查看 IP 地址和子网掩码:
ifconfig eth0 | grep 'inet '
  1. 查看广播地址:
ifconfig eth0 | grep 'broadcast'
  1. 查看网络接口的 MAC 地址:
ifconfig eth0 | grep 'ether'
  1. 添加一个新的网络接口(例如,添加名为 eth1 的接口):
sudo ifconfig eth1 up
  1. 配置静态 IP 地址(例如,为 eth1 接口配置 IP 地址 192.168.1.10 和子网掩码 255.255.255.0):
sudo ifconfig eth1 192.168.1.10 netmask 255.255.255.0
  1. 禁用网络接口(例如,禁用 eth1 接口):
sudo ifconfig eth1 down
  1. 启用网络接口(例如,启用 eth1 接口):
sudo ifconfig eth1 up
  1. 删除网络接口(例如,删除 eth1 接口):
sudo ifconfig -d eth1

请注意,CentOS 7 及更高版本中的网络管理工具已从 ifconfig 更改为 ip。在这些系统上,您需要使用 ip 命令进行网络诊断。

0
看了该问题的人还看了