How to Change Mac Address in Linux – HackerNet

Banner for How to change Mac Address in Linux

How to Change Mac Address in Linux – HackerNet

What is Mac Address?

MAC Address is a permanent physical address. The device manufacturer assigns it and it was unique. An IP address is used to identify the device on the internet. A MAC address is used to identify the device between the multiple devices within the network and helps to transfer the data between devices.

Each packet that is transferred in Network Contains Source MAC and Destination Mac Address.

Why Change the Mac Address?

MAC address is a unique address that is used to identify the device over the network. When we change the mac address it will help for anonymity over the network.

It also helps to bypass the MAC filter in the network by using another device’s mac address.

How to Change Mac Address in Linux

Here we have listed two methods to change the mac address in Linux

Method 1: Change MAC Address in Linux using ifconfig

steps to change mac address using ifconfig in Linux

1. Open Terminal and type the below command to display all network interfaces in the machine

ifconfig

2. Select the network interface which you want to change the mac address

3. To change the network interface mac address we need to down it.

ifconfig wlan0 down

4. Changing MAC Address (Replace XX:XX:XX:XX:XX:XX with the mac address that you want to set)

ifconfig wlan0 hw ether XX:XX:XX:XX:XX:XX

5. Up the network interface

ifconfig wlan0 up

6. That’s it. your mac address has changed temporarily.

Method 2: Change Mac Address in Linux Using macchanger

macchanger is a Linux utility to view or modify the network interfaces. Using mac changer we can temporarily or permanently change the mac address.

steps to change mac address using mac changer in Linux

1. Open a terminal and run the below commands to install macchanger utility

sudo apt update
sudo apt install macchanger

2. During installation, you can choose to automatically change the MAC address on your system.

How to install macchanger in Redhat, Fedora, Centos, RHEL

You can use the below command to install macchanger in Redhat, Fedora, Centos, RHEL

sudo yum install macchanger

3. for the macchanger usage below command

Standard options available are:

  • -h, –help: Show summary of options.
  • -m, –mac=XX:XX:XX:XX:XX:XX: Set the MAC address to XX:XX:XX:XX:XX:XX
  • V, –version: Show version of the program.
  • e, –ending: Don’t change the vendor bytes.
  • -a, –another: Set random vendor MAC of the same kind.
  • -A: Set random vendor MAC of any kind.
  • r, –random: Set fully random MAC.
  • -p, –permanent : Reset MAC address to its original, permanent hardware value.
  • -l, –list[=keyword] : Print known vendors (with the keyword in  the  vendor’s  description)

4. Use below command to change mac address

sudo macchanger --mac=XX:XX:XX:XX:XX:XX

or

sudo macchanger -m=XX:XX:XX:XX:XX:XX

note: change XX:XX:XX:XX:XX:XX with your desired Mac Address. That’s it.