Home>Article>Operation and Maintenance> What is the command to query mac address in Linux?

What is the command to query mac address in Linux?

青灯夜游
青灯夜游 Original
2023-03-10 10:20:06 20416browse

Command to query the mac address: 1. "ifconfig -a", the HWaddr field of the output result is the MAC address; 2. "cat /etc/sysconfig/network-scripts/ifcfg-eth0", read the MAC Configuration file; 3. "cat /sys/class/net/eth0/address"; 4. "dmesg | grep eth0"; 5. "cat /proc/net/arp".

What is the command to query mac address in Linux?

The operating environment of this tutorial: linux7.3 system, Dell G3 computer.

What is the mac address?

MAC (Media Access Control, media access control) is used to define the location of network devices. An identifier used to represent each site on the Internet, expressed in hexadecimal numbers, with a total of six bytes (48 bits). Among them, the first three bytes are codes (high-order 24 bits) assigned to different manufacturers by the IEEE registration authority RA, also known as "Organizationally Unique Identifier", and the last three bytes are (lower 24 bits) is assigned by each manufacturer to the adapter interface produced, called an extended identifier (uniqueness). An address block can generate 2^24 different addresses. The MAC address is actually the adapter address or adapter identifier. MAC is globally unique.

How to query the mac address in Linux

PS: Generally, the default network card file name is eth0, which can be determined based on the actual situation corresponding to the IP address. Just ethx.

1,ifconfig -aThe HWaddr field is the MAC address, which is the most commonly used method

What is the command to query mac address in Linux?

2,cat /etc/sysconfig/network-scripts/ifcfg-eth0(CentOS or Redhat configuration file)

What is the command to query mac address in Linux?

below Both types can be viewed before IP is set. 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. On host B, it cannot be started remotely because the MAC address is different (because the configuration file is still the mac address of A at this time). Since the OS will detect the hardware when it starts, obtain the MAC address of the hardware, and write it to the /sys/class/net/eth0/address file, after the OS obtains the mac address, before using the original MAC configuration file (that is, /etc /sysconfig/network-scripts/ifcfg-eth0), write the real mac address into the configuration file.

3、cat /sys/class/net/eth0/addressCheck the MAC address of eth0

What is the command to query mac address in Linux?

4,dmesg | grep eth0

dmesg' command is very important to diagnose device faults. When performing hardware connection or disconnection operations with the help of the 'dmesg' command, we can see the hardware detection or disconnection information.

What is the command to query mac address in Linux?

5、cat /proc/net/arpView the MAC of the remote IP connected to this machine The address

cannot see the MAC of the local machine, only the remote connection, which is mostly used by the server.

What is the command to query mac address in Linux?

Recommended study: "PHP Video Tutorial"

The above is the detailed content of What is the command to query mac address in Linux?. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn