Change mac address in Ubuntu

Source: Internet
Author: User
1. You must first disable the NIC device for temporary modification. Otherwise, the system will be reported to be busy and cannot be changed. Sudo/sbin/ifconfigeth0down to modify the MAC address. This step is simpler than that in Windows. Sudo/sbin/ifc

1. Temporary Modification

You must first disable the NIC device. Otherwise, the system is reported to be busy and cannot be changed.

Sudo/sbin/ifconfig eth0 down

Modify the MAC address. This step is simpler than that in Windows.

Sudo/sbin/ifconfig eth0 hw ether 00: AA: BB: CC: DD: EE (your MAC address)

Enable Nic again

Sudo/sbin/ifconfig eht0 up

The MAC address of the NIC is changed.

2. Permanent modification (two methods)
Method 1
The above is only a temporary modification of the mac address. If you need to automatically modify the MAC address after each system startup, you can write the above commands into the startup script, the method I use is to write it to/etc/init. d/rc. the end of local.
Sudo nano/etc/init. d/rc. local
Restart rc. local

Sudo/etc/init. d/rc. local start

Method 2
Directly edit the/etc/network/interfaces file and add a line after iface eth0 inet static:
Pre-up ifconfig eth0 hw ether xx: xx (MAC to be changed)
Edit the interfaces File
Sudo nano/etc/network/interfaces
As follows:
Face eth0 inet static
Pre-up ifconfig eth0 hw ether xx: xx (MAC to be changed)
Address 192.168.1.10
Netmask 255.255.255.0
Gateway 192.168.1.1
Restart Nic
Sudo/etc/init. d/networking restart

Note: The MAC address is detected and loaded by udev when the system starts. It can be reflected in the following two files:
/Sys/class/net/eth0/address
/Etc/udev/rules. d/70-persistent-net.rules ---- the modification is invalid. files automatically generated based on hardware
However, after the mac is modified with ifconfig, the value of/sys/class/net/eth0/address changes immediately, but/etc/udev/rules. d/70-persistent-net.rules does not change. This file is modified only when udev detects hardware changes.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.