Basic routing
«Second star to the right, ...and straight on till morning!» Edoardo Bennato
Routing is the basis of the network functionality implemented by level 3 entities (OSI) and allows two nodes A and B, not directly connected, to communicate each other through the collaboration of other nodes placed on a path in the network that connects A and B.
Routing.
The task of the network layer is therefore the transmission of packets between two arbitrary hosts, which in general are not directly connected, that is they do not have a direct connection between them. In the ISO / OSI model, the network layer software is present in all the nodes of the network, while that of the higher levels is present only in the terminal nodes. In detail, the functions of the network layer are:
Purpose of routing: connecting networks.
Routing is necessary when the network starts to become complex; If we want:
The principle on which IP routing is based is very simple: send packets on the shortest path to the destination. The calculation is performed in a distributed way by the routers through an exchange of information among them; in the table of each router possesses and it is indicated the direction the packet must take, only the next router on the path (next hop) is indicated, not the entire path. This approach exploits the property of graphs according to which even the sub-paths of a minimum path are minimal.
Routing classification
Routing, ie the process for forwarding packets from a network to other networks can be done using:
Classification of dynamic routing protocols
routing-protocols
RouterOS routing components
The router keeps the routing information in two separate spaces:
Router Information Base (RIB)
rib The routing table is a table of data that in a specific router lists all the known routes to certain networks. For each route the metric that represents the cost that is spent along this route is indicated. The routing table consists of:
In RouterOS the routing table can be displayed using menu IP > Route > List .
Routing table (RIB)
The routing table is used:
For each entry in the routing table there are letters indicating the route status according to the abbreviations shown in the table table:route-flag :
Property
Label
Description
disabled
X
The route is disabled ie it is not used.
active
A
The route is used to forward packets.
dynamic
D
The route was created by the software automatically.
It will not be exported and cannot be modified directly.
connected
C
Connected route.
statica
S
Static Route.
rip
r
Created through the RIP protocol.
bgp
b
Created through the BGP protocol.
ospf
o
Created through the OSPF protocol.
mme
m
Created through the MME protocol.
blackhole
B
Do not consider packets addressed to this route and
do not notify anyone of the action.
unreachable
U
Do not consider packages addressed to this route but
notify the situation with an ICMP message.
prohibited
P
Do not consider packets addressed to this route but
notify the situation with an ICMP message.
Labels that can be associated with a route
table:route-fla g
Forwarding Information Base (FIB)
fib Routing tables (RIB) are generally not used directly for packet forwarding; the data present in the RIB are used to generate smaller and specific tables called forwarding tables: Forwarding Information Base (FIB). A forwarding table contains only the path selected by the routing algorithm to continue routing the packet to its destination. This path is often in the form of a cache in compressed or precompiled format, in a format optimized for archiving and searching for the specific hardware of the router. In Cisco devices this component is called Cisco Express Forwarding (CEF). Then the forwarding table:
How RIB and FIB tables are used
FIB uses the following package information to determine its destination:
The possible routing decisions are:
The results of the routing decision are remembered in the routing cache (FIB) to improve forwarding performance. When another packet with the same source address, destination address, source interface, routing mark and ToS is routed, the cached results are used. This also allows the implementation of load balancing by connection (per-connection load balancing) via ECMP routes, since the values used to look up the entry in the routing cache are the same for all the packets belonging to the same connection and going in the same direction.
Forwarding Information Base (FIB)
If there is no routing entry in the cache for a packet then this is created by executing a routing decision according to the following process:
Rules that do not match the current packet are ignored. If the rule has a drop or unreachable action then this is returned as a result of the routing decision process. If the action is the search, the destination address of the packet is searched for in the routing table specified in the rule. If search fails (there is no route that matches the destination address of the packet), then the FIB proceeds to the next rule. Otherwise:
The result of this routing decision is stored in the new routing cache entry. Notice how a routing decision is returned from the indicated process which can be:
Interoperability between RIB and FIB
Default route
The route with destination address 0.0.0.0/0 applies to all destination addresses. This path is called the default route and indicated router is called the default gateway. If the routing table contains an active default route then the routing table search will always be successful. To use an analogy is like traveling in a city and finding a road sign indicating "all directions".
Connected Routes
Connected routes are automatically created for each IP network that has at least one interface connected to it (as specified in the IP address configuration). RIB keeps track of the status of the connected routes but does not change them. For each connected route there is an ip address so that:
Correspondence between addresses and connected routes.
We saw that every time we add an IP address on a valid interface (active interface) a connected route is automatically created. It should be noted that if there are two IP addresses coming from the same subnet and from the same interface there will be only one path connected. For this it is important not to place two IP addresses of the same subnet on two different interfaces, because it will confuse the RIB. For the same reason it is suggested that if an interface has multiple IP addresses on the same subnet, only the first address is indicated with the complete netmask while the others will be indicated with the netmask / 32.
As described at the beginning of the chapter in MikroTik RouterOS dynamic routes and static routes are possible. The former are created automatically when an IP address is added to an interface or through routing information obtained from specific protocols such as RIP, OSPF and BGP. Static routes are routing information entered manually by the user (network administrator) to define a specific route. The default route is an example of a static route.
Static routing
Static routes are added by creating an entry in the RIB and defining a static route to route packets. The destination network and router (gateway) to be used for this destination is indicated. The gateway can be:
Remember that if Dst-address indicates 0.0.0.0/0, all IPs on the internet are included and a default route is created.
Adding a static route
The following parameters are available when adding a static route:
Labs
Before carrying out the following laboratories make sure you have answered correctly to the summary questions on the page domande-1 .
Static routing - guided
Simple static routing
This laboratory allows you to recreate the network infrastructure of figure routing-statico-semplice and to verify the correctness of your answers. target
  1. restore factory router configuration (without default);
  2. connect the laptops between the participants based on the topology above;
  3. enter the following configuration in router R1:
    {R1}
    /ip address
    add address=10.10.20.1/24 interface=ether1 network=10.10.20.0
    add address=10.10.10.1/24 interface=ether2 network=10.10.10.0
    add address=11.11.11.2/24 interface=ether3 network=11.11.11.0
    /ip route add distance=1 dst-address=0.0.0.0/0 gateway=11.11.11.1
    /system identity set name=R1
  4. enter the following configuration in router R2:
    {R2}
    /ip address
    add address=11.11.11.1/24 interface=ether1 network=11.11.11.0
    add address=22.22.22.2/24 interface=ether2 network=22.22.22.0
    /ip route
    add distance=1 dst-address=0.0.0.0/0 gateway=22.22.22.2
    add distance=1 dst-address=10.10.10.0/24 gateway=11.11.11.2
    add distance=1 dst-address=10.10.20.0/24 gateway=11.11.11.2
    /system identity set name=R2
