[openstack-dev] [Network] Allocate MAC and IP address for a VM instance

Gary Kotton gkotton at vmware.com
Sun Feb 23 09:35:58 UTC 2014


Hi,
There is currently no nova network API for this.
Thanks
Gary

From: Jay Lau <jay.lau.513 at gmail.com<mailto:jay.lau.513 at gmail.com>>
Reply-To: "OpenStack Development Mailing List (not for usage questions)" <openstack-dev at lists.openstack.org<mailto:openstack-dev at lists.openstack.org>>
Date: Sunday, February 23, 2014 6:11 AM
To: "OpenStack Development Mailing List (not for usage questions)" <openstack-dev at lists.openstack.org<mailto:openstack-dev at lists.openstack.org>>
Subject: Re: [openstack-dev] [Network] Allocate MAC and IP address for a VM instance

Sorry to bring this up again, just want to ask more, currently, I can only use neutron to bind IP and MAC but cannot reach this goal via nova-network, right?

Thanks,

Jay



2014-02-19 21:05 GMT+08:00 Jay Lau <jay.lau.513 at gmail.com<mailto:jay.lau.513 at gmail.com>>:
Thanks Liu Dong. Clear now! ;-)


2014-02-19 20:17 GMT+08:00 Dong Liu <willowd878 at gmail.com<mailto:willowd878 at gmail.com>>:

Sorry for replying so late.

Yes, that is what I mean, btw, if you only need floatingip to bind vm mac, you do not need to specified --fix_ip, just specify the --mac-address is ok.

What I mean floatingip-mac is that, actually, when you creating a floatingip, neutron will automatic create a port use that public ip, this port has a mac-address, I mean this one.


在 2014年2月19日,18:22,Jay Lau <jay.lau.513 at gmail.com<mailto:jay.lau.513 at gmail.com>> 写道:

Hi Liu Dong,

Just found a solution for this as following, the method is using fixed ip as a bridge for MAC and floating ip.

Can you please help check if it is the way that you want me to do? If not, can you please give some suggestion for your idea?

Thanks,

Jay

==============My steps==============
Suppose I want to bind MAC fa:16:3e:9d:e9:11 to floating ip 9.21.52.22, I was doing as following:

1) Create a port for fixed ip with the MAC address fa:16:3e:9d:e9:11
[root at db01b05 ~(keystone_admin)]#  neutron port-create IntAdmin  --mac-address fa:16:3e:9d:e9:11 --fixed-ip ip_address=10.0.1.2
Created a new port:
+-----------------------+---------------------------------------------------------------------------------+
| Field                 | Value                                                                           |
+-----------------------+---------------------------------------------------------------------------------+
| admin_state_up        | True                                                                            |
| allowed_address_pairs |                                                                                 |
| binding:capabilities  | {"port_filter": true}                                                           |
| binding:host_id       |                                                                                 |
| binding:vif_type      | ovs                                                                             |
| device_id             |                                                                                 |
| device_owner          |                                                                                 |
| fixed_ips             | {"subnet_id": "0fff20f4-142a-4e89-add1-5c5a79c6d54d", "ip_address": "10.0.1.2"} |
| id                    | b259770d-7f9c-485a-8f84-bf7b1bbc5706                                            |
| mac_address           | fa:16:3e:9d:e9:11                                                               |
| name                  |                                                                                 |
| network_id            | fb1a75f9-e468-408b-a172-5d2b3802d862                                            |
| security_groups       | aa3f3025-ba71-476d-a126-25a9e3b34c9a                                            |
| status                | DOWN                                                                            |
| tenant_id             | f181a9c2b1b4443dbd91b1b7de716185                                                |
+-----------------------+---------------------------------------------------------------------------------+
[root at db01b05 ~(keystone_admin)]# neutron port-list | grep 10.0.1.2
| b259770d-7f9c-485a-8f84-bf7b1bbc5706 |      | fa:16:3e:9d:e9:11 | {"subnet_id": "0fff20f4-142a-4e89-add1-5c5a79c6d54d", "ip_address": "10.0.1.2"}   |

