在 Debian(以及大多数 Linux 发行版)中,ifconfig 是一个用于查看和配置网络接口的传统命令,全称是 interface configuration。
ifconfig 是什么示例:
ifconfig
显示所有网络接口信息。
ifconfig eth0
只看 eth0 网卡。
# 给 eth0 配置 IP
sudo ifconfig eth0 192.168.1.100 netmask 255.255.255.0
# 启用网卡
sudo ifconfig eth0 up
# 禁用网卡
sudo ifconfig eth0 down
在**新版本 Debian(如 Debian 9+)**中:
ifconfig 默认不再预装ip 命令(来自 iproute2)等价对照:
| 功能 | ifconfig | ip 命令 |
|---|---|---|
| 查看网卡 | ifconfig |
ip addr |
| 启用网卡 | ifconfig eth0 up |
ip link set eth0 up |
| 配置 IP | ifconfig eth0 192.168.1.2 |
ip addr add 192.168.1.2/24 dev eth0 |
可以安装:
sudo apt update
sudo apt install net-tools
ifconfig:老命令,已逐渐被淘汰ip 命令如果你愿意,我可以给你一份 ifconfig → ip 完整对照表 或 Debian 网络配置教程。