The laboratory is correctly executed if it is possible to ping between the two laptops and both can reach the 22.22.22.2 interface with the ping command.
Static routing - without help
Simple static routing
This laboratory allows you to recreate the network infrastructure of figure routing-statico-semplice-2 without help.
Network with static routing
routing-statico-semplice-2
Run the following operations independently:
  1. restore router configuration (without default);
  2. connect the laptops between the participants based on the topology above;
  3. performs static routing on each router as shown in the diagram.
The lab runs correctly if you can ping the three laptops.
Labs solutions
{R1}
/system identity set name=R1
/ip address
add address=192.168.1.1/24 interface=ether1 network=192.168.1.0
add address=12.12.12.1/24 interface=ether2 network=12.12.12.0
/ip route
add distance=1 dst-address=23.23.23.0/24 gateway=12.12.12.2
add distance=1 dst-address=192.168.2.0/24 gateway=12.12.12.2
add distance=1 dst-address=192.168.3.0/24 gateway=12.12.12.2
{R2}
/system identity set name=R2
/ip address
add address=192.168.2.1/24 interface=ether1 network=192.168.2.0
add address=12.12.12.2/24 interface=ether2 network=12.12.12.0
add address=23.23.23.2/24 interface=ether3 network=23.23.23.0
/ip route
add distance=1 dst-address=192.168.1.0/24 gateway=12.12.12.1
add distance=1 dst-address=192.168.3.0/24 gateway=23.23.23.3
{R3}
/system identity set name=R3
/ip address
add address=192.168.3.1/24 interface=ether1 network=192.168.3.0
add address=23.23.23.3/24 interface=ether2 network=23.23.23.0
/ip route
add distance=1 dst-address=192.168.1.0/24 gateway=23.23.23.2
add distance=1 dst-address=192.168.2.0/24 gateway=23.23.23.2
Summary questions
domande-1
  1. The default distance value for a static route is:
    1. 255
    2. 1
    3. 10
    4. 0
  2. The following routes are present in the routing table:
    0 dst=192.168.1.0/24 gateway=192.168.1.1
           1 dst=192.168.1.0/25 gateway=192.168.1.2
          
    Which gateway will be used to reach the 192.168.1.5 ip?
    1. Both, half of the traffic through 192.168.1.1 and the other half through 192.168.1.1
    2. Through 192.168.1.1
    3. Through 192.168.1.2
    4. The required route is not present in the routing table
  3. The default distance value for a connected route is:
    1. 255
    2. 1
    3. 10
    4. 0
  4. Can a route have the D and S flags at the same time?
    1. Yes
    2. No
  5. Can a route have the A, C and S flags at the same time?
    1. Yes
    2. No
  6. The following routes are present in the routing table:
    0 dst=192.168.1.0/24 gateway=192.168.1.1 distance=10
           1 dst=192.168.1.0/25 gateway=192.168.1.2 distance=20
           
    Which gateway will be used to reach the 192.168.1.5 ip?
    1. Both, half of the traffic through 192.168.1.1 and the other half through 192.168.1.1
    2. Through 192.168.1.1
    3. Through 192.168.1.2
    4. None because the distance is >= 10
  7. Remembering that the gateway routers must always be in the subnet of an IP interface of the router to answer the following questions with reference to figure routing-statico-semplice :
    Network with static routing
    routing-statico-semplice
    1. On laptop A, what is the IP gateway on the 11.11.11.0/24 network?
    2. On laptop A, what is the IP gateway for the network is 22.22.22.0/24?
    3. On laptop A, what is the IP of the default gateway?
    4. In R1, what is the IP gateway on the 22.22.22.0/24 network?
    5. In R1, what is the IP of the default gateway?
    6. On R2, what IP gateways need to be set up to reach laptop networks?
Solutions