Hacking/Tools/Network/Changing Your MAC Address/Linux

Under GNU/Linux, the MAC address of a network interface card (NIC) can be changed by following the procedures below.

NOTE: MAC addresses used within this article are provided for example only. Substitute according to your requirements.

NOTE: Commands below MUST be executed with root privileges (e.g. prepended with "sudo "), in order for things to work!



Execute " " to confirm.

The above should work on Debian, Ubuntu, and similar distributions. Alternatively, under RHEL/Fedora and possibly other GNU/Linux distributions (incl. CentOS and Scientific Linux), to disable and restart networking, one must stop and start, instead of.

If you have iproute2 utilities installed, you may prefer to use the " " command, as follows:



To confirm your setting, you may prefer to execute " " or " " instead of " ".

NOTE: You may not be able do this if using a DSL modem (depending on modem vendor or ISP).

Making Changes Permanent - Surviving a Reboot
In openSUSE and other SUSE-based systems (SUSE enterprise desktop\server, etc.) you can make changes "permanent" across reboots by adding an appropriate entry to the /etc/sysconfig/network/ifcfg-ethN file (ifcfg-eth0 for the first Ethernet interface config file, ifcfg-eth1 - for the second, etc.):



In Red Hat Enterprise Linux (RHEL) and other similar systems (Fedora, CentOS, etc.) an easy way to make changes "permanent" across reboots is to add an appropriate entry to the /etc/sysconfig/network-scripts/ifcfg-ethN file (ifcfg-eth0 for the first Ethernet interface config file, ifcfg-eth1 - for the second, etc.):



Note: in the file is a value HWADDR - This is not the same thing. Use MACADDR for permanent changes.

from http://www.centos.org/docs/5/html/Deployment_Guide-en-US/s1-networkscripts-interfaces.html

The HWADDR "directive is useful for machines with multiple NICs to ensure that the interfaces are assigned the correct device names regardless of the configured load order for each NIC's module. This directive should not be used in conjunction with MACADDR." ... The MACADDR "directive is used to assign a MAC address to an interface, overriding the one assigned to the physical NIC. This directive should not be used in conjunction with HWADDR."

Upper and lower case letters are accepted when specifying the MAC address, because the network function converts all letters to upper case.

You can test changes without restarting the system by executing:



(WARNING: doing this will break all existing network connections!)

On Debian, Ubuntu, and similar systems, place the following in the appropriate section of /etc/network/interfaces (within an iface stanza, e.g., right after the gateway line) so that the MAC address is set when the network device is started:



On Gentoo you may achieve the same result by adding an entry to the global configuration file /etc/conf.d/net for each Ethernet card. Example for the eth0 device:



You can also use the tool "GNU MACChanger" to change the MAC address under GNU/Linux.

To change MAC address during boot time with MACChanger, add the following line to your /etc/network/interfaces (example for the eth0 interface):