In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-18 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/01 Report--
Editor to share with you what are the commands to check the mac address in the Linux system. I hope you will get something after reading this article. Let's discuss it together.
MAC (Media Access Control, Media access Control) is used to define the location of network devices. The identifier used to represent each site on the Internet, expressed in hexadecimal numbers, with a total of six bytes (48 bits).
1:ifconfig command to check the Nic MAC address / sbin/ifconfig | grep HWaddr
Or
/ sbin/ifconfig | grep ether
The MAC address field for some Linux distributions is HWaddr, and the MAC address field for some Linux distributions is ether. Choose the above command according to the actual situation.
[root@KerryDB] # ifconfig-a lo: flags=73 mtu 65536 inet 127.0.0.1 netmask 255.0.0.0 inet6:: 1 prefixlen 128 scopeid 0x10 loop txqueuelen 1000 (Local Loopback) RX packets 858 bytes 72251 (70.5 KiB) RX errors 0 dropped 0 overruns 0 frame 0 TX packets 858 bytes 72251 (70.5 KiB) TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0 p4p1: flags=4163 Mtu 1500 inet 10.20.57.24 netmask 255.255.255.0 broadcast 10.20.57.255 inet6 fe80::b283:feff:fe55:32e5 prefixlen 64 scopeid 0x20 ether b0:83:fe:55:32:e5 txqueuelen 1000 (Ethernet) RX packets 6637181 bytes 1536293500 (1.4 GiB) RX errors 0 dropped 293652 overruns 0 frame 0 TX packets 4333535 bytes 1080300983 (1.0 GiB) TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0 if you want to extract only the MAC address of the network card You can use the following command (replace xxx with a specific network card name)
Ifconfig xxx | grep-o-E'([[: xdigit:]] {1 xdigit 2}:) {5} [[: xdigit:]] {1jue 2}'
[root@KerryDB tmp] # ifconfig p4p1 | grep-o-E'([[: xdigit:]] {1xxx 2}:) {5} [[: xdigit:]] {1Power2} 'b0:83:fe:55:32:e5 [root@KerryDB tmp] # method 2:/sys/class/net/xxx/address view is adjusted according to the name of the network card, for example, the name of the network card is ens160, if the name of the network card is xxx, then / sys/class/net/xxx/address should be used.
# more / sys/class/net/ens160/address 00:50:56:95:5c:16 # cat / sys/class/net/eth0/address 00:50:56:b3:81:f8 method 3:ip command to view the MAC address of the network card [root@KerryDB tmp] # ip link 1: lo:mtu 65536 qdisc noqueue state UNKNOWN mode DEFAULT group default qlen 1000 link/loopback 0000 brd 00 00 brd 00 00: p4p1:mtu 1500 qdisc pfifo_fast state UP mode DEFAULT group default qlen 1000 link/ether b0:83:fe:55:32:e5 brd ff:ff:ff:ff:ff:ff [root@KerryDB tmp] # ip link show 1: lo:mtu 65536 qdisc noqueue state UNKNOWN mode DEFAULT group default qlen 1000 link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00 2: p4p1:mtu 1500 qdisc pfifo_fast state UP mode DEFAULT group default qlen 1000 link/ether b0: 83:fe:55:32:e5 brd ff:ff:ff:ff:ff:ff [root@KerryDB tmp] # ip link show p4p1 2: p4p1:mtu 1500 qdisc pfifo_fast state UP mode DEFAULT group default qlen 1000 link/ether b0:83:fe:55:32:e5 brd ff:ff:ff:ff:ff:f [root@KerryDB tmp] # ip link show p4p1 | awk'/ ether/ {print $2}' B0:83:fe:55:32:e54:nmcli command to check the Nic MAC address [root@KerryDB tmp] # nmcli device show p4p1 GENERAL.DEVICE: p4p1 GENERAL.TYPE: ethernet GENERAL.HWADDR: B0:83:FE:55:32:E5 GENERAL.MTU: 1500 GENERAL.STATE: 100 (connected) GENERAL.CONNECTION: p4p1 GENERAL.CON-PATH: / org/freedesktop/NetworkManager/ActiveConnection/1 WIRED-PROPERTIES.CARRIER: on IP4.ADDRESS [1]: 10.20.57.24 IP4.GATEWAY: 10 .20.57.1 IP4.ROUTE [1]: dst = 10.20.57.0 Nh = 0.0.0.0, mt = 100IP4.ROUTE [2]: dst = 0.0.0.0Univer, nh = 10.20.57.1 Mt = 100IP6.ADDRESS [1]: fe80::b283:feff:fe55:32e5/64 IP6.GATEWAY:-- IP6.ROUTE [1]: dst = ff00::/8, nh =:, mt = 256, table=255 IP6.ROUTE [2]: dst = fe80::/64, nh =:: Mt = 256 [root@KerryDB tmp] # nmcli device show p4p1 | grep-I hw GENERAL.HWADDR: B0:83:FE:55:32:E5 Note: adjust according to the actual Nic name here If the network card is named ens160, then the above command needs to be adjusted to
# nmcli device show ens160 | grep-I hwaddr GENERAL.HWADDR: 00:50:56:B4:00:945:dmesg command to check the MAC address of the network card [root@KerryDB tmp] # dmesg | grep eth [0.776155] r8169 0000 hwaddr GENERAL.HWADDR 02 XID 0c000800 IRQ 00.0 eth0: RTL8168g/8111g at 0xffffafbe80648000, b0:83:fe:55:32:e5, XID 0c000800 IRQ 27 [0.776158] r8169 0000 Fran 02Frey 00.0 eth0: jumbo features [frames: 9200 bytes Tx checksumming: ko] finished reading this article I believe you have a certain understanding of "what are the mac address commands in the Linux system?" if you want to know more about it, you are welcome to follow the industry information channel, thank you for reading!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.