2) Create a floating ip with the port id created in step 1)
[root at db01b05 ~(keystone_admin)]# neutron floatingip-create --port-id b259770d-7f9c-485a-8f84-bf7b1bbc5706 Ex
Created a new floatingip:
+---------------------+--------------------------------------+
| Field               | Value                                |
+---------------------+--------------------------------------+
| fixed_ip_address    | 10.0.1.2                             |
| floating_ip_address | 9.21.52.22                           |
| floating_network_id | 9b758062-2be8-4244-a5a9-3f878f74e006 |
| id                  | 7c0db4ff-8378-4b91-9a6e-87ec06016b0f |
| port_id             | b259770d-7f9c-485a-8f84-bf7b1bbc5706 |
| router_id           | 43ceb267-2a4b-418a-bc9a-08d39623d3c0 |
| tenant_id           | f181a9c2b1b4443dbd91b1b7de716185     |
+---------------------+--------------------------------------+

3) Boot the VM with the port id in step 1)
[root at db01b05 ~(keystone_admin)]#  nova boot --image centos64-x86_64-cfntools --flavor 2 --key-name adminkey --nic port-id=b259770d-7f9c-485a-8f84-bf7b1bbc5706 vm0001
+--------------------------------------+--------------------------------------+
| Property                             | Value                                |
+--------------------------------------+--------------------------------------+
| OS-EXT-STS:task_state                | scheduling                           |
| image                                | centos64-x86_64-cfntools             |
| OS-EXT-STS:vm_state                  | building                             |
| OS-EXT-SRV-ATTR:instance_name        | instance-00000026                    |
| OS-SRV-USG:launched_at               | None                                 |
| flavor                               | m1.small                             |
| id                                   | c0cebd6b-94ae-4305-8619-c013d45f0727 |
| security_groups                      | [{u'name': u'default'}]              |
| user_id                              | 345dd87da2364fa78ffe97ed349bb71b     |
| OS-DCF:diskConfig                    | MANUAL                               |
| accessIPv4                           |                                      |
| accessIPv6                           |                                      |
| progress                             | 0                                    |
| OS-EXT-STS:power_state               | 0                                    |
| OS-EXT-AZ:availability_zone          | nova                                 |
| config_drive                         |                                      |
| status                               | BUILD                                |
| updated                              | 2014-02-19T10:12:36Z                 |
| hostId                               |                                      |
| OS-EXT-SRV-ATTR:host                 | None                                 |
| OS-SRV-USG:terminated_at             | None                                 |
| key_name                             | adminkey                             |
| OS-EXT-SRV-ATTR:hypervisor_hostname  | None                                 |
| name                                 | vm0001                               |
| adminPass                            | F4cSHu9oC3Wi                         |
| tenant_id                            | f181a9c2b1b4443dbd91b1b7de716185     |
| created                              | 2014-02-19T10:12:36Z                 |
| os-extended-volumes:volumes_attached | []                                   |
| metadata                             | {}                                   |
+--------------------------------------+--------------------------------------+

4) The VM goes to active with floating ip 9.21.52.22
[root at db01b05 ~(keystone_admin)]# nova list
+--------------------------------------+--------+--------+------------+-------------+-------------------------------+
| ID                                   | Name   | Status | Task State | Power State | Networks                      |
+--------------------------------------+--------+--------+------------+-------------+-------------------------------+
| c0cebd6b-94ae-4305-8619-c013d45f0727 | vm0001 | ACTIVE | None       | Running     | IntAdmin=10.0.1.2, 9.21.52.22 |
+--------------------------------------+--------+--------+------------+-------------+-------------------------------+

5) Check the VM MAC address, it is FA:16:3E:9D:E9:11 as expected
[root at db01b05 ~(keystone_admin)]# ssh -i adminkey.priv root at 9.21.52.22<mailto:root at 9.21.52.22>
ssh: connect to host 9.21.52.22 port 22: Connection refused
[root at db01b05 ~(keystone_admin)]# ssh -i adminkey.priv root at 9.21.52.22<mailto:root at 9.21.52.22>
Last login: Wed Feb 19 18:14:00 2014
[root at host-10-0-1-2 ~]# ifconfig
eth0      Link encap:Ethernet  HWaddr FA:16:3E:9D:E9:11
          inet addr:10.0.1.2  Bcast:10.0.1.255  Mask:255.255.255.0
          inet6 addr: fe80::f816:3eff:fe9d:e911/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:43 errors:0 dropped:0 overruns:0 frame:0
          TX packets:52 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:6402 (6.2 KiB)  TX bytes:6483 (6.3 KiB)

