在较新的 Linux 发行版中,ifconfig 命令通常默认不再安装,被 ip 命令取代。你可以按下面方式解决:
ip 命令查看网卡和 IP 信息:
ip addr
查看网络接口状态:
ip link
启用 / 禁用网卡:
ip link set eth0 up
ip link set eth0 down
ifconfig(推荐)sudo apt update
sudo apt install net-tools
sudo yum install net-tools
或(CentOS 8+ / Rocky / Alma):
sudo dnf install net-tools
sudo pacman -S net-tools
sudo zypper install net-tools
安装完成后即可使用:
ifconfig
which ifconfig
如果输出路径说明可用,否则会提示找不到。
ip 命令ifconfig 已逐步被弃用,仅用于兼容旧脚本如果你告诉我你的 Linux 发行版和版本,我可以给你更精确的命令。