Modify MAC address in VMware Linux Virtual Machine

Source: Internet
Author: User
  1. Modify the *. vmx file of the VM.

This method is most recommended, because it is similar to re-"Burning" The vmwarevm's "physical Nic Rom ". The method is:

There are two situations:

A:

Ethernet0.addresstype = "static"

Ethernet0.address = "00: 50: 56: 0a: 0b: 0C"

"Static" indicates that the MAC of VM's "physical nic" is set statically. You can change it to another Mac starting with 005056. Select "keep always" if you ask your SSID when starting the VM ".

B:

Ethernet0.addresstype = "generated"

UUID. Location = "56 4D DC F1 ff aa 75 ea-f1 B9 EE 0d 68 9C 65 5C"

UUID. BIOS = "56 4D Ed 23 13 8C 96 91-7c 68 B2 09 8B aa bb cc"

Ethernet0.generatedaddress = "00: 0C: 29: AA: BB: CC"

"Generated" indicates that the MAC of the VM's "physical nic" is randomly and dynamically set by the system. change the last six digits of the bios and the last six digits of ethernet0.generatedaddress to the Mac starting with 000c29.

2. Modify the MAC value of the/etc/sysconfig/network-scripts/ifcfg-eth0 file in Linux.

VI/etc/sysconfig/network-scripts/ifcfg-eth0

Macaddr = XX: xx

: WQ save and exit

Reboot

3. Modify the MAC value of the RC. Local file in Linux.

Simply write the script.

4,Other methods

  • Method 1:

    # Ifconfig ethx down

    # Ifconfig ethx HW ether new_mac_addr

    # Ifconfig ethx up

    However, after the restart, it becomes invalid and you need to repeat it again. Of course, you can also write RC. Local to solve this problem.

  • Method 2:

    Similar to method 1, ifconfig is replaced by an ip command:

    # IP link set ethx address new_mac_addr

    But it still fails after restart.

  • Method 3:

    For the RedHat system,

    # Vi/etc/sysconfig/network-scripts/ifcfg-ethx

    Comment out the hwaddr row. If yes, add the following modifications:

    Macaddr {new_mac_addr}

    Save and exit.

Differences between hwaddr and macaddr (it is easy to mistake hwaddr for controlling the MAC address, because hwaddr is displayed when ifconfig is output -. -) Can you refer to how to modify the MAC address to keep it effective? And what parameters can be configured in an Ethernet interface configuration file on redhat.com.cn? The two documents are excerpted as follows:

Hwaddr =, where the hardware address of the Ethernet device in the form of AA: BB: CC: DD: EE: ff. this field is very useful on machines with multiple Nic devices.Ensure that the device interface is assigned the correct device nameRegardless of the loading sequence configured for each Nic module. This field cannot be used with macaddr.

Macaddr =, where the hardware address of an Ethernet device in the form of AA: BB: CC: DD: EE: FF. This field is used on a machine with multiple Nic devices.It is used to assign a MAC address to an interface to overwrite the MAC address allocated physically.. This field cannot be used with hwaddr.

In addition, you can also refer to the handling of hwaddr and macaddr in the ifup script:

# REMAP, if the device is bound with a MAC address and not the right device num

# Bail out, if the Mac does not fit

If [-n "$ {hwaddr}"]; then

Foundmacaddr = 'get _ hwaddr $ {realdevice }'

If ["$ {foundmacaddr }"! = "$ {Hwaddr}"]; then

Curdev = 'IP-o link | awk-F': '-vignorecase = 1'/$ hwaddr/{print $2 }''

Rename_device "$ {realdevice}" "$ {hwaddr}" "$ {curdev}" | {

Echo $ "device $ {Device} has different MAC address than expected, ignoring ."

Exit 1

}

Fi

Fi

# This isn't the same as the Mac in the configuration filename. It is

# Available as a configuration option in the config file, forcing the kernel

# To think an Ethernet card has a different MAC address than it really has.

If [-n "$ {macaddr}"]; then

IP link set Dev $ {Device} address $ {macaddr}

Fi

Let's take a look at the man document of nameif:

Nameif looks for the interface with the given MAC address and renames it to the name given.

You can see the differences between hwaddr and macaddr,The former is used to bind the ethx name based on hwaddr, and the latter is used to modify the MAC address.

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.