Change Mac Address- CSU1899 - Shoolini U

Practical 3: Change MAC address in Linux

3. Change MAC address in Linux

In this practical we changed the MAC address on a Kali Linux system. A MAC (Media Access Control) address is a unique identifier assigned to a network interface card (NIC). Changing it can be useful for privacy or testing purposes. Following are the steps:

Step 1: Identify the Network Interface

Open the terminal and list the available network interfaces using:

ifconfig
Output of ifconfig
Figure 3.1.1: Output of ifconfig

Alternatively, use:

ip link show

From the output, identify the interface you want to change the MAC address for. In this example, the active interface is eth0 with the current MAC address: 00:0c:29:cc:99:31.

Step 2: Bring Down the Network Interface

Before changing the MAC address, disable the interface temporarily. Use the following command:

sudo ifconfig eth0 down

Replace eth0 with the name of your network interface (from Step 1).

Step 3: Change the MAC Address

Assign a new MAC address to the interface. Use the command:

sudo ifconfig eth0 hw ether 12:34:56:78:9A:BC

Replace 12:34:56:78:9A:BC with the desired MAC address. Alternatively, you can randomize the MAC address using the macchanger tool:

sudo apt install macchanger    # Install macchanger if not already installed
sudo macchanger -r eth0        # Randomize the MAC address

Step 4: Bring Up the Network Interface

Re-enable the network interface using:

sudo ifconfig eth0 up

Step 5: Verify the New MAC Address

Confirm that the MAC address has been successfully updated by running:

ifconfig eth0

Look for the ether field in the output. It should show the new MAC address.

Output of ifconfig
Figure 3.2.1: Output of ifconfig

Optional: Persistent MAC Address Change

By default, the MAC address change is temporary and will reset after a reboot. To make it permanent, edit the network configuration file:

sudo nano /etc/network/interfaces

Add the following lines for the network interface:


iface eth0 inet dhcp
    hwaddress ether 12:34:56:78:9A:BC

Save and exit the editor (press Ctrl+O, then Enter, and Ctrl+X). Restart the network service:

sudo systemctl restart networking

Notes: