In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-09-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/02 Report--
How does linux check the mac address? This problem may be often seen in our daily study or work. I hope you can gain a lot from this question. The following is the reference content that the editor brings to you, let's take a look at it!
The commands for linux to check the mac address are: "ifconfig-a" command, "cat / sys/class/net/eth0/address" command, "dmesg | grep eth0" command, "cat / proc/net/arp" command, and so on.
The method of checking mac address by linux
PS: generally, the default Nic file name is eth0, which can be judged to be ethx according to the actual situation area corresponding to the IP address.
1. Ifconfig-a where the HWaddr field is the MAC address, which is the most commonly used method
2. Cat / etc/sysconfig/network-scripts/ifcfg-eth0 (CentOS or Redhat configuration file)
The following two can be viewed before IP is set. It can be used to solve the problem of binding between MAC and operating system. For example, if you install the operating system to a remote server, the mac address of the operating system is the address of host A, and it cannot be started remotely on host B due to different MAC addresses (because the configuration file is still the mac address of An at this time). Because OS detects the hardware at startup, gets the MAC address of the hardware and writes it to the / sys/class/net/eth0/address file, after OS gets the mac address, we write the real mac address to the configuration file before using the original MAC configuration file (that is, / etc/sysconfig/network-scripts/ifcfg-eth0).
3. Cat / sys/class/net/eth0/address check the MAC address of eth0
4. Dmesg | grep eth0
Dmesg' command equipment fault diagnosis is very important. When we connect or disconnect the hardware with the help of the 'dmesg' command, we can see the detection or disconnection information of the hardware.
5. Cat / proc/net/arp check the MAC address of the remote IP connected to the local computer
Can not see the local MAC, can only see the remote connection, the server uses more.
6. Use the ioctl command of SIOCGIFHWADDR to obtain the MAC address in the program
Thank you for reading! After reading the above, do you have a general idea of how linux looks up the mac address? I hope the content of the article will be helpful to all of you. If you want to know more about the relevant articles, you are welcome to follow the industry information channel.
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.
The market share of Chrome browser on the desktop has exceeded 70%, and users are complaining about
The world's first 2nm mobile chip: Samsung Exynos 2600 is ready for mass production.According to a r
A US federal judge has ruled that Google can keep its Chrome browser, but it will be prohibited from
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
About us Contact us Product review car news thenatureplanet
More Form oMedia: AutoTimes. Bestcoffee. SL News. Jarebook. Coffee Hunters. Sundaily. Modezone. NNB. Coffee. Game News. FrontStreet. GGAMEN
© 2024 shulou.com SLNews company. All rights reserved.