{"id":675,"date":"2016-01-12T22:42:53","date_gmt":"2016-01-12T21:42:53","guid":{"rendered":"http:\/\/www.opencloudblog.com\/?p=675"},"modified":"2021-01-17T13:17:22","modified_gmt":"2021-01-17T12:17:22","slug":"openstack-juno-neutron-deployment-part-5-add-router-and-netsubnet","status":"publish","type":"post","link":"https:\/\/www.opencloudblog.com\/?p=675","title":{"rendered":"OpenStack Liberty Neutron Deployment (Part 5 Add Router and Net\/Subnet)"},"content":{"rendered":"<h1>Create a router and set a gateway<\/h1>\n<p>Now it&#8217;s time to create a router and set a gateway.<\/p>\n<pre class=\"lang:sh decode:true\">#\r\n# create a router\r\nneutron router-create r1\r\n#\r\n# attach the router to floating pool 1\r\n#\r\n# list the external networks\r\n#\r\nneutron net-external-list\r\n+--------------------------------------+---------------------+-----------------------------------------------------+\r\n| id                                   | name                | subnets                                             |\r\n+--------------------------------------+---------------------+-----------------------------------------------------+\r\n| f79385f6-e878-4450-9ed9-e906f6985149 | floating-198-18-0   | 7b9a75c2-fbbc-455b-9aa7-1a1bf286571e 198.18.0.0\/20  |\r\n| 97d1c4c7-c5a2-4399-9d12-cf9bf6bef739 | floating-198-18-16  | 3af17d23-8229-4022-a49f-f8b41939adc9 198.18.16.0\/20 |\r\n+--------------------------------------+---------------------+-----------------------------------------------------+\r\n#\r\n# list the routers\r\nneutron router-list\r\n+--------------------------------------+------+-----------------------+\r\n| id                                   | name | external_gateway_info |\r\n+--------------------------------------+------+-----------------------+\r\n| 4b965826-e67d-4473-8436-a21db3955c38 | r1   | null                  |\r\n+--------------------------------------+------+-----------------------+\r\n#\r\n# set the gateway of the router\r\n#\r\nneutron router-gateway-set 4b965826-e67d-4473-8436-a21db3955c38 f79385f6-e878-4450-9ed9-e906f6985149<\/pre>\n<p>What was configured on the nodes by Openstack?<\/p>\n<div id=\"attachment_721\" style=\"width: 970px\" class=\"wp-caption aligncenter\"><a href=\"http:\/\/www.opencloudblog.com\/wp-content\/uploads\/2015\/02\/cnsn-router2.png\"><img loading=\"lazy\" decoding=\"async\" aria-describedby=\"caption-attachment-721\" class=\"size-medium wp-image-721\" src=\"http:\/\/www.opencloudblog.com\/wp-content\/uploads\/2015\/02\/cnsn-router2-960x588.png\" alt=\"After creating the first router and setting the gateway\" width=\"960\" height=\"588\" srcset=\"https:\/\/www.opencloudblog.com\/wp-content\/uploads\/2015\/02\/cnsn-router2-960x588.png 960w, https:\/\/www.opencloudblog.com\/wp-content\/uploads\/2015\/02\/cnsn-router2-150x92.png 150w, https:\/\/www.opencloudblog.com\/wp-content\/uploads\/2015\/02\/cnsn-router2-1920x1175.png 1920w, https:\/\/www.opencloudblog.com\/wp-content\/uploads\/2015\/02\/cnsn-router2.png 1921w\" sizes=\"(max-width: 960px) 100vw, 960px\" \/><\/a><p id=\"caption-attachment-721\" class=\"wp-caption-text\">After creating the first router and setting the gateway<\/p><\/div>\n<p>A node local vlan has been set up by Openstack on br-int. This vlan 1 has to be connected to vlan 100 on our public network. This is done by using two Openflow rules to map Vlan IDs on br-int and br-vlan.<\/p>\n<pre class=\"lang:sh decode:true\" title=\"Vlan mapping rules\">#\r\n# on br-vlan\r\ncookie=0x0, duration=16s, table=0, n_packets=5, n_bytes=115, idle_age=1711, hard_age=65534, \r\n            priority=4,in_port=2,dl_vlan=1 actions=mod_vlan_vid:100,NORMAL\r\n#\r\n# on br-int\r\ncookie=0x0, duration=16s, table=0, n_packets=11, n_bytes=1479, idle_age=216, hard_age=65534,\r\n            priority=3,in_port=1,dl_vlan=100 actions=mod_vlan_vid:1,NORMAL\r\n<\/pre>\n<p>The router is running on the network node in a Linux network namespace. The name of the network namespace is build from &#8222;qrouter-&#8220; and the UUID of the router [qrouter-4b965826-e67d-4473-8436-a21db3955c38].<\/p>\n<h1>Create a second router and set a gateway<\/h1>\n<p>Now create a second router and set the gateway to use the second floating pool.<\/p>\n<div id=\"attachment_724\" style=\"width: 970px\" class=\"wp-caption aligncenter\"><a href=\"http:\/\/www.opencloudblog.com\/wp-content\/uploads\/2015\/02\/cnsn-2router.png\"><img loading=\"lazy\" decoding=\"async\" aria-describedby=\"caption-attachment-724\" class=\"size-medium wp-image-724\" src=\"http:\/\/www.opencloudblog.com\/wp-content\/uploads\/2015\/02\/cnsn-2router-960x588.png\" alt=\"After adding the second router\" width=\"960\" height=\"588\" srcset=\"https:\/\/www.opencloudblog.com\/wp-content\/uploads\/2015\/02\/cnsn-2router-960x588.png 960w, https:\/\/www.opencloudblog.com\/wp-content\/uploads\/2015\/02\/cnsn-2router-150x92.png 150w, https:\/\/www.opencloudblog.com\/wp-content\/uploads\/2015\/02\/cnsn-2router-1920x1175.png 1920w, https:\/\/www.opencloudblog.com\/wp-content\/uploads\/2015\/02\/cnsn-2router.png 1921w\" sizes=\"(max-width: 960px) 100vw, 960px\" \/><\/a><p id=\"caption-attachment-724\" class=\"wp-caption-text\">After adding the second router<\/p><\/div>\n<p>Creating a second router and setting a gateway triggered the creation of a second node local vlan on br-int. Another set of vlan mappings between the local vlan 2 and the global vlan 101 is created on br-int and br-vlan.<\/p>\n<h1>Create a tenant network and attach it to r2<\/h1>\n<p>Now let&#8217;s create a tenant network and attach it to r2<\/p>\n<pre class=\"lang:sh decode:true\" title=\"Create a net\/subnet and attach it to r2\"># using names instead of UUIDs works when names of resources are unique\r\n#\r\n# create the broadcast domain\r\nneutron net-create n1\r\n#\r\n# create the subnet \r\nneutron subnet-create --name s1 n1 192.168.1.0\/24\r\n#\r\n# attach the router to the created network\r\nneutron router-interface-add r2 s1\r\n<\/pre>\n<p>Lets take a view on the network:<\/p>\n<div id=\"attachment_835\" style=\"width: 951px\" class=\"wp-caption aligncenter\"><img loading=\"lazy\" decoding=\"async\" aria-describedby=\"caption-attachment-835\" class=\"size-large wp-image-835\" src=\"http:\/\/www.opencloudblog.com\/wp-content\/uploads\/2015\/02\/cnsn-network1-1-1920x1176.png\" alt=\"Create a net\/subnet and attach it to r2\" width=\"941\" height=\"576\" srcset=\"https:\/\/www.opencloudblog.com\/wp-content\/uploads\/2015\/02\/cnsn-network1-1.png 1920w, https:\/\/www.opencloudblog.com\/wp-content\/uploads\/2015\/02\/cnsn-network1-1-150x92.png 150w, https:\/\/www.opencloudblog.com\/wp-content\/uploads\/2015\/02\/cnsn-network1-1-960x588.png 960w, https:\/\/www.opencloudblog.com\/wp-content\/uploads\/2015\/02\/cnsn-network1-1-768x470.png 768w\" sizes=\"(max-width: 941px) 100vw, 941px\" \/><p id=\"caption-attachment-835\" class=\"wp-caption-text\">Create a net\/subnet and attach it to r2<\/p><\/div>\n<p>The tenant network n1\/s1 is assigned the node local vlan 3. This network is using vxlan for the L2 transport, because it is a tenant vlan and the tenant network type has been set to vxlan. The global vxlan id 0x10001 is assigned to this tenant network by Neutron. On the network node, vlan 3 on br-int must be used to attach the interface of the router r2. In addition, a vxlan to vlan mapping is created on br-tun:<\/p>\n<pre class=\"lang:sh decode:true\" title=\"br-tun rules to map vxlan ids to vlan ids\"># map vlan --&gt; vxlan\r\ncookie=0x0, duration=33.693s, table=4, n_packets=0, n_bytes=0, idle_age=33, priority=1,\r\n            tun_id=0x10001 actions=mod_vlan_vid:3,resubmit(,10)\r\n# map vxlan -&gt; vlan (this is a flooding entry, the traffic is flooded to all nodes in the vxlan mesh)\r\ncookie=0x0, duration=33.750s, table=22, n_packets=3, n_bytes=182, idle_age=25, \r\n            dl_vlan=3 actions=strip_vlan,set_tunnel:0x10001,output:2\r\n<\/pre>\n<p>On the network node, a neutron namespace metadata proxy (used by Cloudinit) is running in the network namespace of the router. This proxy listens to Port 8775. All traffic, which reaches the router namespace for the target 169.254.169.254:8775 is redirected to this proxy, forwarded using a unix socket to the neutron metadata proxy in the default network namespace, and is then forwarded to the nova metadata proxy service.<\/p>\n<h1>The tenant&#8217;s view<\/h1>\n<p>On the dashboard, the tenants network view shows:<\/p>\n<div id=\"attachment_738\" style=\"width: 410px\" class=\"wp-caption aligncenter\"><a href=\"http:\/\/www.opencloudblog.com\/wp-content\/uploads\/2015\/02\/neutron-2view.png\"><img loading=\"lazy\" decoding=\"async\" aria-describedby=\"caption-attachment-738\" class=\"wp-image-738\" src=\"http:\/\/www.opencloudblog.com\/wp-content\/uploads\/2015\/02\/neutron-2view-799x600.png\" alt=\"Tenant's view with two routers\" width=\"400\" height=\"300\" srcset=\"https:\/\/www.opencloudblog.com\/wp-content\/uploads\/2015\/02\/neutron-2view-799x600.png 799w, https:\/\/www.opencloudblog.com\/wp-content\/uploads\/2015\/02\/neutron-2view-150x113.png 150w, https:\/\/www.opencloudblog.com\/wp-content\/uploads\/2015\/02\/neutron-2view.png 1006w\" sizes=\"(max-width: 400px) 100vw, 400px\" \/><\/a><p id=\"caption-attachment-738\" class=\"wp-caption-text\">Tenant&#8217;s view with two routers<\/p><\/div>\n<p>The two routers are connected to the blue networks in the dashboard view, the red network in the dashboard view has been created by the tenant. This network (n1) is connected to one of the two routers.<\/p>\n<p><a title=\"Part 6\" href=\"http:\/\/www.opencloudblog.com\/?p=740\">Continue reading (part 6)<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Create a router and set a gateway Now it&#8217;s time to create a router and set a gateway. # # create a router neutron router-create r1 # # attach the router to floating pool 1 # # list the external networks # neutron net-external-list +&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;+&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;+&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;+ | id | name | subnets | +&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;+&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;+&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;+ | f79385f6-e878-4450-9ed9-e906f6985149 [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[14],"tags":[],"_links":{"self":[{"href":"https:\/\/www.opencloudblog.com\/index.php?rest_route=\/wp\/v2\/posts\/675"}],"collection":[{"href":"https:\/\/www.opencloudblog.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.opencloudblog.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.opencloudblog.com\/index.php?rest_route=\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.opencloudblog.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=675"}],"version-history":[{"count":32,"href":"https:\/\/www.opencloudblog.com\/index.php?rest_route=\/wp\/v2\/posts\/675\/revisions"}],"predecessor-version":[{"id":836,"href":"https:\/\/www.opencloudblog.com\/index.php?rest_route=\/wp\/v2\/posts\/675\/revisions\/836"}],"wp:attachment":[{"href":"https:\/\/www.opencloudblog.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=675"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.opencloudblog.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=675"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.opencloudblog.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=675"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}