如何在debian上安装ifconfig

时间:2020-03-05 15:27:42  来源:igfitidea点击:

如果我们尝试使用Debian 10中的Ifconfig命令获取IP或者网络详细信息,则会遇到"Ifconfig:命令未找到"错误。

-bash: ifconfig: command not found

DEBIAN上默认未安装IFCONFIG包。
这是因为ifconfig被弃用支持新的IP命令。
此IP命令现在负责修改或者显示路由,网络设备,接口和隧道。

如果我们仍然想要使用Good younconfig命令,则必须明确安装它。

在Debian中安装ifconfig命令

如果我们尝试直接安装ifconfig命令,则Debian系统找不到此包。

Hyman@theitroad:~# apt install ifconfig
Reading package lists... Done
Building dependency tree       
Reading state information... Done
E: Unable to locate package ifconfig

这是因为Ifconfig不是自己的包。
它安装有具有一些其他网络工具的Net-Tools包。

因此要获取ifconfig,我们需要安装这样的网络工具包:

sudo apt install net-tools

安装后,我们使用ifconfig命令:

Hyman@theitroad:~# 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将完全弃用,我们将无法安装它。