Sunday, December 20, 2009

How to Change MAC Address on Linux [system-config-network Way]

If you want to change MAC address using NetworkManager follow this post.

To succeed in system-config-network way we need to make sure NetworkManage tool does not exist! Because it won't let us change the MAC of eth0 device with ifconfig command!
# service NetworkManager stop
# yum -y remove NetworkManager

To change the MAC address of a Linux Machine you have to change the MAC address on system-config-network tool, then apply the ifconfig command and then start the interface.


# ifconfig eth0 down
# ifconfig eth0 hw ether 00:11:22:33:44:55
# ifconfig eth0 up

To change the MAC address in system-config-network you need to do the following.

1. Apply command system-config-network either on gnome-terminal or pressing alt+F2.

2. It will ask for root password. Provide the password.

3. Deactivate the current eth0 profile by clicking deactivate if it is shown active.

4. Now double click the eth0 device profile.

5. Click Hardware Device Tab.


[Click image to enlarge]

6. Tick "Bind to MAC address" option. And provide the new MAC address(as used ifconfig command) on the textbox following the format aa:bb:cc:dd:ee:ff (colon after every 2 literals). Then click ok.

Now let's change the eth0 hardware address using ifconfig command.

# ifconfig eth0 down
# ifconfig eth0 hw ether 00:11:22:33:44:55
# ifconfig eth0 up

Where 00:11:22:33:44:55 should be replaced by your PC's physical address.

Now activate eth0 from system-config-network.



To check if the change is in effect apply this command.

# ifconfig | grep HWaddr

If you still cannot access network restart the network service.

# service network restart
ping to check back your internet connection.

$ $ ping www.google.com
PING www.l.google.com (74.125.43.105) 56(84) bytes of data.
64 bytes from bw-in-f105.1e100.net (74.125.43.105): icmp_seq=1 ttl=53 time=220 ms
64 bytes from bw-in-f105.1e100.net (74.125.43.105): icmp_seq=2 ttl=53 time=220 ms
64 bytes from bw-in-f105.1e100.net (74.125.43.105): icmp_seq=3 ttl=53 time=219 ms
64 bytes from bw-in-f105.1e100.net (74.125.43.105): icmp_seq=4 ttl=53 time=220 ms
64 bytes from bw-in-f105.1e100.net (74.125.43.105): icmp_seq=5 ttl=53 time=220 ms
^C
--- www.l.google.com ping statistics ---
5 packets transmitted, 5 received, 0% packet loss, time 4298ms
rtt min/avg/max/mdev = 219.408/220.194/220.799/0.709 ms
$
Press Ctrl + C to exit ping. All these commands require root privilege. Either do an su or login as root.

This command works on all Linux Distros(Fedora Core, Ubuntu, Suse, Mandriva etc). But system-config-network & NetworkManager commands may be different on distros other than Fedora Core OSs.

No comments:

Post a Comment