温馨提示×

centos中ifconfig命令使用技巧

小樊
85
2025-02-13 09:42:47
栏目: 智能运维
Centos服务器限时活动,0元免费领,库存有限,领完即止! 点击查看>>

ifconfig 是一个用于配置和显示 Linux 内核中网络接口的命令行实用程序。在 CentOS 系统中,你可以使用 ifconfig 命令来查看和管理网络接口。以下是一些常用的 ifconfig 命令技巧:

  1. 查看所有网络接口信息:
ifconfig
  1. 查看指定网络接口的信息(例如:eth0):
ifconfig eth0
  1. 启动指定的网络接口(例如:eth0):
sudo ifconfig eth0 up
  1. 关闭指定的网络接口(例如:eth0):
sudo ifconfig eth0 down
  1. 为指定的网络接口分配 IP 地址(例如:eth0,IP 地址为 192.168.1.100,子网掩码为 255.255.255.0):
sudo ifconfig eth0 192.168.1.100 netmask 255.255.255.0
  1. 删除指定的网络接口的 IP 地址(例如:eth0):
sudo ifconfig eth0 0.0.0.0
  1. 临时修改网络接口的 MTU(最大传输单元)值(例如:eth0,MTU 值为 1400):
sudo ifconfig eth0 mtu 1400
  1. 显示网络接口的广播地址:
ifconfig eth0 broadcast
  1. 显示网络接口的 MAC 地址:
ifconfig eth0 hw ether
  1. 将网络接口设置为混杂模式(用于抓包等操作):
sudo ifconfig eth0 promisc
  1. 取消网络接口的混杂模式:
sudo ifconfig eth0 -promisc

请注意,ifconfig 命令在某些 Linux 发行版中可能已被弃用,建议使用 ip 命令替代。

亿速云「云服务器」,即开即用、新一代英特尔至强铂金CPU、三副本存储NVMe SSD云盘,价格低至29元/月。点击查看>>

推荐阅读:centos如何使用ifconfig命令

0