ifconfig 是一个用于配置和显示 Linux 内核中网络接口的命令行实用程序。在 Debian 系统中,你可以使用 ifconfig 命令来查看网络接口的状态、配置 IP 地址等。以下是一些实战案例:

要查看系统上所有活动的网络接口,只需在终端中输入以下命令:
ifconfig这将显示类似以下内容的输出:
eth0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>mtu 1500inet 192.168.1.100netmask 255.255.255.0broadcast 192.168.1.255inet6 fe80::a00:27ff:fe4e:66a1prefixlen 64scopeid 0x20<link>ether 08:00:27:4e:66:a1txqueuelen 1000(Ethernet)RX packets 1003456bytes 123456789 (117.7 MiB)RX errors 0dropped 0overruns 0frame 0TX packets 987654bytes 987654321 (941.5 MiB)TX errors 0dropped 0 overruns 0carrier 0collisions 0lo: flags=73<UP,LOOPBACK,RUNNING>mtu 65536inet 127.0.0.1netmask 255.0.0.0inet6 ::1prefixlen 128scopeid 0x10<host>looptxqueuelen 1000(Local Loopback)RX packets 12345bytes 123456 (120.6 KiB)RX errors 0dropped 0overruns 0frame 0TX packets 12345bytes 123456 (120.6 KiB)TX errors 0dropped 0 overruns 0carrier 0collisions 0要将 IP 地址分配给特定的网络接口(例如 eth0),可以使用以下命令:
sudo ifconfig eth0 192.168.1.100 netmask 255.255.255.0这将把 IP 地址 192.168.1.100 和子网掩码 255.255.255.0 分配给 eth0 接口。
要启用或禁用特定的网络接口(例如 eth0),可以使用以下命令:
启用接口:
sudo ifconfig eth0 up禁用接口:
sudo ifconfig eth0 down要将网络接口(例如 eth0)的 MTU(最大传输单元)更改为 1400,可以使用以下命令:
sudo ifconfig eth0 mtu 1400请注意,更改 MTU 可能会影响网络性能,因此在进行更改之前,请确保了解其影响。
要查看特定网络接口(例如 eth0)的详细信息,可以使用以下命令:
ifconfig eth0这将显示 eth0 接口的详细配置信息,包括 IP 地址、子网掩码、广播地址等。
这些案例应该可以帮助你开始使用 ifconfig 命令来管理和配置 Debian 系统上的网络接口。然而,请注意,ifconfig 已经被废弃,建议使用 ip 命令来替代。