You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cloudstack.apache.org by Imran Ahmed <im...@eaxiom.net> on 2017/05/11 16:27:05 UTC

Auto Generating MAC Addresses for VMs in a given pattern

Dear Team,
We are in a situation where the datacenter provider has put a restriction on
the MAC addresses.
We Cloudstack 4.3 with XenServers 6.5 .  We need to modify the pattern in
which the guest VMs get the MAC address and use the pattern provided by the
datacenter provider.
Please suggest what should be a good starting point ?

Best regards,

Imran 


RE: Auto Generating MAC Addresses for VMs in a given pattern

Posted by Imran Ahmed <im...@eaxiom.net>.
Hi Sergey,

Bundle of thanks for your valuable input on this. I will do some research and see what can be the best alternative for this.

Kind regards
Imran

-----Original Message-----
From: Sergey Levitskiy [mailto:Sergey.Levitskiy@autodesk.com] 
Sent: Thursday, May 11, 2017 10:57 PM
To: users@cloudstack.apache.org
Subject: Re: Auto Generating MAC Addresses for VMs in a given pattern

Randomization is done for each VM. The only static part is prefix - 06. Unless you change the ACS code it won’t support a predefined range for Mac addresses. If you sort you nics table by IP address you will see that octet on the rigtht gets incremented due to respective sequence increment. But at the same time second and third octet on the left change due to randomization.

On 5/11/17, 10:44 AM, "Imran Ahmed" <im...@eaxiom.net> wrote:

    Hi Sergey,
    
    I am grateful for your prompt reply. The data center provider has provided a starting sequence to be used. Do you think it would be another option to modify the sequence in db tables (data_center and user_ip_address) so that the VMs get an IP/MAC from that sequence? Is  the randomization function called during creation of each VM  or its run just once during the creation of zone (data_center)?
    
    Kind regards,
    
    Imran 
    
    -----Original Message-----
    From: Sergey Levitskiy [mailto:Sergey.Levitskiy@autodesk.com] 
    Sent: Thursday, May 11, 2017 10:16 PM
    To: users@cloudstack.apache.org
    Subject: Re: Auto Generating MAC Addresses for VMs in a given pattern
    
    Mac address is dynamically created based on the IP address sequence number being allocated on your subnet with randomization algorithm.
    It is done in NetUtils.java 
    
        public static long createSequenceBasedMacAddress(final long macAddress) {
            return macAddress | 0x060000000000l | (long)s_rand.nextInt(32768) << 25 & 0x00fffe000000l;
        }
    
    Starting sequence of your address is defined in data_center table and carried over to user_ip_address tablewhere it gets properly incremented.
    
    Routers use slightly different pattern for mac addresses.
    
    I would advise to figure out another way of addressing your issue vs modifying ACS code that deals with MACs.
    
    Thanks,
    Sergey
    
    
    
    
    On 5/11/17, 9:27 AM, "Imran Ahmed" <im...@eaxiom.net> wrote:
    
        Dear Team,
        We are in a situation where the datacenter provider has put a restriction on
        the MAC addresses.
        We Cloudstack 4.3 with XenServers 6.5 .  We need to modify the pattern in
        which the guest VMs get the MAC address and use the pattern provided by the
        datacenter provider.
        Please suggest what should be a good starting point ?
        
        Best regards,
        
        Imran 
        
        
    
    
    



Re: Auto Generating MAC Addresses for VMs in a given pattern

Posted by Sergey Levitskiy <Se...@autodesk.com>.
Randomization is done for each VM. The only static part is prefix - 06. Unless you change the ACS code it won’t support a predefined range for Mac addresses. If you sort you nics table by IP address you will see that octet on the rigtht gets incremented due to respective sequence increment. But at the same time second and third octet on the left change due to randomization.

