温馨提示×

debian ifconfig是什么命令

小樊
37
2026-10-12 09:08:21
栏目: 智能运维

在 Debian(以及大多数 Linux 发行版)中,ifconfig 是一个用于查看和配置网络接口的传统命令,全称是 interface configuration。

一、ifconfig 是什么

  • 属于 net-tools 软件包
  • 用于:
    • 查看网络接口信息(IP、MAC、掩码、状态)
    • 配置 IP 地址、子网掩码
    • 启用 / 禁用网卡

示例:

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(如 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

四、如果要用 ifconfig

可以安装:

sudo apt update
sudo apt install net-tools

五、总结

  • ifconfig:老命令,已逐渐被淘汰
  • 新系统建议学 ip 命令
  • Debian 上不是“没有”,而是“默认不用”

如果你愿意,我可以给你一份 ifconfig → ip 完整对照表 或 Debian 网络配置教程。

0 踩