lo        Link encap:Local Loopback
          inet addr:127.0.0.1  Mask:255.0.0.0
          inet6 addr: ::1/128 Scope:Host
          UP LOOPBACK RUNNING  MTU:16436  Metric:1
          RX packets:4 errors:0 dropped:0 overruns:0 frame:0
          TX packets:4 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0
          RX bytes:352 (352.0 b)  TX bytes:352 (352.0 b)





2014-02-19 17:59 GMT+08:00 Jay Lau <jay.lau.513 at gmail.com<mailto:jay.lau.513 at gmail.com>>:
Thanks Liu Dong.

It is a VM mac address, so do you have any idea for how can I make sure the VM mac address can bind to a floating ip address?

Also what do you mean by floatingip mac?

Really thanks very much for your kind help, it is really helped me a lot!

Thanks,

Jay



2014-02-19 16:21 GMT+08:00 Dong Liu <willowd878 at gmail.com<mailto:willowd878 at gmail.com>>:

Jay, what the mac belong to? Is it a vm mac, or a mac of floatingip.
If it is a vm mac, you can associate any floatingip to vm port.
If it is a floatingip mac, I have no idea.

2014-02-19 11:44, Jay Lau :
Thanks Liu Dong.

In case that you may not get my previous question, so here just post it
again to see if you can give a help.

Is it possible to bind MAC to a FLOATING IP?

Thanks,

Jay



