1. 前言
本文主要讲解如何在CentOS8或RHEL8系统中安装ifconfig
命令。
你的RHEL 8 / CentOS 8最小化安装版中没有找到Ifconfig
命令吗?RHEL8 / CentOS8的最小安装并没有附带ifconfig命令。参见RHEL 8的新特性
ifconfig是一个命令行工具,用于配置驻留内核的网络接口。使用ifconfig
,您可以配置一个网络接口,显示当前可用的所有接口,即使是关闭的。
注意:ifconfig
程序已经过时了!请使用ip addr
和ip link
命令。
在RHEL 8 / CentOS 8的最小安装上,ifconfig
命令由net-tools
提供,它是基本的网络管理工具组包。
yum provides ifconfig
Updating Subscription Management repositories.
Updating Subscription Management repositories.
Last metadata expiration check: 21 days, 0:07:56 ago on Fri 30 Nov 2018 03:57:18 AM EST.
net-tools-2.0-0.51.20160912git.el8.x86_64 : Basic networking tools
Repo : @System
Matched from:
Filename : /usr/sbin/ifconfig
net-tools-2.0-0.51.20160912git.el8.x86_64 : Basic networking tools
Repo : rhel-8-for-x86_64-baseos-beta-rpms
Matched from:
Filename : /usr/sbin/ifconfig
2. 在RHEL8或CentOS8系统上如何安装ifconfig
命令
要获得ifconfig命令,请安装net-tools
包:
sudo yum -y install net-tools
3. ifconfig
命令使用案例
3.1 使用ifconfig
命令显示第一个以太网适配器的网络设置
假设无线网卡为wlan0,有线网卡为etho,请使用ip addr
查看当前网卡标识。
ifconfig wlan0
ifconfig eth0
3.2 使用ifconfig
命令显示所有接口信息
ifconfig -a
3.3 使用ifconfig
命令开启与禁用接口
ifconfig wlan0/eth0 {up|down}
3.4 使用ifconfig
命令设置静态IP和子网掩码
ifconfig eth0 192.168.1.100 netmask 255.255.255.0
3.5 使用ifconfig
命令添加网关
route add -net 192.168.1.0 netmask 255.255.255.0 gw 192.168.1.1
3.6 使用ifconfig
命令修改网卡的MAC地址
ifconfig eth0 hw ether AA:BB:CC:DD:EE:FF
3.7 开启混杂模式
ifconfig eth0 promisc
ifconfig eth0 -promisc
3.8 添加网络接口别名
ifconfig eth0:0 172.16.25.127
ifconfig eth0:0 down
4.总结
通过本文您应该了解到如何在RHEL8或CentOS8上安装ifconfig
命令了吗?
评论前必须登录!
注册