This guide takes you lot through pace yesteryear pace procedures on how to modify MAC address inwards Linux. I’ve tried to buy the farm inwards generic to comprehend nearly Linux distros. If you lot possess got a dissimilar option, delight comment together with I volition include it inwards my guide.
Under GNU/Linux, the MAC address of a network interface carte (NIC) tin live changed yesteryear next the procedures below.
NOTE: MAC addresses used inside this article are provided for illustration only. Substitute according to your requirements.
NOTE: Commands below MUST live executed amongst root privileges (e.g. prepended amongst sudo if required), inwards club for things to work!
Temporarily modify MAC Address
All illustration are for eth0 interface. If you lot possess got a dissimilar interface you lot tin uncovering them easily amongst the next command
ifconfig -a
I’ve also used /etc/init.d/networking to buy the farm inwards to a greater extent than generic. Experienced users tin also endeavour the next command
service networking stop
service networking start
Do the next from dominance trace of piece of job to modify you lot MAC address temporarily. This means it volition revert dorsum to master copy MAC when you lot 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 next inwards Terminal to confirm if your MAC address has been changed:
ifconfig eth0
The higher upwards should operate on Debian, Ubuntu, together with like distributions. Alternatively, nether RHEL/Fedora together with maybe other GNU/Linux distributions (incl. CentOS together with Scientific Linux), to disable together with restart networking, 1 must halt together with start /etc/init.d/network instead of /etc/init.d/networking.
If you lot possess got iproute2 utilities installed, you lot may prefer to utilization the “ip” command, every bit follows:
/etc/init.d/network stop
ip link fix eth0 address 02:01:02:03:04:08
/etc/init.d/network start
To confirm your setting, you lot may prefer to execute ip link ls eth0 or ip addr ls eth0 instead of ifconfig eth0.
NOTE: You may non live able create this if using a DSL modem (depending on modem vendor or ISP).
Permanently modify MAC Address
Now allow deed to brand these changes permanent. Following guide is to enable your modify live on a Reboot.
In openSUSE together with other SUSE-based systems (SUSE enterprise desktop\server, etc.) you lot tin brand changes permanent” across reboots yesteryear adding an appropriate entry to the /etc/sysconfig/network/ifcfg-ethN file (ifcfg-eth0 for the root Ethernet interface config file, ifcfg-eth1 – for the second, etc.):
LLADDR=12:34:56:78:90:ab
In Red Hat Enterprise Linux (RHEL) together with other like systems (Fedora, CentOS, etc.) an slowly means to brand changes permanent across reboots is to add together an appropriate entry to the /etc/sysconfig/network-scripts/ifcfg-ethN file (ifcfg-eth0 for the root Ethernet interface config file, ifcfg-eth1 – for the second, etc.):
MACADDR=12:34:56:78:90:ab
Note: inwards the file is a value HWADDR – This is non the same thing. Use MACADDR for permanent changes.
from CentOS Interface Configuration Files
The HWADDR “directive is useful for machines amongst multiple NICs to ensure that the interfaces are assigned the right device names regardless of the configured charge club for each NIC’s module. This directive should non live used inwards conjunction amongst MACADDR.”
…
The MACADDR “directive is used to assign a MAC address to an interface, overriding the 1 assigned to the physical NIC. This directive should non live used inwards conjunction amongst HWADDR.”
Upper together with lower illustration letters are accepted when specifying the MAC address, because the network utilization converts all letters to upper case.
You tin attempt out changes without restarting the organisation yesteryear executing:
service network restart
(WARNING: doing this volition intermission all existing network connections!)
On Debian, Ubuntu, together with like systems, house the next inwards the appropriate department of /etc/network/interfaces (within an iface stanza, e.g., right afterward the gateway line) together with then that the MAC address is fix when the network device is started:
hwaddress ether 02:01:02:03:04:08
On Gentoo you lot may accomplish the same number yesteryear 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 tin also utilization the tool GNU MACChanger apt-get install macchanger to modify the MAC address nether GNU/Linux.
To modify MAC address during kick fourth dimension amongst MACChanger, add together the next trace of piece of job to your /etc/network/interfaces (example for the eth0 interface):
pre-up macchanger -m 12:34:56:78:90:AB eth0
Thanks for reading. Please portion together with RT.