Ask Your Question
1

vm on multiple networks

asked 2018-02-23 06:16:40 -0600

Navya gravatar image

how to launch a single vm on multiple networks?

I mean how to link the vm to multiple networks just like router interface.

edit retag flag offensive close merge delete

3 answers

Sort by » oldest newest most voted
1

answered 2018-02-24 04:34:41 -0600

Radhakrishnan Rk gravatar image

Create a port with required details in a virtual network :

https://docs.openstack.org/ocata/cli-...

Example:

neutron port-create --fixed-ip subnet_id=SUBNET,ip_address=IP_ADDR --security-group SECURITY_GROUP <network-id>

After a port is created, attach security group to it.

Once port it is created in a specific network, use nova command to attach the interface to a virtual machine.

nova interface-attach --port-id <port-id> <server-id>

edit flag offensive delete link more

Comments

You can directly choose virtual networks where the vm has to be launched and sg from dash board/cli/api while creating vm. Or use the above steps to add network interfaces of multiple networks to a vm.

Radhakrishnan Rk gravatar imageRadhakrishnan Rk ( 2018-02-24 04:36:45 -0600 )edit
1

answered 2018-02-23 07:58:28 -0600

https://docs.openstack.org/python-ope...

openstack server add network

or

openstack server add port

Also, when creating an instance, you can specify several —nic options.

edit flag offensive delete link more
0

answered 2018-02-25 09:55:37 -0600

yas gravatar image

updated 2018-02-25 09:57:34 -0600

Let's assume that you have 2 external networks Network A with the Network address (192.168.255.0/24) and Network B with a network address (192.168.0.0/24). Network A is linked through a neutron router to a private internal Network A_internal with the Network address (10.0.0.0/24) and Network B is linked also through a neutron router to a private internal Network B_internal with the Network address (10.0.1.0/24):

  1. First, start an instance from the dashboard and link it to the private internal network A_internal (Let's assume that it has the following internal address 10.0.0.2

  2. attach a second NIC to the instance (you can do it from the dashboard) (Let's assume that the second NIC has the following internal IP address (from Network B_internal) 10.0.1.8)

Now you will have an instance that is connected to A_internal and B_internal

Adding floating IP addresses

If you want your instance to be reachable from outside you need to add a floating IP address to your instance to be reachable from outside. In the case when you want your instance to be reachable from outside by machines in the Network A and machines in Network B you need to associate two floating IP addresses. You can associate the first floating IP address (from Network A 192.168.255.0/24) from the Horizon dashboard. In order to add a second floating IP address to the second interface which is linked to the network B_internal you need to do the following:

  1. determine the port id of internal ip address 10.0.1.8 using the following command:

    neutron port-list

    copy that id (port_id)

  2. Determine which floating ip address you want to use:

    neutron floatingip-list

    copy the floating ip address (192.168.0.3 for example) id (floating_ip_id)

  3. associate the floating ip to the port id

    neutron floatingip-associate floating_ip_id port_id

Now you should have an instance that is connected to two networks with two floating IPs. In order to the have the second interface fully working you to do the following in the instance (through vnc or ssh) :

echo "1 rt2" >> /etc/iproute2/rt_tables

ip route add 192.168.0.0/24 dev eth1 src 192.168.0.3 table rt2

ip route add default via 192.168.0.1 dev eth1 table rt2

ip rule add from 192.168.0.3/32 table rt2

ip rule add to 192.168.0.3/32 table rt2

Now you might be able to ping the second floating ip address 192.168.0.3 from outside. In the case when you can ping it but cannot ssh it try to use a lower mtu in the instance:

sudo ip link set eth1 mtu 1400

You can add as many interfaces as you want. Hope it helps I use this technique to access multiple instances that are connected to different VLANs from one single management network and it works fine ... (more)

edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Get to know Ask OpenStack

Resources for moderators

Question Tools

2 followers

Stats

Asked: 2018-02-23 06:16:40 -0600

Seen: 295 times

Last updated: Feb 25