Mac 地址,又称硬件地址或物理地址,用于标识网络设备(如网卡、路由器)在网络中的唯一身份。在 Linux 系统中,查看 mac 地址十分简便,可通过多种命令实现。
ifconfig 命令
最常用的 是使用 ifconfig 命令,该命令可显示网络接口配置信息,包括 mac 地址。执行以下命令即可查看当前所有网络接口的 mac 地址:
ifconfig
例如,输出中可能显示如下信息:
eth0: flags=4163
ether 00:50:56:c0:00:08 txqueuelen 1000 (Ethernet)
其中,"ether" 行显示了该网络接口的 mac 地址("00:50:56:c0:00:08")。
ip 命令
ip 命令是 Linux 系统中用于配置和管理网络接口的更强大工具。它也可以用于查看 mac 地址。执行以下命令即可查看当前所有网络接口的 mac 地址:
ip link show
例如,输出中可能显示如下信息:
1: lo:
link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
2: eth0:
link/ether 00:50:56:c0:00:08 brd ff:ff:ff:ff:ff:ff
其中,"link/ether" 行显示了该网络接口的 mac 地址("00:50:56:c0:00:08")。
ethtool 命令
ethtool 命令专门用于以太网设备的配置和诊断。它也可以用于查看 mac 地址。执行以下命令即可查看指定网络接口的 mac 地址:
ethtool -i <接口名称>
例如,要查看 eth0 网络接口的 mac 地址,执行以下命令:
ethtool -i eth0
输出中将包含以下信息:
Settings for eth0:
...
Permanent Address: 00:50:56:c0:00:08
在 Linux 系统中查看 mac 地址非常简单,有 ifconfig、ip 和 ethtool 等多种命令可供使用。这些命令的使用 简单,可以快速、准确地获取网络设备的 mac 地址。