http://www.blackmoreops.com/2013/11/20/how-to-change-mac-address-in-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 if required), in order for things to work!
All example are for eth0 interface. If you have a different interface you can find them easily with the following command
If you have
NOTE: You may not be able do this if using a DSL modem (depending on modem vendor or ISP).
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
from CentOS Interface Configuration Files
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:
On Debian, Ubuntu, and similar systems, place the following in the appropriate section of
To change MAC address during boot time with MACChanger, add the following line to your
Changing MAC address in Linux
This guide takes you through step by step procedures on How to change MAC address in Linux. I’ve tried to make it generic to cover most Linux distroes. If you have a different option, please comment and I will include it in my guide.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 if required), in order for things to work!
All example are for eth0 interface. If you have a different interface you can find them easily with the following command
ifconfig -aI’ve also used
/etc/init.d/networking
to make it more generic. Experienced users can also try the following commandservice networking stop service networking start
Temporarily change MAC Address
Do the following from command line to change you MAC address temporarily. This way it will revert back to original MAC when you reboot your machine./etc/init.d/networking stop ifconfig eth0 hw ether 02:01:02:03:04:08 /etc/init.d/networking start
Test
Try the following in Terminal to confirm if your MAC address has been changed:ifconfig eth0The 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
/etc/init.d/network
instead of /etc/init.d/networking
.If you have
iproute2
utilities installed, you may prefer to use the “ip
” command, as follows:/etc/init.d/network stop ip link set eth0 address 02:01:02:03:04:08 /etc/init.d/network startTo confirm your setting, you may prefer to execute
ip link ls eth0
or ip addr ls eth0
instead of ifconfig eth0
.NOTE: You may not be able do this if using a DSL modem (depending on modem vendor or ISP).
Permanently change MAC Address
Now let move to make these changes permanent. Following guide is to enable your change survive 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.):LLADDR=12:34:56:78:90:abIn 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.):MACADDR=12:34:56:78:90:abNote: in the file is a value HWADDR – This is not the same thing. Use MACADDR for permanent changes.
from CentOS Interface Configuration Files
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:
service network restart(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:hwaddress ether 02:01:02:03:04:08On 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:mac_eth0="12:34:56:78:90:ab"You can also use the tool GNU MACChanger
apt-get install 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):pre-up macchanger -m 12:34:56:78:90:AB eth0Thanks for reading.
No comments:
Post a Comment