How to know mac address linux

3 Ways to Find MAC Address In Linux

How to list MAC address on Linux is a commonly asked question during a Linux job interview. Here are some methods to get the MAC address. These commands are safe to run without changing anything.

The following commands can get you the MAC address of your network interface in Linux.

If you’re new to the world of Linux, you can refer to “Mastering the Linux Command: A Beginner’s Guide.” This in-depth article will be your guiding light, providing you with the foundational knowledge and skills required to navigate and wield the Linux command line interface (CLI) effectively and with assurance.

Procedures to find MAC address in Linux

  • Open the terminal application.
  • Type ifconfig -a or ip link show or cat /sys/class/net/*/address command
  • Press Enter to run the command.
  • The output will display the MAC address for all the network interfaces.

This article is part of the following series.

What is MAC address?

From Wikipedia, A MAC address is the unique identifier that is assigned by the manufacturer to a piece of network hardware (like a wireless card or an ethernet card). MAC stands for Media Access Control, and each identifier is intended to be unique to a particular device.

The MAC address consists of six sets of two characters, each separated by a colon. 00:1B:44:11:3A:B7 is an example of a MAC address. The MAC address is usually printed on the card itself. The MAC address can also be found in the BIOS of the computer or device.

A MAC address can be used to uniquely identify a device on a network. This allows for better security and more efficient networking. MAC addresses are usually assigned by the manufacturer of the network adapter. However, it is possible to change the MAC address of a device.

Find MAC address with ifconfig command in Linux

The best Linux command to find MAC address is using ifconfig command. All we need is to open the terminal then type ifconfig -a in the prompt. The number next to ether is the MAC address. This command will list MAC address, IP address, MTU size and other information about a network interface.

ens1f0: flags=4163 mtu 1500
inet 10.124.202.230 netmask 255.255.255.128 broadcast 10.124.202.255
ether 70:ca:9b:ce:67:ae txqueuelen 1000 (Ethernet)
RX packets 12187970 bytes 7390885300 (6.8 GiB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 16813496 bytes 16253942714 (15.1 GiB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
device memory 0xb1960000-b197ffff

By default, the ifconfig command will display information for all the network interfaces on the Linux system.

If you receive a message “ifconfig command not found” when you try to use it, you can run the following command to install it.

Читайте также:  Мобильная операционная система линукс

On Debian based distros:
# apt update
# apt install net-tools

On Red Hat based distros:
# dnf install net-tools

Check this post to get more info about how to fix ifconfig command not found

Find MAC address for a specific interface with ifconfig command in Linux

You can append the name of the interface to the end of the command (e.g. “ifconfig eth0”) to view the MAC address about a specific interface.

So if you want to display information only for specific device like eth0, you can use this command ifconfig eth0.

$ ifconfig eth0
eth0: flags=4163 mtu 1500
inet 10.254.222.37 netmask 255.255.254.0 broadcast 10.254.223.255
ether fa:16:3e:18:3a:76 txqueuelen 1000 (Ethernet)
RX packets 94405374 bytes 5781082518 (5.3 GiB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 23249315 bytes 1034177108 (986.2 MiB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0

The ifconfig command can be used to configure a network interface. The basic syntax for the ifconfig command is: ifconfig interface ip address netmask BROADCAST_ADDRESS

This will set the IP address, netmask and gateway for the specified network interface.You can also use the ifconfig command to enable or disable a network interface. The basic syntax for this is: ifconfig interface up or down

The “ifconfig” command is a command-line utility that is used to display information about your network interfaces. This command is available on most Unix-like operating systems, including Linux and macOS. We can also use ifconfig command to troubleshoot network issues.

Another way to find MAC address in Linux is using “ip link show” command. The number next to link/ether is the MAC address. This command will list the interface status, MAC address, MTU size, etc.

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: ens1f0: mtu 1500 qdisc mq state UP mode DEFAULT group default qlen 1000
link/ether 70:ca:9b:ce:67:ae brd ff:ff:ff:ff:ff:ff

To view information about a specific network link, you can use the “ip link show” command followed by the name of the network interface. For example, if you want to view information about the eth0 interface, you can run the following command: “ip link show eth0”.

The following command lists the interface names on the left and the associated MAC addresses on the right.

ip -o link show |cut -d ‘ ‘ -f 2,20
lo: 00:00:00:00:00:00
eth0: 02:01:e4:a2:3a:31

Find MAC address from /sys in Linux

If you want to get MAC information about the network interface, you can use this command cat /sys/class/net/*/address .

sysfs is a virtual filesystem in Linux that provides a way to access and manipulate the parameters of devices. sysfs is mounted on /sys when your system boots.

The sysfs filesystem contains a directory for each device on your system. The name of the directory is the name of the device. The contents of the directory depend on the type of device.If you want to get information about the network interfaces on your system, you can cd to /sys/class/net/.

# cat /sys/class/net/ens1f0/address
70:ca:9b:ce:67:ae