2014-02-19 10:38 GMT+08:00 Dong Liu <willowd878 at gmail.com<mailto:willowd878 at gmail.com>
<mailto:willowd878 at gmail.com<mailto:willowd878 at gmail.com>>>:


    yes, it does not worked via dashboard

    Dong Liu

    于 2014-02-19 8:11, Jay Lau 写道:

        Thanks Dong for the great help, it does worked with command line!

        This seems not available via dashboard, right?

        Thanks,

        Jay



        2014-02-19 1:11 GMT+08:00 Dong Liu <willowd878 at gmail.com<mailto:willowd878 at gmail.com>
        <mailto:willowd878 at gmail.com<mailto:willowd878 at gmail.com>>
        <mailto:willowd878 at gmail.com<mailto:willowd878 at gmail.com> <mailto:willowd878 at gmail.com<mailto:willowd878 at gmail.com>>>>__:



             Hi Jay,

             In neutron API, you could create port with specified
        mac_address and
             fix_ip, and then create vm with this port.
             But the mapping of them need to manage by yourself.


             在 2014年2月18日,22:41,Jay Lau <jay.lau.513 at gmail.com<mailto:jay.lau.513 at gmail.com>
        <mailto:jay.lau.513 at gmail.com<mailto:jay.lau.513 at gmail.com>>
             <mailto:jay.lau.513 at gmail.com<mailto:jay.lau.513 at gmail.com>
        <mailto:jay.lau.513 at gmail.com<mailto:jay.lau.513 at gmail.com>>>__> 写道:



              > Greetings,
              >
              > Not sure if it is suitable to ask this question in
        openstack-dev
             list. Here come a question related to network and want to
        get some
             input or comments from you experts.
              >
              > My case is as this: For some security issue, I want to
        put both
             MAC and internal IP address to a pool and when create VM, I
        can get
             MAC and its mapped IP address and assign the MAC and IP
        address to
             the VM.
              >
              > For example, suppose I have following MAC and IP pool:
              > 1) 78:2b:cb:af:78:b0, 192.168.0.10
              > 2) 78:2b:cb:af:78:b1, 192.168.0.11
              > 3) 78:2b:cb:af:78:b2, 192.168.0.12
              > 4) 78:2b:cb:af:78:b3, 192.168.0.13
              >
              > Then I can create four VMs using above MAC and IP
        address, each
             row in above can be mapped to a VM.
              >
              > Does any of you have any idea for the solution of this?
              >
              > --
              > Thanks,
              >
              > Jay
              > _________________________________________________
              > OpenStack-dev mailing list
              > OpenStack-dev at lists.openstack<mailto:OpenStack-dev at lists.openstack>.__org
        <mailto:OpenStack-dev at lists.openstack.org<mailto:OpenStack-dev at lists.openstack.org>>
             <mailto:OpenStack-dev at lists.<mailto:OpenStack-dev at lists.>__openstack.org<https://urldefense.proofpoint.com/v1/url?u=http://openstack.org/&k=oIvRg1%2BdGAgOoM1BIlLLqw%3D%3D%0A&r=eH0pxTUZo8NPZyF6hgoMQu%2BfDtysg45MkPhCZFxPEq8%3D%0A&m=k0UWhpEM3yJXwvC3t5StODNelngR%2BgY66A%2BeBJ4Psr0%3D%0A&s=a196fa464283f231de5b26c25a81d1d3a6027d0cc26d66bf7c8d575e0c788e39>
        <mailto:OpenStack-dev at lists.openstack.org<mailto:OpenStack-dev at lists.openstack.org>>>

              >
        http://lists.openstack.org/__cgi-bin/mailman/listinfo/__openstack-dev<https://urldefense.proofpoint.com/v1/url?u=http://lists.openstack.org/__cgi-bin/mailman/listinfo/__openstack-dev&k=oIvRg1%2BdGAgOoM1BIlLLqw%3D%3D%0A&r=eH0pxTUZo8NPZyF6hgoMQu%2BfDtysg45MkPhCZFxPEq8%3D%0A&m=k0UWhpEM3yJXwvC3t5StODNelngR%2BgY66A%2BeBJ4Psr0%3D%0A&s=f1451a32d00fb24d9d1298641fbc0b9d72b994c3fb6c321e8db06eaa5a72d901>
        <http://lists.openstack.org/cgi-bin/mailman/listinfo/openstack-dev<https://urldefense.proofpoint.com/v1/url?u=http://lists.openstack.org/cgi-bin/mailman/listinfo/openstack-dev&k=oIvRg1%2BdGAgOoM1BIlLLqw%3D%3D%0A&r=eH0pxTUZo8NPZyF6hgoMQu%2BfDtysg45MkPhCZFxPEq8%3D%0A&m=k0UWhpEM3yJXwvC3t5StODNelngR%2BgY66A%2BeBJ4Psr0%3D%0A&s=63f1f6e4b69c2aa39a1bfdaaa87d5bc75af6462d197287d4202895f4ba216c36>>


             _________________________________________________
             OpenStack-dev mailing list
        OpenStack-dev at lists.openstack<mailto:OpenStack-dev at lists.openstack>.__org
        <mailto:OpenStack-dev at lists.openstack.org<mailto:OpenStack-dev at lists.openstack.org>>
             <mailto:OpenStack-dev at lists.<mailto:OpenStack-dev at lists.>__openstack.org<https://urldefense.proofpoint.com/v1/url?u=http://openstack.org/&k=oIvRg1%2BdGAgOoM1BIlLLqw%3D%3D%0A&r=eH0pxTUZo8NPZyF6hgoMQu%2BfDtysg45MkPhCZFxPEq8%3D%0A&m=k0UWhpEM3yJXwvC3t5StODNelngR%2BgY66A%2BeBJ4Psr0%3D%0A&s=a196fa464283f231de5b26c25a81d1d3a6027d0cc26d66bf7c8d575e0c788e39>
        <mailto:OpenStack-dev at lists.openstack.org<mailto:OpenStack-dev at lists.openstack.org>>>

        http://lists.openstack.org/__cgi-bin/mailman/listinfo/__openstack-dev<https://urldefense.proofpoint.com/v1/url?u=http://lists.openstack.org/__cgi-bin/mailman/listinfo/__openstack-dev&k=oIvRg1%2BdGAgOoM1BIlLLqw%3D%3D%0A&r=eH0pxTUZo8NPZyF6hgoMQu%2BfDtysg45MkPhCZFxPEq8%3D%0A&m=k0UWhpEM3yJXwvC3t5StODNelngR%2BgY66A%2BeBJ4Psr0%3D%0A&s=f1451a32d00fb24d9d1298641fbc0b9d72b994c3fb6c321e8db06eaa5a72d901>

        <http://lists.openstack.org/cgi-bin/mailman/listinfo/openstack-dev<https://urldefense.proofpoint.com/v1/url?u=http://lists.openstack.org/cgi-bin/mailman/listinfo/openstack-dev&k=oIvRg1%2BdGAgOoM1BIlLLqw%3D%3D%0A&r=eH0pxTUZo8NPZyF6hgoMQu%2BfDtysg45MkPhCZFxPEq8%3D%0A&m=k0UWhpEM3yJXwvC3t5StODNelngR%2BgY66A%2BeBJ4Psr0%3D%0A&s=63f1f6e4b69c2aa39a1bfdaaa87d5bc75af6462d197287d4202895f4ba216c36>>




        --
        Thanks,

        Jay


        _________________________________________________
        OpenStack-dev mailing list
        OpenStack-dev at lists.openstack<mailto:OpenStack-dev at lists.openstack>.__org
        <mailto:OpenStack-dev at lists.openstack.org<mailto:OpenStack-dev at lists.openstack.org>>
        http://lists.openstack.org/__cgi-bin/mailman/listinfo/__openstack-dev<https://urldefense.proofpoint.com/v1/url?u=http://lists.openstack.org/__cgi-bin/mailman/listinfo/__openstack-dev&k=oIvRg1%2BdGAgOoM1BIlLLqw%3D%3D%0A&r=eH0pxTUZo8NPZyF6hgoMQu%2BfDtysg45MkPhCZFxPEq8%3D%0A&m=k0UWhpEM3yJXwvC3t5StODNelngR%2BgY66A%2BeBJ4Psr0%3D%0A&s=f1451a32d00fb24d9d1298641fbc0b9d72b994c3fb6c321e8db06eaa5a72d901>
        <http://lists.openstack.org/cgi-bin/mailman/listinfo/openstack-dev<https://urldefense.proofpoint.com/v1/url?u=http://lists.openstack.org/cgi-bin/mailman/listinfo/openstack-dev&k=oIvRg1%2BdGAgOoM1BIlLLqw%3D%3D%0A&r=eH0pxTUZo8NPZyF6hgoMQu%2BfDtysg45MkPhCZFxPEq8%3D%0A&m=k0UWhpEM3yJXwvC3t5StODNelngR%2BgY66A%2BeBJ4Psr0%3D%0A&s=63f1f6e4b69c2aa39a1bfdaaa87d5bc75af6462d197287d4202895f4ba216c36>>



    _________________________________________________
    OpenStack-dev mailing list
    OpenStack-dev at lists.openstack<mailto:OpenStack-dev at lists.openstack>.__org
    <mailto:OpenStack-dev at lists.openstack.org<mailto:OpenStack-dev at lists.openstack.org>>
    http://lists.openstack.org/__cgi-bin/mailman/listinfo/__openstack-dev<https://urldefense.proofpoint.com/v1/url?u=http://lists.openstack.org/__cgi-bin/mailman/listinfo/__openstack-dev&k=oIvRg1%2BdGAgOoM1BIlLLqw%3D%3D%0A&r=eH0pxTUZo8NPZyF6hgoMQu%2BfDtysg45MkPhCZFxPEq8%3D%0A&m=k0UWhpEM3yJXwvC3t5StODNelngR%2BgY66A%2BeBJ4Psr0%3D%0A&s=f1451a32d00fb24d9d1298641fbc0b9d72b994c3fb6c321e8db06eaa5a72d901> <http://lists.openstack.org/cgi-bin/mailman/listinfo/openstack-dev<https://urldefense.proofpoint.com/v1/url?u=http://lists.openstack.org/cgi-bin/mailman/listinfo/openstack-dev&k=oIvRg1%2BdGAgOoM1BIlLLqw%3D%3D%0A&r=eH0pxTUZo8NPZyF6hgoMQu%2BfDtysg45MkPhCZFxPEq8%3D%0A&m=k0UWhpEM3yJXwvC3t5StODNelngR%2BgY66A%2BeBJ4Psr0%3D%0A&s=63f1f6e4b69c2aa39a1bfdaaa87d5bc75af6462d197287d4202895f4ba216c36>>





--
Thanks,

Jay


_______________________________________________
OpenStack-dev mailing list
OpenStack-dev at lists.openstack.org<mailto:OpenStack-dev at lists.openstack.org>
http://lists.openstack.org/cgi-bin/mailman/listinfo/openstack-dev<https://urldefense.proofpoint.com/v1/url?u=http://lists.openstack.org/cgi-bin/mailman/listinfo/openstack-dev&k=oIvRg1%2BdGAgOoM1BIlLLqw%3D%3D%0A&r=eH0pxTUZo8NPZyF6hgoMQu%2BfDtysg45MkPhCZFxPEq8%3D%0A&m=k0UWhpEM3yJXwvC3t5StODNelngR%2BgY66A%2BeBJ4Psr0%3D%0A&s=63f1f6e4b69c2aa39a1bfdaaa87d5bc75af6462d197287d4202895f4ba216c36>



_______________________________________________
OpenStack-dev mailing list
OpenStack-dev at lists.openstack.org<mailto:OpenStack-dev at lists.openstack.org>
http://lists.openstack.org/cgi-bin/mailman/listinfo/openstack-dev<https://urldefense.proofpoint.com/v1/url?u=http://lists.openstack.org/cgi-bin/mailman/listinfo/openstack-dev&k=oIvRg1%2BdGAgOoM1BIlLLqw%3D%3D%0A&r=eH0pxTUZo8NPZyF6hgoMQu%2BfDtysg45MkPhCZFxPEq8%3D%0A&m=k0UWhpEM3yJXwvC3t5StODNelngR%2BgY66A%2BeBJ4Psr0%3D%0A&s=63f1f6e4b69c2aa39a1bfdaaa87d5bc75af6462d197287d4202895f4ba216c36>



