在CentOS7下获取Mac地址的值

时间:2024-11-15 10:28:06


[root@localhost shell]# ifconfig eth0
eth0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet 192.168.2.10  netmask 255.255.255.0  broadcast 192.168.2.255
        inet6 fe80::20c:29ff:fed7:8537  prefixlen 64  scopeid 0x20<link>
        ether 00:0c:29:d7:85:37  txqueuelen 1000  (Ethernet)
        RX packets 137188  bytes 184028883 (175.5 MiB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 42678  bytes 3437016 (3.2 MiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0


[root@localhost shell]# ifconfig eth0 |egrep "ether" 
        ether 00:0c:29:d7:85:37  txqueuelen 1000  (Ethernet)
[root@localhost shell]# ifconfig eth0 |egrep "ether" |awk '{print $2}'
00:0c:29:d7:85:37
[root@localhost shell]#