温馨提示×

debian ifconfig是什么

小樊
42
2026-09-06 15:59:55
栏目: 智能运维

在 Debian 系统中,ifconfig 是一个用于查看和配置网络接口的命令(来源于 net-tools 工具包)。

1️⃣ ifconfig 是什么

  • 全称:interface config
  • 作用:
    • 查看网卡 IP 地址、MAC 地址
    • 启用 / 禁用网卡
    • 配置 IP 地址、子网掩码等
  • 示例输出中常见内容:
    • eth0 / ens33:有线网卡
    • lo:回环接口(127.0.0.1)
    • wlan0:无线网卡

2️⃣ 常见用法

ifconfig          # 查看所有启用的网络接口
ifconfig -a      # 查看所有接口(包括未启用的)
ifconfig eth0    # 查看指定网卡

配置示例:

sudo ifconfig eth0 192.168.1.100 netmask 255.255.255.0
sudo ifconfig eth0 up
sudo ifconfig eth0 down

3️⃣ Debian 中的现状(重要)

⚠️ ifconfig 已逐渐被弃用

  • Debian 新版本(如 Debian 9+)默认不再安装
  • 官方推荐使用 ip 命令(来自 iproute2)

等价替代:

ip addr          # 替代 ifconfig
ip link          # 替代 ifconfig -a
ip link set eth0 up

4️⃣ 如果要用 ifconfig

安装:

sudo apt update
sudo apt install net-tools

5️⃣ 总结

  • ifconfig:老式网络配置命令
  • Debian 新系统:推荐用 ip
  • 学习或维护老服务器时仍会常见

如果你愿意,我可以帮你对比 ifconfig vs ip 的对照表,或者看你当前 Debian 版本该怎么查 IP。

0 踩