在较新的 Linux 发行版中,ifconfig 命令属于 net-tools 软件包,而很多系统默认只安装了 iproute2(使用 ip 命令)。如果你发现系统中没有 ifconfig,可以按下面的方法安装。
which ifconfig
或
ifconfig
如果提示 command not found,说明未安装。
sudo apt update
sudo apt install net-tools
sudo yum install net-tools
或(CentOS 8+ / RHEL 8+):
sudo dnf install net-tools
sudo pacman -S net-tools
sudo zypper install net-tools
ifconfig
或查看某个网卡:
ifconfig eth0
⚠️ ifconfig 已被弃用,官方推荐使用:
ip addr
ip link
ip route
功能和 ifconfig 类似,且更强大。
如果你告诉我具体的 Linux 发行版和版本号,我可以给你更精确的命令。