It's very easy to change the IP address in Linux. We can use the command
ifconfig to switch to a new IP address temporarily,
or change it permanently by editing the network configuration file. In this post, we talk about how to change the MAC address in Linux.
Temporary change of MAC address
Switch to root or use
ifconfig eth0 down ifconfig eth0 hw ether XX:XX:XX:XX:XX:XX ifconfig eth0 up
where "eth0" is the name of your work device, and XX:XX:XX:XX:XX:XX is a new MAC address (same below). The above commands will take effect immediately. But if we reboot the system, these changes will be lost.
Permanent change of MAC address
In order to change the MAC address permanently, we have to edit the network configuration file.
In Red Hat/CentOS/Fedora, it is
Comment out the line start with HWADDR, and then add a MACADDR line like this:
To make the change take effect immediately, you should restart the network interface:
In debian/ubuntu, the network interface is configured in file
And the syntax is totally different with those in Redhat-like system. But it is also very easy to change the MAC address:
Add this line at the end of this file:
pre-up ifconfig eth0 hw ether XX:XX:XX:XX:XX:XX
Then restart the network subsystem: