Forum Stats

  • 3,875,555 Users
  • 2,266,945 Discussions
  • 7,912,249 Comments

Discussions

Assign Fixed Address to eth0 in VM linux

User_VHFJK
User_VHFJK Member Posts: 3 Green Ribbon

Hi,

I have a VM installation of Oracle linux which is hosting an FPGA CAE tool. For reasons to do with 3rd party IP licensing I need to create a situation in which the MAC address assigned to eth0 is always the same pre-determined value every time the linux VM is running.

Can anyone help with this please?

Thanks

Best Answer

  • VolneiCP
    VolneiCP Member Posts: 38 Red Ribbon
    Answer ✓

    Hello, I don't know how you configure your VM's, presuming it's in KVM, below is the section of the XML file that configures a network interface.

      <interface type='bridge'>

         <mac address='52:54:00:19:1c:8a'/>

         <source bridge='br0'/>

         <model type='virtio'/>

         <address type='pci' domain='0x0000' bus='0x00' slot='0x03' function='0x0'/> /* automatically assigned */

       </interface>

    Always put 52:54:00 at the beginning of the MAC address, the rest must be generated randomly. The command below will do this for you:

    printf "52:54:00:%02x:%02x:%02x\n" $(($RANDOM & 0x7F)) $(($RANDOM & 0xFF)) $(($RANDOM & 0xFF))

    I hope I helped in some way.

Answers

  • VolneiCP
    VolneiCP Member Posts: 38 Red Ribbon
    Answer ✓

    Hello, I don't know how you configure your VM's, presuming it's in KVM, below is the section of the XML file that configures a network interface.

      <interface type='bridge'>

         <mac address='52:54:00:19:1c:8a'/>

         <source bridge='br0'/>

         <model type='virtio'/>

         <address type='pci' domain='0x0000' bus='0x00' slot='0x03' function='0x0'/> /* automatically assigned */

       </interface>

    Always put 52:54:00 at the beginning of the MAC address, the rest must be generated randomly. The command below will do this for you:

    printf "52:54:00:%02x:%02x:%02x\n" $(($RANDOM & 0x7F)) $(($RANDOM & 0xFF)) $(($RANDOM & 0xFF))

    I hope I helped in some way.

  • User_VHFJK
    User_VHFJK Member Posts: 3 Green Ribbon

    Hi VolneiCP,

    Thanks for taking time to reply, much appreciated.

    Afraid I had nothing to do with configuring the VM it was a completely automatic installation from a file provided by the CAE company, Xilinx.

    My present knowledge of this VM, or any VM to be honest, is limited so I'm going to need to do some digging to get to grips with your suggestions. Thanks for warning about first six chars, interesting that they are nothing like this at the moment, nor are they the MAC address of the physical NIC in the host machine.

    Regards

    Robert

  • VolneiCP
    VolneiCP Member Posts: 38 Red Ribbon

    no problems. The default MAC address prefix of the QEMU is 52:54:00. See this site which shows some other common prefixes.


    The most common configuration is:

    PHYSICAL NIC ----> BRIDGE Assigned to VM

    eth0 (any MAC) ---> br0 (The MAC you created)

  • User_VHFJK
    User_VHFJK Member Posts: 3 Green Ribbon

    Hi VolneiCP,

    Thanks for reply and information.

    I only wish I could just stick to FPGA design but needs must if you don't have an IT person to call in.

    Best Regards

    Robert