温馨提示×

怎样用linux ifconfig查网卡

小樊
49
2026-10-02 00:40:32
栏目: 智能运维

在 Linux 中,ifconfig 常用于查看和配置网络接口(网卡)。下面按常见用法说明。


一、查看所有网卡(最常用)

ifconfig

或(有些系统需要)

/sbin/ifconfig

输出示例:

eth0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
      inet 192.168.1.10  netmask 255.255.255.0
      ether 00:0c:29:xx:xx:xx

lo: flags=73<UP,LOOPBACK,RUNNING>  mtu 65536
      inet 127.0.0.1

✅ 这里:

  • eth0 是网卡名
  • inet 是 IP 地址
  • ether 是 MAC 地址

二、只查看某个网卡

ifconfig eth0

三、查看网卡是否启用

ifconfig -a
  • 会列出所有网卡(包括未启用的)
  • 没有 UP 标志的说明未启用

四、只看 IP 地址(精简)

ifconfig | grep inet

五、常见问题

1️⃣ 命令不存在

新版本 Linux 可能默认没有 ifconfig

command not found: ifconfig

解决方法:

  • Ubuntu / Debian:
sudo apt install net-tools
  • CentOS / RHEL:
sudo yum install net-tools

2️⃣ 推荐替代命令(新版系统)

ip addr

或

ip link

六、总结

目的 命令
查所有网卡 ifconfig
查全部(含未启用) ifconfig -a
查指定网卡 ifconfig eth0
查 IP `ifconfig

如果你是想查网卡名、IP、MAC、是否连通,可以告诉我你的系统(Ubuntu / CentOS 等),我可以给你更精确的命令。

0 踩