--
Thanks,

Jay



--
Thanks,

Jay
_______________________________________________
OpenStack-dev mailing list
OpenStack-dev at lists.openstack.org<mailto:OpenStack-dev at lists.openstack.org>
http://lists.openstack.org/cgi-bin/mailman/listinfo/openstack-dev<https://urldefense.proofpoint.com/v1/url?u=http://lists.openstack.org/cgi-bin/mailman/listinfo/openstack-dev&k=oIvRg1%2BdGAgOoM1BIlLLqw%3D%3D%0A&r=eH0pxTUZo8NPZyF6hgoMQu%2BfDtysg45MkPhCZFxPEq8%3D%0A&m=k0UWhpEM3yJXwvC3t5StODNelngR%2BgY66A%2BeBJ4Psr0%3D%0A&s=63f1f6e4b69c2aa39a1bfdaaa87d5bc75af6462d197287d4202895f4ba216c36>


_______________________________________________
OpenStack-dev mailing list
OpenStack-dev at lists.openstack.org<mailto:OpenStack-dev at lists.openstack.org>
http://lists.openstack.org/cgi-bin/mailman/listinfo/openstack-dev<https://urldefense.proofpoint.com/v1/url?u=http://lists.openstack.org/cgi-bin/mailman/listinfo/openstack-dev&k=oIvRg1%2BdGAgOoM1BIlLLqw%3D%3D%0A&r=eH0pxTUZo8NPZyF6hgoMQu%2BfDtysg45MkPhCZFxPEq8%3D%0A&m=k0UWhpEM3yJXwvC3t5StODNelngR%2BgY66A%2BeBJ4Psr0%3D%0A&s=63f1f6e4b69c2aa39a1bfdaaa87d5bc75af6462d197287d4202895f4ba216c36>




--
Thanks,

Jay



--
Thanks,

Jay
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.openstack.org/pipermail/openstack-dev/attachments/20140223/54bdce8e/attachment.html>


More information about the OpenStack-dev mailing list