On 5/11/17, 10:44 AM, "Imran Ahmed" <im...@eaxiom.net> wrote:

    Hi Sergey,
    
    I am grateful for your prompt reply. The data center provider has provided a starting sequence to be used. Do you think it would be another option to modify the sequence in db tables (data_center and user_ip_address) so that the VMs get an IP/MAC from that sequence? Is  the randomization function called during creation of each VM  or its run just once during the creation of zone (data_center)?
    
    Kind regards,
    
    Imran 
    
    -----Original Message-----
    From: Sergey Levitskiy [mailto:Sergey.Levitskiy@autodesk.com] 
    Sent: Thursday, May 11, 2017 10:16 PM
    To: users@cloudstack.apache.org
    Subject: Re: Auto Generating MAC Addresses for VMs in a given pattern
    
    Mac address is dynamically created based on the IP address sequence number being allocated on your subnet with randomization algorithm.
    It is done in NetUtils.java 
    
        public static long createSequenceBasedMacAddress(final long macAddress) {
            return macAddress | 0x060000000000l | (long)s_rand.nextInt(32768) << 25 & 0x00fffe000000l;
        }
    
    Starting sequence of your address is defined in data_center table and carried over to user_ip_address tablewhere it gets properly incremented.
    
    Routers use slightly different pattern for mac addresses.
    
    I would advise to figure out another way of addressing your issue vs modifying ACS code that deals with MACs.
    
    Thanks,
    Sergey
    
    
    
    
    On 5/11/17, 9:27 AM, "Imran Ahmed" <im...@eaxiom.net> wrote:
    
        Dear Team,
        We are in a situation where the datacenter provider has put a restriction on
        the MAC addresses.
        We Cloudstack 4.3 with XenServers 6.5 .  We need to modify the pattern in
        which the guest VMs get the MAC address and use the pattern provided by the
        datacenter provider.
        Please suggest what should be a good starting point ?
        
        Best regards,
        
        Imran 
        
        
    
    
    


RE: Auto Generating MAC Addresses for VMs in a given pattern

Posted by Imran Ahmed <im...@eaxiom.net>.
Hi Sergey,

I am grateful for your prompt reply. The data center provider has provided a starting sequence to be used. Do you think it would be another option to modify the sequence in db tables (data_center and user_ip_address) so that the VMs get an IP/MAC from that sequence? Is  the randomization function called during creation of each VM  or its run just once during the creation of zone (data_center)?

Kind regards,

Imran 

-----Original Message-----
From: Sergey Levitskiy [mailto:Sergey.Levitskiy@autodesk.com] 
Sent: Thursday, May 11, 2017 10:16 PM
To: users@cloudstack.apache.org
Subject: Re: Auto Generating MAC Addresses for VMs in a given pattern

Mac address is dynamically created based on the IP address sequence number being allocated on your subnet with randomization algorithm.
It is done in NetUtils.java 

    public static long createSequenceBasedMacAddress(final long macAddress) {
        return macAddress | 0x060000000000l | (long)s_rand.nextInt(32768) << 25 & 0x00fffe000000l;
    }

Starting sequence of your address is defined in data_center table and carried over to user_ip_address tablewhere it gets properly incremented.

Routers use slightly different pattern for mac addresses.

I would advise to figure out another way of addressing your issue vs modifying ACS code that deals with MACs.

Thanks,
Sergey




On 5/11/17, 9:27 AM, "Imran Ahmed" <im...@eaxiom.net> wrote:

    Dear Team,
    We are in a situation where the datacenter provider has put a restriction on
    the MAC addresses.
    We Cloudstack 4.3 with XenServers 6.5 .  We need to modify the pattern in
    which the guest VMs get the MAC address and use the pattern provided by the
    datacenter provider.
    Please suggest what should be a good starting point ?
    
    Best regards,
    
    Imran 
    
    



Re: Auto Generating MAC Addresses for VMs in a given pattern

Posted by Sergey Levitskiy <Se...@autodesk.com>.
Mac address is dynamically created based on the IP address sequence number being allocated on your subnet with randomization algorithm.
It is done in NetUtils.java 

    public static long createSequenceBasedMacAddress(final long macAddress) {
        return macAddress | 0x060000000000l | (long)s_rand.nextInt(32768) << 25 & 0x00fffe000000l;
    }

Starting sequence of your address is defined in data_center table and carried over to user_ip_address tablewhere it gets properly incremented.

Routers use slightly different pattern for mac addresses.

I would advise to figure out another way of addressing your issue vs modifying ACS code that deals with MACs.

Thanks,
Sergey




On 5/11/17, 9:27 AM, "Imran Ahmed" <im...@eaxiom.net> wrote:

    Dear Team,
    We are in a situation where the datacenter provider has put a restriction on
    the MAC addresses.
    We Cloudstack 4.3 with XenServers 6.5 .  We need to modify the pattern in
    which the guest VMs get the MAC address and use the pattern provided by the
    datacenter provider.
    Please suggest what should be a good starting point ?
    
    Best regards,
    
    Imran