$ cat /sys/class/net/*/address
02:01:e4:a2:3a:31
00:00:00:00:00:00

Difference between MAC address and IP address

MAC addresses are physical addresses, while ip addresses are logical addresses. MAC addresses are used to identify devices on a network, while ip addresses are used to identify the location of devices on a network.

The two most common types of ip addresses are IPv4 and IPv6. IPv4 is a 32-bit address that can support up to 4.3 billion unique addresses. IPv6 is a 128-bit address that can support up to 3.4×1038 unique addresses.

Читайте также:  Canon 4410 драйвер astra linux

MAC addresses are assigned by the manufacturer of the device. Ip addresses can be assigned by the user or by the network administrator.

Источник

How to Look Up a MAC Address in Linux?

A MAC address, also known as hardware or a physical address, stands for Media Access Control address. It is usually formatted as six pairs of hexadecimal digits, separated by colons (e.g., 00:11:22:33:44:55) which is a 48-bit number. The MAC address contains information about the device, such as its manufacturer and type.

This post will provide a list of methods to look for a MAC address in Linux.

Method 1: How to Look Up a MAC Address in Linux Through Command Line?

A few commands are used to find the MAC addresses of the devices through the command line, which includes the following.

Using the ip link command, users can find the MAC addresses of each device by following the syntax mentioned below:

In the above image, the string in the box is the MAC address of “ens33,” which can differ depending on your connection. It can either be a “wlan0, eth0, or enpls0,” and the zeroes can be either “1, 2, or 3”.

If you’re having difficulty knowing the MAC address, use the Ip link command with grep as in this format.

$ ip link show ens33 | grep -o -E '([[:xdigit:]]:)[[:xdigit:]]'

The above command works as follows:

  • The command “Ip link show ens33” displays information about the network interface “ens33”.
  • The output of this command is then passed to the “grep” command, which searches for lines that match a specified pattern.
  • The “-o” option is used to print the matching portion of the line, rather than the complete line.
  • The “-E” option tells grep to use extended regular expressions for the pattern.
  • The pattern “([[:xdigit:]]:)[[:xdigit:]]” is used to search for the MAC address of the network interface.

The ifconfig Command

The ifconfig command is primarily used to find the IP addresses. Still, you can also use it to find your MAC address as well as shown below:

Using ifconfig With grep

If you only want to see the MAC address of a specific connection (ens33 in our case), use this command just like you did in the previous section:

$ ifconfig ens33 | grep -o -E '([[:xdigit:]]:)[[:xdigit:]]'

If we look at the above command, the grep parameters are the same as we used in the ip link command. Finally, the output has shown the MAC address only on the terminal.

Method 2: How to Look Up MAC Addresses in Linux through the GUI?

To look up the MAC address of your network device, you need to go to settings and click on the “Network” tab. After that, click on the wheel-like button under the “Connection (Wired in our case),” highlighted below.

A new menu will pop up that basically is the advanced settings of the network, and here you will see different settings and information, including the MAC address highlighted in the below image.

The hardware address represents the MAC address of the currently selected network device.

Conclusion

MAC addresses of the devices, such as networks or Bluetooth, can be checked using the command line and the graphical interface. For the command line, use the ‘ifconfig’ and the ‘iplink’ commands in the terminal. While the networks settings option in the GUI of Linux will give you the initial details about the MAC addresses. All these methods are practically demonstrated in this post.

Читайте также:  Telnet udp порт linux

Источник

How to Find Your MAC address in Ubuntu and Other Linux Distros

When you are learning networking or troubleshooting it, you would need to know the MAC address.

A computer can have more than one MAC address. It is because the MAC address is a core part of networking, and each networking peripheral device has its own MAC address.

So, your WiFi card has a MAC address, and so does the Ethernet (LAN) port. Even the Bluetooth has one.

The MAC address, also known as the physical address, is a 12-digit hexadecimal code (48-bits) and is represented as MM:MM:MM:SS:SS:SS

In this tutorial, I’ll share the steps for finding the MAC address of your desired networking interface in Linux. I’ll show both command line and GUI methods.

Method 1: Find MAC address using command line

There are serveral Linux networking commands that can be used to get the MAC address of the WiFi or LAN cards.

Open up your terminal and use the following command, and it will bring the address of the present network cards in your system:

And you’ll be met with the following output:

use ip link command to show mac address

Generally, the wireless device names will be wlan0, wlan1, wlan2, wlo0, wlo1, and wlo2, whereas the Ethernet (wired device) will probably have eth0, eth1, eno0, eno1,enpls0, or enpls1.

You can find the MAC address of each device at the last line of the device description, followed by link/ether and it’s 52:54:00:5c:92:bf in my case.

Get the MAC address of Bluetooth

As I mentioned earlier, all networking devices have a physical address. If you want to see the MAC address of your Bluetooth adapter, you can use this command:

You can see it beside the BD Address field.

[email protected]:~$ hciconfig hci0: Type: Primary Bus: USB BD Address: DC:41:A9:FB:7A:C4 ACL MTU: 1021:4 SCO MTU: 96:6 UP RUNNING RX bytes:17895787 acl:275 sco:250783 events:298882 errors:0 TX bytes:303664302 acl:295384 sco:249895 commands:3380 errors:0

You can also use the bluetoothctl command here.

Method 2: Get MAC address using GUI

If you’re afraid of using the terminal you can use the network settings to get the MAC address details.

I am using Ubuntu with the GNOME desktop environment. If you use some other desktop environments, the screenshots may not look the same.

First, search for settings in the system menu and open the first result.

search for settings in system menu

Now, for the left menu bar, select Network and click on the little gear icon located near to wired network toggle. Even if you’re not connected to a wired network, you can still follow the same approach.

select networks and click on gear icon

If you’re on Wi-Fi, there will be an option for Wi-Fi in the left menu bar. From there, you have to follow the same approach (clicking on the gear icon) to get your MAC address.

Once you click on the gear icon, you’ll be met with details of the selected network interface. Here, the MAC address is given as the Hardware address.

find mac address using gui

Here you have it in the easiest way possible!

Final Words

Did you know that the first half of hexadecimal code (24 bits) is used to represent the manufacturer of your network adapter?

Finding a MAC address in Linux is quite easy as you have seen it here. On the same note, you may like to learn about changing the MAC address in Linux.

Let me know if you have any questions or suggestions.

Источник

Оцените статью
Adblock
detector