How-To Change Your MAC Address

Alexey Eremenko "Technologov"

$Revision: 04 $

$Date: 2007-01-24 $

Scenario

You want to test a layer 2 firewall via MAC address spoofing, or you may just want to learn a bit of networking.

This How-To uses standard GNU/Linux commands, therefore it is not specific to openSUSE.

Procedure

The commands are very simple: (you must be logged in as root)

# ifconfig eth0 down
# ifconfig eth0 hw ether AA:BB:CC:DD:EE:FF
# ifconfig eth0 up

Now check that it is actually been set:

# ifconfig eth0

Understanding

OK, here we go; First understand: Your MAC address, despite is physically burned into a NIC (LAN card), *can* be changed. It is due to the fact, that it is not the LAN card, that builds frames (as I thought originally), but it's the driver. This means, that the driver can build non-standard frames, such as with a non-standard MAC address, or even completely non-standard sized frames, such as IEEE 802.1q frames for VLANs, or even Jumbo frames (with 9000 bytes, instead of 1500 bytes of payload).

Because it is driver dependent, your NIC driver must support that feature in order to succeed. Just don't blindly believe hardware manufacturers, saying that model X or model Y doesn't support this or that feature. With some extra work on the drivers part, everything is possible. And since we are an Open-Source community, we have the power to change it.

Procedure to get the original MAC address from ROM

Since we changed the MAC address in the driver, the only way to change this back is to reload the driver. Make sure you are logged in as root.

  1. Find out, which driver is used with:

    localhost:/ # ethtool -i eth0
    driver: via-rhine
    version: 1.4.1
    firmware-version:
    bus-info: 0000:00:12.0

    OK, now we just found, that our driver is named: “via-rhine”.

  2. Unload the networking driver with:

    localhost:/ # rmmod via-rhine

    WARNING: It will stop all the network cards that use this driver, so, if you're running a multi-NIC machine, proceed with caution.

  3. Load the networking driver back with:

    localhost:/ # modprobe via-rhine

  4. Start the network card with:

    localhost:/ # killall dhcpcd
    localhost:/ # dhcpcd eth0

    It will kill all the problematic (stucked) processes of the Dynamic Host Configuration Protocol Client Daemon, and restart it again on eth0 NIC.

  5. Now check that it is actually been reverted to original value:

    # ifconfig eth0

Troubleshooting

May happen, that after reboot, your NIC will fail to start. In this case do:

Yast->Network Devices->Network Card->Traditional Method->select a NIC->delete, then: ->edit->next->Finish.