Linux mac address of interface

Solved: Change MAC Address in Linux [Temp & Persistent]

When it comes to networking, you’ve probably heard of the term MAC addressed a lot. MAC Address is a physical identity assigned to each interface. Now you may wonder when the MAC Address is already assigned to an interface then why would we want to change it? Well there can be a number of scenarios, speaking from my personal experience

  1. We had a very old rack server where we failed to installed RHEL 8 and the MAC address of the interfaces from this server kept changing after every reboot. So we decided to update the PCI ID of each interface using udev rule bundled inside initrd to overcome this issue.
  2. For PXE boot we perform network based installation. Now this should not be a problem when we are using DHCP but if you want to use static IP then you must define the MAC Address of the interface and the IP to be assigned. Now imagine you have 100s of servers, so connecting to each one and getting the MAC can be nasty so we can just change the MAC address of these servers as per our need and then just use them to perform PXE boot.

In this tutorial, I will cover what we mean by MAC address, what it’s used for, and how to change it. We will use Kali Linux to demonstrate the steps from this article.

Overview on MAC Address

  • MAC address stands for Media Access Control, and it’s a permanent, physical, and unique address assigned to network interfaces by the device manufacturer.
  • So whether you have a wireless, wired, or Ethernet, each of these network cards comes with a specific address unique to this card. There are no two devices in the world that would have the same MAC address.
  • This address will always be the same to this specific device; even if you unplug it from your computer and connect it to another computer, this network device will always have the same address.
  • Not only that but the MAC address is often used by filters to prevent or allow devices to connect to networks and do specific tasks on the web.
  • Changing your MAC address to another device’s MAC address will allow you to impersonate this device and will enable you to do things that you might not be able to do.
  • So you’d be able to bypass filters or connect to networks that only specific devices with specific MAC addresses can relate to, and you will also be able to hide your identity. Now changing the MAC address is very simple, so let me show you how to do that.
Читайте также:  Просмотр сертификатов linux openssl

Method-1: Change MAC Address of Network Adapter (Non-Persistent)

Step 1: List Network Interfaces

First, I will use the ifconfig command to list all the network interfaces available on my Kali machine. What I mean by network interface is any device that allows us to connect to a network.

An example is a Wi-Fi card or an Ethernet card, and so on. So you can see first of all we have eth0 , which is a virtual interface created by virtual box when we set Kali to use NAT network.

Solved: Change MAC Address in Linux [Temp & Persistent]

You can see the interface name is eth0, and you can see it has an IP address because, as I said, it’s connected to a network.

If we go here, we can see it saying Wired Connected. The interface represents the wired network that Kali is connected to, which is a virtual NAT network.

You can also see the netmask, the broadcast, and an essential piece of information: the ether, which is the MAC address of this virtual interface.

Now, you can see similar information for my other two interfaces, the lo and the wlan0. The only thing is you can see for both of these interfaces. We do not have an IP address. And the main reason for that is that none of these interfaces is connected to a network.

Now lo is the default interface created by Linux, and wlan0 is my genuine wireless adapter. I can use it to connect to Wi-Fi networks. But if I go on the web in here, you’ll see Wi-Fi is not connected because I didn’t connect to any network, and that’s why it does not have an IP address.

Now, this doesn’t matter because we want to change the MAC address, which is again shown under the ether part, similar to what you see here for eth0 .

Step 2: Disable Interfaces

Now, to change any of the values you see here, you first have to disable the interface. In this example, we want to change the MAC address to represent it by the ether, and the value is right here.

Читайте также:  Nfs server setup in linux

To disable an interface, we’re going to do ifconfig followed by the interface name, wlan0 in my example, followed by down to disable it.

Solved: Change MAC Address in Linux [Temp & Persistent]

Now, if I hit Enter, you’ll see the command runs with no errors, so it means that it got correctly executed. And the next thing that we need to do is change the option that we want to change. And in this example, we want to change the ether, which is the MAC address.

Step 3: Change MAC Address

First, we’re going to type ifconfig , type the interface that we want to change, one of its options, then type the option we want to change. And what we want to change is the hardware address, so we’re going to do hw ether. Then we’re going to give it the lesson that we want to change the MAC address.

For this example, I’m going to use 00:89:76:88:82:33 . Very, very simple command, we’re doing ifconfig wlan0 to select the interface that we want to change its option, we want to set the hardware address, and we want to put this address to this specific address.

So you can use any address that you want, following the same format shown here. Just make sure your address starts with 00 . So I’m going to hit Enter, and again, we don’t see any error messages, so it means the command got appropriately executed.

Solved: Change MAC Address in Linux [Temp & Persistent]

And finally, we need to enable the interface because we disabled it by doing ifconfig wlan0 down , so we need to do ifconfig wlan0 up to allow it. Now the interface is enabled, and if we do ifconfig again, and look at the ether part here, you can see that it is changed to the MAC address that we specified.

Step 4: Verify the new MAC Address

Now, this is done, and your MAC address has changed. Now, you can go ahead and start using the interface, and it’ll appear to have this MAC address instead of its original MAC address. And like I said, this can be useful in so many scenarios.

Solved: Change MAC Address in Linux [Temp & Persistent]

Now, keep in mind, the MAC address will revert to the original one once you restart the computer because we’re only changing the MAC address in memory. We’re not changing the physical MAC address.

Method-2: Change MAC Address of Network Adapter (Persistent)

In this section we will change MAC Address of a network adapter permanently which will be persistent across reboots.

Источник

How to Find Network MAC Address in Linux System

The term MAC Address is a derived abbreviation for Media Access Control Address. The network interface controller (NIC) uses the MAC address as its assigned unique identifier within an existing network segment.

Читайте также:  Raspberry pi pico установка linux

To practically relate to or understand what a MAC address is, think of it as the postal or physical address to a house. The house in this case is the network interface controller (NIC).

There is a key difference between MAC address and IP address and therefore we should not confuse the two. MAC address identifies the device you are using since it is imprinted on the device hardware whereas IP address identifies the connection status among devices seeking to communicate on an existing/configured network.

The MAC address of any device is represented by a 12-digit hexadecimal number. Its display includes a colon or hyphen after every two MAC address digits for easy readability.

For instance, a MAC address can be represented in the following manner.

aa:bb:cc:dd:ee:ff or gg-hh-ii-jj-kk-ll

Approaches to Finding MAC Address in Linux

Depending on the number of network interfaces on your Linux machine like Wi-Fi built-in and Ethernet port, your computer can be associated with more than one MAC Address.

1. Find Linux System Mac Address Using IP Command

The ip command is part of the iproute2 package and can be used to display both the MAC address and IP address of your Linux-powered machine using either of the following commands.

$ ip addr or $ ip address or $ ip address show

Find Linux System MAC Address

Depending on the network adapter or interface present, we can see the availed MAC addresses. In the above screen capture, three distinct MAC addresses can be identified from the ip address command.

Another useful command is the ip link which only focuses on the MAC address and does not display the IP addresses.

Show Linux System MAC Address

2. Find Linux System Mac Address Using Ifconfig Command

The ifconfig command is another effective approach to identifying the MAC address of your Linux machine. We however need to install it first since it is a member of the net-tools package and not installed on Linux by default.

$ sudo apt install net-tools [On Debian, Ubuntu and Mint] $ sudo yum install net-tools [On RHEL/CentOS/Fedora and Rocky Linux/AlmaLinux] $ sudo emerge -a sys-apps/net-tools [On Gentoo Linux] $ sudo pacman -S net-tools [On Arch Linux] $ sudo zypper install net-tools [On OpenSUSE]

Once installed, run the ifconfig command to find the IP address and MAC address of your Linux system.

Check Linux System MAC Address

Different network interfaces or adapters showcase different MAC addresses as highlighted in the above screen capture.

We have successfully defined and understood how to get the MAC address(es) on our Linux machines.

Источник

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