OpenStack Networking Essentials - Sample Chapter
OpenStack Networking Essentials - Sample Chapter
ee
$ 39.99 US
25.99 UK
P U B L I S H I N G
E x p e r i e n c e
D i s t i l l e d
OpenStack Networking
Essentials
Build and manage networks in OpenStack using Neutron
Sa
m
pl
C o m m u n i t y
James Denton
OpenStack Networking
Essentials
James Denton
networking and has been deploying, operating, and maintaining OpenStack clouds
since late 2012. He is a Principal Architect at Rackspace, and prior to joining the
Rackspace Private Cloud team, he spent 5 years as an enterprise network security
engineer. James has a bachelor's degree in business management, with a focus on
computer information systems, from Texas State University in San Marcos, Texas. In
his spare time, James enjoys spending time with his wife and son and camping in the
Texas hill country.
Preface
OpenStack is an open source cloud operating system designed to control pools of
compute, storage, and networking resources. This powerful system fosters rapid
innovation while decreasing operational and capital costs. OpenStack has exploded
in popularity in recent years, thanks to its features, flexibility, and overall maturity.
In this book, we will explore the networking component of OpenStack, known as
Neutron. Neutron provides an API for users to build virtual network resources
such as switches, routers, load balancers, and firewalls. We will walk through the
installation of OpenStack using RDO and will look at the core components of the
API, made up of networks, subnets, and ports. By the end of the book, you will have
harnessed the power of OpenStack and Neutron to create and access virtual network
resources of your own.
Preface
Chapter 6, Routing, discusses how Neutron implements virtual routers that provide
routing between Neutron networks and the outside world using source network
address translation and floating IPs.
Chapter 7, Building Networks and Routers, covers basic virtual network architectures
and showcases the traffic flow from client workstations to virtual machine instances
via fixed and floating IPs.
Chapter 8, Security Group Fundamentals, examines the use of Neutron security groups
to secure instance traffic at the virtual switch port and walks you through creating
and managing security groups and associated rules.
Appendix, Configuring VirtualBox, is meant to assist with the setup of a virtual
environment using VirtualBox so that many of the examples throughout the
book can be followed.
Operating system:
Software:
Routing
In the previous chapter, we discovered how Neutron builds out logical networks
using two of the most popular open source virtual switching platforms for
OpenStack: Open vSwitch and LinuxBridge. In this chapter, we will take a look at
how Neutron implements virtual routers that provide routing between Neutron
networks and the outside world. Concepts that will be covered include network
namespaces, Source Network Address Translation (SNAT), and floating IPs.
Network namespaces
In a reference implementation, virtual routers created in Neutron are implemented
as network namespaces that reside on nodes running the Neutron L3 agent service.
Network namespaces are similar in function to Virtual Routing and Forwarding
(VRF) domains, where multiple instances of a routing table exist to provide
complete network segregation in a single device. The use of network namespaces
allows Neutron to support overlapping subnets across networks. In Linux, network
namespaces can be managed using the ip netns command as the root user or a
user with sudo privileges. Router namespaces follow the qrouter-<router_id>
naming convention.
[ 71 ]
Routing
The Neutron L3 agent service usually runs on controller nodes or dedicated network
nodes, but as we'll see later, the service can also run on compute nodes to help
provide a smaller failure zone when using distributed virtual routers.
Instances in Tenant Network A can use the Neutron router as their default
gateway to communicate with instances in Tenant Network B, and vice versa.
When an external provider network is attached to the Neutron router, the router
can route traffic upstream to its respective gateway device. In most cases, a physical
routing device will be the gateway for a Neutron router. The following diagram
demonstrates a physical gateway and the Neutron router connected to a common
provider network:
[ 72 ]
Chapter 6
[ 73 ]
Routing
Outbound connectivity
By default, Neutron routers will apply Source Network Address Translation
(SNAT) to all outbound traffic from connected tenant networks. This means that, as
traffic exits the virtual router and heads upstream, the router modifies each packet
and changes the source IP address to that of its own external interface. This ensures
that return traffic gets directed back to the virtual router, where the destination
IP address is modified from the router's address back to the original client.
The following diagram demonstrates a router performing SNAT for a virtual
machine instance:
Inbound connectivity
In a SNAT scenario, all traffic leaving the router appears to come from the same
address. In addition, inbound connections cannot be made directly to a SNAT
address, which means that that address cannot be used to reach the instance directly.
[ 74 ]
Chapter 6
[ 75 ]
Routing
Types of routers
Neutron routers act as the default gateway for connected tenant networks
and provide outbound and inbound connectivity to the instances they service.
Neutron provides three types of routers to users:
Standalone
Highly available
Distributed
Routers can be created in both the Horizon dashboard and via the Neutron CLI.
As an ordinary user, the type of router that is created via the API is predetermined,
based on a combination of settings found in the Neutron server and L3 agent
configuration files. Users with the admin role are free to define the type of router
to be created using the router-create command, using the following flags:
--distributed {true | false}
--ha {true | false}
Neutron does not expose the router type to users via the API, even with the
router-show command. Users with the admin role, however, can see those details.
The Horizon dashboard limits all users, including administrative users, to the
default router type specified in the configuration. This behavior may change
in future releases.
Standalone routers
A standalone router is a single logical router that is implemented as a single network
namespace on a host running the Neutron L3 agent. Most often, the L3 agent runs
on dedicated network nodes or the controller nodes themselves. By its very nature,
a standalone router is a single point of failure for directly connected networks. If
the node hosting the network namespace experiences issues, connectivity through
the namespace can become limited or completely unavailable. Needless to say, the
failure of a standalone router can result in an unhappy user experience.
Standalone routers have been the default router type since the Folsom release
of OpenStack and are supported by both the Open vSwitch and LinuxBridge
mechanism drivers and agents.
[ 76 ]
Chapter 6
[ 77 ]
Routing
2. A single-step router creation wizard will appear. Name the router in the
Router Name field, as shown here:
3. Click on the Create Router button to complete the wizard and return to the
Routers screen, as shown in the following screenshot:
[ 78 ]
Chapter 6
Congratulations, you just created a virtual router! Behind the scenes, Neutron has
determined the type of router to create and may have implemented one or more
network namespaces as a result. In this environment, the default router type is
standalone, which means a single network namespace will be created that will
serve as the virtual router. In Chapter 7, Building Networks and Routers, we'll
build some common network topologies and observe traffic flow through a
Neutron router.
[ 79 ]
Routing
2. Right now, the topology consists of a single network object and a single
router object. Notice that the router and network are not connected. To
connect the router to the network, click on the Add Interface button,
shown here:
3. An interface wizard will appear. From the Subnet menu, select the subnet to
attach the router to:
[ 80 ]
Chapter 6
4. When adding an interface to a router, the router will take on the IP address
defined in the gateway_ip attribute of the selected subnet. Instead, you can
specify a different IP in the IP Address field. Click on the Add interface
button to complete the wizard and return to the network topology screen
pictured here:
The router is now connected to the network! This means that an instance in the
MySimpleNetwork network can use the router as its default gateway.
Additional interfaces can be added to the router, but only from other
networks. A Neutron router should not be connected to the same network
more than once.
[ 81 ]
Routing
Here, we can see the previously created router, MySimpleRouter. Clicking on the
router name provides a limited subset of the actions that are available through the
Project | Network | Routers pane:
[ 82 ]
Chapter 6
As expected, no routers were returned. Routers, like other OpenStack resources, are
associated with a single tenant or project and can only be viewed or managed by the
respective users of those projects or by administrators.
Creating a router
Creating a router with the Neutron client can be accomplished with the neutron
router-create command. In this example, the demo user is logged in and the router
to be created is named MyDemoRouter:
[root@allinone ~(keystone_demo)]# neutron router-create MyDemoRouter
[ 83 ]
Routing
The operation returns a response that can be seen in the following output:
Notice that the output did not return information regarding the router type. As an
ordinary user, that information is not exposed by Neutron and is only available to
users with the admin role.
Copy the id and name values from the output. You will use the router ID when you
add an interface to the router or perform certain other network activities. In some
cases, the router name can be used in lieu of the ID, but only when the name is
unique. In this example, the ID is dfa617ad-3ded-4962-9484-a5e9ce138172,
but the value will be unique in your response.
Adding an interface
Adding an interface to a router with the Neutron client can be accomplished with the
neutron router-interface-add command. To add an interface, you must specify
the router and subnet name or ID.
Users who consume all available addresses in a subnet may find it
necessary to add additional subnets to a network. Neutron allows
multiple subnets to be associated with a single network, and routers
should be connected to each subnet using the router-interface-add
command.
[ 84 ]
Chapter 6
If you recall from Chapter 4, Interfacing with Neutron, we created a network and
subnet as the demo user, named MyDemoNetwork and MyDemoSubnet, respectively. As
the demo user, perform a neutron net-list command to retrieve a list of networks
and associated subnets, like this:
That's it! As a result of adding an interface to the router via the API, Neutron created
a logical Neutron port for the virtual network interface used by the router, created
the virtual interface inside the respective network namespace, attached the interface
to the virtual switch or bridge, and configured an IP address on the virtual interface
that corresponds with the address defined by the gateway_ip attribute of the subnet.
Thanks, Neutron!
All ports currently associated with the router will be listed in the output.
As expected, the fixed IP of the port corresponds to the gateway_ip of the
MyDemoSubnet subnet.
[ 85 ]
Routing
The two qrouter namespaces in the list correspond to the two routers we've created
so far:
Using the ip netns exec <namespace> command, you can specify a command to
execute within the specified namespace. Useful commands such as ip, netstat, ps,
and iptables provide details within the scope of the namespace they're executed in.
A quick look at the MySimpleRouter network namespace shows the virtual interface
created by Neutron when we attached the router to the MySimpleSubnet subnet
earlier in this chapter:
Using the ovs-vsctl show command, we can see the qr-2e525501-5f interface
attached to the integration bridge in a local VLAN mapped to MySimpleNetwork:
[ 86 ]
Chapter 6
Additional router interfaces will be connected to the same integration bridge, but
they will be tagged with different local VLAN tags and names based on the network,
subnet, and port the interfaces are associated with.
Summary
In this chapter, we learned that Neutron routers can route between directly
connected tenant networks and external networks using network address translation.
Neutron routers can be configured in a redundant or distributed manner, and
they trade simplicity in their implementation for high availability. Like the virtual
switching infrastructure covered in the previous chapter, users without access to the
underlying infrastructure will be unable to observe how Neutron implements virtual
routers and their respective features. The logical network diagram provided within
the Horizon dashboard, coupled with an understanding of the concepts outlined in
this book, will help you understand what is happening behind the scenes.
In the next chapter, we will take a look at some common virtual network
architectures that can be built by users and will showcase the traffic flow from
client workstations to virtual machine instances using floating IPs.
[ 87 ]
www.PacktPub.com
Stay Connected: