温馨提示×

centos下ifconfig命令格式是什么

小樊
38
2025-12-27 07:46:12
栏目: 智能运维

在 CentOS 系统中,ifconfig 命令用于配置、激活和查询网络接口。其基本格式如下:

ifconfig [interface] [options]
  • [interface]:指定要操作的网络接口名称,例如 eth0ens33 等。
  • [options]:可选参数,用于指定对网络接口的操作。

以下是一些常用的 ifconfig 命令示例:

  1. 查看所有网络接口的信息:
ifconfig
  1. 查看指定网络接口的信息(例如 eth0):
ifconfig eth0
  1. 激活网络接口(例如 eth0):
ifconfig eth0 up
  1. 关闭网络接口(例如 eth0):
ifconfig eth0 down
  1. 为网络接口分配 IP 地址(例如 eth0 分配 IP 地址 192.168.1.100,子网掩码为 255.255.255.0):
ifconfig eth0 192.168.1.100 netmask 255.255.255.0
  1. 删除网络接口的 IP 地址(例如 eth0):
ifconfig eth0 down

请注意,ifconfig 命令在较新的 CentOS 版本中可能已被弃用,建议使用 ip 命令来替代。

0