如果您尝试在 Debian 10 中使用 ifconfig 命令获取 IP 或网络详细信息,您将遇到“ifconfig: command not found”错误。
-bash: ifconfig: command not found
Debian 上默认不安装 ifconfig 软件包。 这是因为 ifconfig 被弃用,取而代之的是新的 ip 命令. 此 ip 命令现在负责修改或显示路由、网络设备、接口和隧道。
如果您仍想使用旧的 ifconfig 命令,则必须显式安装它。
在 Debian 中安装 ifconfig 命令
如果您尝试直接安装 ifconfig 命令,您的 Debian 系统不会找到这个包。
[email protected]:~# apt install ifconfig
Reading package lists... Done
Building dependency tree
Reading state information... Done
E: Unable to locate package ifconfig
这是因为 ifconfig 本身不是一个包。 它安装有 网络工具包 有一些额外的网络工具。
所以要获得 ifconfig,你需要像这样安装 net-tools 包:
sudo apt install net-tools

安装后,使用 ifconfig 命令:
[email protected]:~# ifconfig
eth0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet 172.124.55.175 netmask 255.255.255.0 broadcast 172.124.55.255
inet6 2400:8966::f03c:92ff:fe32:ffef prefixlen 64 scopeid 0x0<global>
inet6 fe80::f03c:99ff:fe32:ffef prefixlen 64 scopeid 0x20<link>
ether f2:3c:92:32:ff:df txqueuelen 1000 (Ethernet)
RX packets 1623 bytes 421318 (411.4 KiB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 876 bytes 108871 (106.3 KiB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
lo: flags=73<UP,LOOPBACK,RUNNING> mtu 65536
inet 127.0.0.1 netmask 255.0.0.0
inet6 ::1 prefixlen 128 scopeid 0x10<host>
loop txqueuelen 1000 (Local Loopback)
RX packets 0 bytes 0 (0.0 B)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 0 bytes 0 (0.0 B)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
但是,我强烈建议您应该开始使用 IP 命令。 迟早,net-tools 将被完全弃用,您将无法安装它。