在Linux或FreeBSD中,如何查看网卡的MAC地址?

时间:2019-11-20 08:53:34  来源:igfitidea点击:

如何查看网口的mac地址?

ifconfig命令

使用ifconfig查看网口的mac地址:

$ /sbin/ifconfig | grep HWaddr

输出:

eth0      Link encap:Ethernet  HWaddr 00:0F:EA:91:04:07

或者

$ /sbin/ifconfig | grep ether

或者

$ /sbin/ifconfig
eth0      Link encap:Ethernet  HWaddr 00:0F:EA:91:04:07
        inet addr:192.168.1.2  Bcast:192.168.1.255  Mask:255.255.255.0
        inet6 addr: fe80::20f:eaff:fe91:407/64 Scope:Link
        UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
        RX packets:60400 errors:0 dropped:0 overruns:0 frame:0
        TX packets:109216 errors:0 dropped:0 overruns:0 carrier:0
        collisions:0 txqueuelen:1000
        RX bytes:69273219 (66.0 MiB)  TX bytes:14285799 (13.6 MiB)
        Interrupt:18 Base address:0xc000

lo        Link encap:Local Loopback
        inet addr:127.0.0.1  Mask:255.0.0.0
        inet6 addr: ::1/128 Scope:Host
        UP LOOPBACK RUNNING  MTU:16436  Metric:1
        RX packets:3869 errors:0 dropped:0 overruns:0 frame:0
        TX packets:3869 errors:0 dropped:0 overruns:0 carrier:0
        collisions:0 txqueuelen:0
        RX bytes:396498 (387.2 KiB)  TX bytes:396498 (387.2 KiB)

也可以查看启动日志:

# grep eth0 /var/log/dmesg
eth0: RealTek RTL8139 at 0xc000, 00:0f:ea:91:04:07, IRQ 18
eth0:  Identified 8139 chip type 'RTL-8100B/8139D'
eth0: link up, 100Mbps, full-duplex, lpa 0x45E1