温馨提示×

如何开启linux ifconfig功能

小樊
43
2026-10-02 00:42:31
栏目: 智能运维

在较新的 Linux 发行版中,ifconfig 命令默认可能未安装,因为它属于 net-tools 工具包,而许多系统已转向使用 ip 命令(来自 iproute2)。以下是开启/使用 ifconfig 的方法:


一、检查 ifconfig 是否已安装

which ifconfig

或

ifconfig

如果提示 command not found,说明未安装。


二、安装 net-tools(提供 ifconfig)

1. Debian / Ubuntu / Linux Mint

sudo apt update
sudo apt install net-tools

2. CentOS / RHEL / Rocky / AlmaLinux

sudo yum install net-tools

或(CentOS 8+)

sudo dnf install net-tools

3. Arch Linux

sudo pacman -S net-tools

4. openSUSE

sudo zypper install net-tools

三、使用 ifconfig

安装完成后即可使用:

ifconfig

查看网卡信息:

ifconfig eth0

启用/禁用网卡:

sudo ifconfig eth0 up
sudo ifconfig eth0 down

四、推荐:使用 ip 命令(现代方式)

ip addr
ip link

启用网卡:

sudo ip link set eth0 up

如果你是在 容器(Docker) 或 最小化系统 中,也可能无法直接使用 ifconfig,可以告诉我你的系统版本,我可以给你更精确的步骤。

0 踩