Ask Your Question

How to create a router to connect 2 subnets? [closed]

asked 2014-12-09 22:35:31 -0500

teju gravatar image

updated 2014-12-10 02:13:38 -0500

SamYaple gravatar image

I have created 2 networks,2 subnets and 2 ports as below:

neutron net-create test1;
neutron subnet-create --name subnet1_test1 test1;
neutron port-create test1 --binding:profile type=dict vnic_type=hostdev;
neutron net-create test2;
neutron subnet-create --name subnet1_test2 test2;
neutron port-create test2 --binding:profile type=dict vnic_type=hostdev;

I've booted 2 instances,one in network test1 and other in network test2

The 2 instances cannot ping each other since they are in a different subnet.

How to create a router to make the instances ping each other?

Please specify the commands if possible, else provide links.

Please specify if we have to add any security group rules.

edit retag flag offensive reopen merge delete

Closed for the following reason the question is answered, right answer was accepted by teju
close date 2014-12-10 23:08:49.693674

4 answers

Sort by ยป oldest newest most voted

answered 2014-12-10 22:38:12 -0500

teju gravatar image

Here are the list of all commands I've used to make the instances on 2 different networks ping each other:

  1. Create networks, subnets,router,ports

neutron net-create net1 neutron subnet-create net1 neutron net-create net2 neutron subnet-create net2 neutron router-create router1

neutron router-interface-add router1 SUBNET1_UUID neutron router-interface-add router1 SUBNET2_UUID

neutron port-create net1 --binding:profile type=dict vnic_type=hostdev neutron port-create net2 --binding:profile type=dict vnic_type=hostdev

  1. Create br-ex and bind a port to it.

ovs-vsctl add-br br-ex ovs-vsctl add-port br-ex em2

  1. As soon as em2 is added as port to br-ex, em2 loses it's IP. So, run below commands to move IP to br-ex

ifconfig em2 ifconfig br-ex

  1. Create external network and subnet

neutron net-create ext-net --shared --router:external=True neutron subnet-create ext-net --name ext-subnet --allocation-pool start=,end= --disable-dhcp --gateway

  1. Launch 2 instances

nova boot --flavor 5 --image centos6.4 centos6.4_1 --nic port-id=<port id="" 1=""> nova boot --flavor 5 --image centos6.4 centos6.4_2 --nic port-id=<port id="" 2="">

edit flag offensive delete link more

answered 2014-12-10 02:30:01 -0500

SamYaple gravatar image

The last command with allow ping traffic to and from both networks you listed if you are using the default security group.

neutron router-create router_test1
neutron router-interface-add <router-id> subnet1_test1
neutron router-interface-add <router-id> subnet1_test2

nova secgroup-add-rule default icmp -1 -1
nova secgroup-add-rule default icmp -1 -1
edit flag offensive delete link more


Hi. The instances could not ping each other even after adding the security rules. Please help me debug this issue.

teju gravatar imageteju ( 2014-12-10 03:07:32 -0500 )edit

answered 2014-12-09 23:26:01 -0500

pramdoyal gravatar image

Hi Teju,

The link below will provide you step by step commands to follow to create a router and connect the 2 subnets.

Thanks Prakash

edit flag offensive delete link more


Hi Prakash,

Thanks for the reply.

I created a router, but it's namespace is not created. As per the instructions in the link, the command ip netns list should have an entry like qrouter-<router-id>.

But, I don't see the entry for the new router

teju gravatar imageteju ( 2014-12-10 00:17:11 -0500 )edit

answered 2014-12-10 00:25:20 -0500

updated 2014-12-10 02:13:55 -0500

SamYaple gravatar image
neutron router-create router1
neutron router-gateway-set ROUTER NETWORK
neutron router-interface-add ROUTER SUBNET
edit flag offensive delete link more

Get to know Ask OpenStack

Resources for moderators

Question Tools

1 follower


Asked: 2014-12-09 22:35:31 -0500

Seen: 6,334 times

Last updated: Dec 10 '14