在 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 标志的说明未启用ifconfig | grep inet
新版本 Linux 可能默认没有 ifconfig
command not found: ifconfig
解决方法:
sudo apt install net-tools
sudo yum install net-tools
ip addr
或
ip link
| 目的 | 命令 |
|---|---|
| 查所有网卡 | ifconfig |
| 查全部(含未启用) | ifconfig -a |
| 查指定网卡 | ifconfig eth0 |
| 查 IP | `ifconfig |
如果你是想查网卡名、IP、MAC、是否连通,可以告诉我你的系统(Ubuntu / CentOS 等),我可以给你更精确的命令。