How to change MAC address on CentOS Linux








  1. Edit /etc/sysconfig/network-scripts/ifcfg-eth0,
    sudo vi /etc/sysconfig/network-scripts/ifcfg-eth0
    and add the MAC address in the following format:
    MACADDR=00:11:22:33:44:55
    
  2. Restart the network:
    sudo service network restart

NOTE:

The above assumes you want to change ethernet interface eth0. You need to change the interface name if it is not eth0. (e.g. eth1)

If /etc/sysconfig/network-scripts/ifcfg-eth0 does not exist, you may need to create one. Here is an example:
DEVICE=eth0
BOOTPROTO=static
ONBOOT=yes
IPADDR=192.168.0.199
NETMASK=255.255.255.0
GATEWAY=192.168.0.1
MACADDR=00:11:22:33:44:55
DNS1=123.111.222.1
or if use dhcp:
DEVICE=eth0
BOOTPROTO=dhcp
ONBOOT=yes
MACADDR=00:11:22:33:44:55



3 comments:

  1. I have changed MAC Address using this trick but my system is unable to update the new MAC Address hence unable to access internet.What should i do?

    Thanks
    Silvester Norman

    Change MAC Address

    ReplyDelete
    Replies
    1. You need to make sure your ip address, net mask, gateway settings, and dns server are correctly set (if you set to use static ip)

      The example in the post is using static ip, to use dhcp instead:

      DEVICE=eth0
      BOOTPROTO=dhcp
      MACADDR=00:11:22:33:44:55

      Delete
    2. Perfect reply you have provided all the latest information that is required to solve my query.Thanks for sharing such great information.

      Regards
      Silvester Norman

      Change MAC Address

      Delete