Routing Basics
Module Introduction
Before you start the hands-on part of this module, you should load the appropriate configuration and verify that the testbed is up and running by executing the corresponding robot file:
student@tour:~/trainings_resources/robot$ robot routing_basics/routing_setup.robot
In order to get a better understanding, the lab setup is shown in the picture below.
RBFS Routing Overview
Routing is the process of determining where to send IP packets destined for IP addresses outside of the local network. A router collects and maintains routing information to enable sending and receiving of such data packets. This process is called forwarding and usually done in purpose-built hardware.
There are a couple of different routing protocols. In this tour we will cover
-
direct routes (interfaces)
-
static routing
-
Interior Gateway Protocols (IGPs) like OSPF and IS-IS
-
Border Gateway Protocol (BGP)
We have already covered the interface routes in the previous module.
All routing protocols contribute to the routing table which provides the best entries for each IP destination. The most important command to view the routing table is the show route command. There are a lot of useful options to narrow down the output of the show route command:
-
address-family describes which address family identifier (AFI), e.g., ipv4 or ipv6, and which subaddress family identifier (SAFI), e.g., unicast, labeled-unicast, etc., should be displayed
-
source restricts the output to a certain routing protocol, e.g., static, direct, …
-
prefix is used to view only a certain IP prefix
Execute the show route ipv4 unicast prefix 172.16.0.0/27 command. Which information can you extract from the output (e.g., route source)?
Click to reveal the answer
cfg> show route ipv4 unicast prefix 172.16.0.0/27
Instance: default, AFI: ipv4, SAFI: unicast
Prefix/Label Source Pref Next Hop Interface
172.16.0.1/32 direct 0 172.16.0.1 hostif-0/0/1/0
172.16.0.0/30 direct 0 172.16.0.0 hostif-0/0/1/0
172.16.0.2/32 arp-nd 6 172.16.0.2 hostif-0/0/1/0
172.16.0.5/32 direct 0 172.16.0.5 hostif-0/0/2/0
172.16.0.4/30 direct 0 172.16.0.4 hostif-0/0/2/0
172.16.0.6/32 arp-nd 6 172.16.0.6 hostif-0/0/2/0
The most important information in this output is the nexthop address and the outgoing interface as this information is used for forwarding IP packets. As there is no routing protocol configured yet, there are mainly interface routes in the routing table which are referred to as direct. In addition, host routes for the ARP entries can be seen.
The show route prefix <prefix> command provides the hits in the routing table for the given prefix including all of its more specific prefixes.
|
The routing table contains an information called preference. The preference is used as a tiebreak if the same prefix is learned from different route sources. The lowest numerical route preference wins. As direct interface routes are the most reliable one, the default preference is 0.
Routing Instances
If you take a close look at the output of the show route command, you will find the instance name in the first line. A routing instance represents a set of interfaces, routing protocols and corresponding routing tables. You can think of a routing instance as a virtual router within RBFS.
Each logical interface is associated uniquely with a routing instance. If no routing instance is explicitly configured, the default routing instance is used. The interface association can be seen with the show interface address command.
|
Routing instances are configured using the set instance <instance_name> syntax, followed by the address families (AFI and SAFI) that the instance needs to support, such as for example ipv4 unicast or ipv6 labeled-unicast, respectively for normal ipv4 routing and for the transport of ipv6 traffic via MPLS.
Once an instance is defined, you can assign logical interfaces to it with the syntax set interface <interface-name> unit <unit-number> instance <instance-name>.
Configure a new routing instance called ABC which supports IPv4 and IPv6 unicast. Associate interface hostif-0/0/2/0 with instance ABC.
Then, verify that you can still reach R3 via hostif-0/0/2/0 by using the ping 172.16.0.6 instance ABC command.
What happens if you omit the instance ABC option to the ping command?
Click to reveal the answer
set instance ABC address-family ipv4 unicast
set instance ABC address-family ipv6 unicast
set interface hostif-0/0/2 unit 0 instance ABC
commit
We can now verify that 172.16.0.6 is still reachable when pinging from instance ABC.
cfg> ping 172.16.0.6 instance ABC count 3
ping to 172.16.0.6 60 byte packets
68 bytes from 172.16.0.6: icmp_seq=1 ttl=64 time=10.03 ms
68 bytes from 172.16.0.6: icmp_seq=2 ttl=64 time=10.00 ms
68 bytes from 172.16.0.6: icmp_seq=3 ttl=64 time=10.03 ms
--- 172.16.0.6 ping statistics ---
3 sent, 3 received, 0 errors, 0.00% loss, time 3018.14 ms
rtt min/avg/max/mdev = 10.00/10.02/10.03/0.01 ms
If you omit the instance option, the switch will try to use the default instance, and the ping command will fail to find a valid egress interface towards the destination:
supervisor@R1>rtbrick: cfg> ping 172.16.0.6 count 3
ping to 172.16.0.6 60 byte packets
Failed: network unreachable: no egress interface
Failed: network unreachable: no egress interface
Failed: network unreachable: no egress interface
--- 172.16.0.6 ping statistics ---
0 sent, 0 received, 0 errors, 0.00% loss, time 3016.04 ms
rtt min/avg/max/mdev = 0.00/0.00/0.00/0.00 ms
Static Routing
With static routing, the router learns routes when an administrator manually configures the static route. The administrator must manually update this static route entry whenever an internetwork topology change requires an update. Static routes are user-defined routes that specify the path that packets take when moving between a source and a destination. These administrator-defined routes allow very precise control over the routing behavior of the IP internetwork.
Static routes are commonly used when you are routing from a network to a stub network. A stub network (sometimes called a leaf node) is a network accessed by a single route. Static routes can also be useful for specifying a "gateway of last resort" to which all packets with an unknown destination address will be sent.
| The static route is configured for connectivity to remote networks that are not directly connected to your router. For end-to-end connectivity, a static route must be configured in both directions. |
In general, a static route consists of two components:
-
route prefix which describes the destination to be reached
-
next-hop profile which indicates how a destination can be reached
You can define a nexthop-profile using the syntax set instance <instance-name> static nexthop-profile <profile-name> nexthop <address>.
The address can be either IPv4 or IPv6.
Alternatively, you can specify an egress interface using this syntax:
set instance <instance-name> static nexthop-profile <profile-name> exit-interface <interface>
This is often used for a nexthop-profile pointing to the null0 interface, which is often useful for route aggregation.
| A static route must have exactly one nexthop profile assigned. However, the nexthop profile can be shared by multiple prefixes. |
Configuring Nexthop Profiles
Configure the following three nexthop profiles in instance default:
-
A nexthop profile named NH_R2_v4 pointing at IPv4 address 172.16.0.2 (R2)
-
A nexthop profile named NH_R2_v6 pointing at IPv6 address fc00:c0a8:0:1:172:16:0:2 (R2)
-
A nexthop profile named NULL having the null0 interface as exit-interface
Click to reveal the answer
set instance default static nexthop-profile NH_R2_v4 nexthop 172.16.0.2
set instance default static nexthop-profile NH_R2_v6 nexthop fc00:c0a8:0:1:172:16:0:2
set instance default static nexthop-profile NULL exit-interface null0
commit
Configuring Static Routing
Configure the following three static routes in instance default and associate them with the three profiles you have configured in the last exercise:
-
172.16.100.0/24 with nexthop-profile NULL
-
192.168.0.2/32 with nexthop-profile NH_R2_v4
-
fc00:c0a8::192:168:0:2/128 with nexthop-profile NH_R2_v6
Use the show route source static to check that routes are now defined.
Finally, ping the two destinations 192.168.0.2 and fc00:c0a8::192:168:0:2 (both defined on R2) to verify that traffic is being forwarded via the static routes.
Click to reveal the answer
set instance default static route ipv4 172.16.100.0/24 unicast NULL
set instance default static route ipv4 192.168.0.2/32 unicast NH_R2_v4
set instance default static route ipv6 fc00:c0a8::192:168:0:2/128 unicast NH_R2_v6
commit
Now we can check that the three static routes are installed in the routing table of the default instance
cfg> show route source static
Instance: default, AFI: ipv4, SAFI: unicast
Prefix/Label Source Pref Next Hop Interface
172.16.100.0/24 static 2 - null0
192.168.0.2/32 static 2 172.16.0.2 hostif-0/0/1/0
Instance: default, AFI: ipv6, SAFI: unicast
Prefix/Label Source Pref Next Hop Interface
fc00:c0a8::192:168:0:2/128 static 2 fc00:c0a8:0:1:172:16:0:2 hostif-0/0/1/0
cfg> ping 192.168.0.2 count 3
68 bytes from 192.168.0.2: icmp_seq=1 ttl=64 time=1.5387 ms
68 bytes from 192.168.0.2: icmp_seq=2 ttl=64 time=2.3116 ms
68 bytes from 192.168.0.2: icmp_seq=3 ttl=64 time=3.4188 ms
Statistics: 3 sent, 3 received, 0% packet loss
cfg> ping fc00:c0a8::192:168:0:2 count 3
68 bytes from fc00:c0a8::192:168:0:2: icmp_seq=1 ttl=64 time=8.9818 ms
68 bytes from fc00:c0a8::192:168:0:2: icmp_seq=2 ttl=64 time=1.3651 ms
68 bytes from fc00:c0a8::192:168:0:2: icmp_seq=3 ttl=64 time=4.6354 ms
Statistics: 3 sent, 3 received, 0% packet loss