title: S1E12 - Interlude - Route Selection |
author: Nicholas Morrison nick@nanocat.net |
draft: false |
tags: [network, workshop, arista, routing] |
categories: [workshop] |
noindex: true |
“For packets with destinations in this network, send them to this router.”
!
ip route 192.168.100.0/24 10.10.10.5
! ^ destination ^ router
!
show ip route
, or
show ip route 192.168.100.8
)192.168.100.0/24 via 10.10.10.5
10.10.10.5
1 AND 1 == 1
1 AND 0 == 0
0 AND 0 == 0
1 OR 1 == 1
1 OR 0 == 1
0 OR 0 == 0
11 AND 10 == 10
01 AND 00 == 00
11 OR 10 == 11
01 OR 00 == 01
101 AND 110 == 100 (5 AND 6 == 4)
101 AND 101 == 101 (5 AND 5 == 5)
001 AND 101 == 001 (1 AND 5 == 1)
101 OR 110 == 111 (5 OR 6 == 7)
101 OR 101 == 101 (5 OR 5 == 5)
001 OR 101 == 101 (1 OR 5 == 5)
1111 AND 1110 == 1110 (15 AND 14 == 14)
1101 AND 0001 == 0001 (13 AND 1 == 1)
1111 OR 1110 == 1111 (15 OR 14 == 15)
1101 OR 0001 == 1101 (13 OR 1 == 13)
11111100
in binary) quantises to multiples of 4:
00000000 AND 11111100 == 00000000 (0 AND 252 == 0)
00000001 AND 11111100 == 00000000 (1 AND 252 == 0)
00000010 AND 11111100 == 00000000 (2 AND 252 == 0)
00000011 AND 11111100 == 00000000 (3 AND 252 == 0)
00000100 AND 11111100 == 00000100 (4 AND 252 == 4)
00000101 AND 11111100 == 00000100 (5 AND 252 == 4)
00000110 AND 11111100 == 00000100 (6 AND 252 == 4)
00000111 AND 11111100 == 00000100 (7 AND 252 == 4)
00001000 AND 11111100 == 00001000 (8 AND 252 == 8)
00001001 AND 11111100 == 00001000 (9 AND 252 == 8)
00001010 AND 11111100 == 00001000 (10 AND 252 == 8)
00001011 AND 11111100 == 00001000 (11 AND 252 == 8)
11111111
(255)
11111100 AND 11111100 == 11111100 (252 AND 252 == 252)
11111101 AND 11111100 == 11111100 (253 AND 252 == 252)
11111110 AND 11111100 == 11111100 (254 AND 252 == 252)
11111111 AND 11111100 == 11111100 (255 AND 252 == 252)
11000000.10101000.00000000.00000101
(192.168.0.5)11111111.11111111.11111111.11111100
(255.255.255.252)
(aka /30)AND
11000000.10101000.00000000.00000100
(192.168.0.4)A packet arrives for forwarding with destination 192.168.100.1. Which route will be chosen?
r7#show ip route
...
Gateway of last resort is not set
C 10.0.0.0/24 is directly connected, Ethernet1
S 192.168.100.0/32 [1/0] via 10.0.0.5, Ethernet1
S 192.168.100.0/30 [1/0] via 10.0.0.4, Ethernet1
S 192.168.100.0/27 [1/0] via 10.0.0.3, Ethernet1
S 192.168.100.0/24 [1/0] via 10.0.0.2, Ethernet1
r7#
Our destination address, converted to binary:
packet's dst: 192 . 168 . 100 . 1
11000000.10101000.01100100.00000001
The first static route is 192.168.100.0 with a 32 bit netmask (255.255.255.255). Does it match?
S 192.168.100.0/32 [1/0] via 10.0.0.5, Ethernet1
192.168.100.0 => 11000000.10101000.01100100.00000000 <-+
|
192.168.100.1 => 11000000.10101000.01100100.00000001 |
bitwise AND to find network |
/32 => 11111111.11111111.11111111.11111111 |
equals |
11000000.10101000.01100100.00000001 <-+
The result of ANDing the destination IP with the /32 netmask is different to the network of this static route.
Therefore, the destination IP 192.168.100.1 is not inside the 192.168.100.0/32 network.
S 192.168.100.0/30 [1/0] via 10.0.0.4, Ethernet1
192.168.100.0 => 11000000.10101000.01100100.00000000 <-+
|
192.168.100.1 => 11000000.10101000.01100100.00000001 |
bitwise AND to find network |
/30 => 11111111.11111111.11111111.11111100 |
equals |
11000000.10101000.01100100.00000000 <-+
S 192.168.100.0/27 [1/0] via 10.0.0.3, Ethernet1
192.168.100.0 => 11000000.10101000.01100100.00000000 <-+
|
192.168.100.1 => 11000000.10101000.01100100.00000001 |
bitwise AND to find network |
/27 => 11111111.11111111.11111111.11100000 |
equals |
11000000.10101000.01100100.00000000 <-+
24 bits of netmask (255.255.255.0):
S 192.168.100.0/24 [1/0] via 10.0.0.2, Ethernet1
192.168.100.0 => 11000000.10101000.01100100.00000000 <-+
|
192.168.100.1 => 11000000.10101000.01100100.00000001 |
bitwise AND to find network |
/24 => 11111111.11111111.11111111.00000000 |
equals |
11000000.10101000.01100100.00000000 <-+
S 192.168.100.0/30 [1/0] via 10.0.0.4, Ethernet1
is the chosen routeA packet arrives for forwarding with destination 192.168.100.25. Which route will be chosen?
r7#show ip route
...
Gateway of last resort is not set
C 10.0.0.0/24 is directly connected, Ethernet1
S 192.168.100.0/32 [1/0] via 10.0.0.5, Ethernet1
S 192.168.100.0/30 [1/0] via 10.0.0.4, Ethernet1
S 192.168.100.0/27 [1/0] via 10.0.0.3, Ethernet1
S 192.168.100.0/24 [1/0] via 10.0.0.2, Ethernet1
r7#
Our destination address, converted to binary:
packet's dst: 192 . 168 . 100 . 25
11000000.10101000.01100100.00011001
The first static route is 192.168.100.0 with a 32 bit netmask (255.255.255.255). Does it match?
S 192.168.100.0/32 [1/0] via 10.0.0.5, Ethernet1
192.168.100.0 => 11000000.10101000.01100100.00000000 <-+
|
192.168.100.25 => 11000000.10101000.01100100.00011001 |
bitwise AND to find network |
/32 => 11111111.11111111.11111111.11111111 |
equals |
11000000.10101000.01100100.00011001 <-+
The result of ANDing the destination IP with the /32 netmask is different to the network of this static route.
Therefore, the destination IP 192.168.100.25 is not inside the 192.168.100.0/32 network.
S 192.168.100.0/30 [1/0] via 10.0.0.4, Ethernet1
192.168.100.0 => 11000000.10101000.01100100.00000000 <-+
|
192.168.100.25 => 11000000.10101000.01100100.00011001 |
bitwise AND to find network |
/30 => 11111111.11111111.11111111.11111100 |
equals |
11000000.10101000.01100100.00011000 <-+
S 192.168.100.0/27 [1/0] via 10.0.0.3, Ethernet1
192.168.100.0 => 11000000.10101000.01100100.00000000 <-+
|
192.168.100.25 => 11000000.10101000.01100100.00011001 |
bitwise AND to find network |
/27 => 11111111.11111111.11111111.11100000 |
equals |
11000000.10101000.01100100.00000000 <-+
24 bits of netmask (255.255.255.0):
S 192.168.100.0/24 [1/0] via 10.0.0.2, Ethernet1
192.168.100.0 => 11000000.10101000.01100100.00000000 <-+
|
192.168.100.25 => 11000000.10101000.01100100.00011001 |
bitwise AND to find network |
/24 => 11111111.11111111.11111111.00000000 |
equals |
11000000.10101000.01100100.00000000 <-+
S 192.168.100.0/27 [1/0] via 10.0.0.3, Ethernet1
is the chosen route