In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-03-31 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.
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.