02 - Linux ITNSA - Networking - Routing
02 - Linux ITNSA - Networking - Routing
● Class A: 0.0.0.0/255.0.0.0
● Class B: 128.0.0.0/255.255.0.0
● Class C: 192.0.0.0/255.255.255.0
Original classes of networks and subnets did not scale well. Networks which did not fit in a class B were often
given a class A. This led to IP addresses going to waste and the creation of CIDR (Classless Inter-Domain
Routing) which uses a numbered bitmask instead of the class bitmask.
Classless Inter-Domain Routing (CIDR)
CIDR network netmasks are more Subnet Mask CIDR Subnet Mask CIDR
flexible, and they do not have to end 255.128.0.0 /9 255.255.240.0 /20
255.192.0.0 /10
on "nibble" boundaries. 255.255.248.0 /21
255.224.0.0 /11 255.255.252.0 /22
255.240.0.0 /12 255.255.254.0 /23
255.248.0.0 /13 255.255.255.0 /24
255.252.0.0 /14 255.255.255.128 /25
255.254.0.0 /15 255.255.255.192 /26
255.255.0.0 /16 255.255.255.224 /27
255.255.128.0 /17 255.255.255.240 /28
255.255.192.0 /18 255.255.255.248 /29
255.255.224.0 /19 255.255.255.252 /30
Command IP Cheat Sheet
ip queries
neigh Show neighbour objects; also known as the ARP table for IPv4
neigh replace Replace, or adds if not defined, an entry to the ARP table
net.ipv4.ip_forward=1
○ # sysctl -p
Lab
Border Gateway Protocol (BGP) is the postal service of the Internet. When someone drops a
letter into a mailbox, the Postal Service processes that piece of mail and chooses a fast,
efficient route to deliver that letter to its recipient. Similarly, when someone submits data via
the Internet, BGP is responsible for looking at all of the available paths that data could travel
and picking the best route, which usually means hopping between autonomous systems
(https://www.cloudflare.com/learning/security/glossary/what-is-bgp/)
How does BGP Work ?
● BGP in networking is based on TCP/IP. It operates on the OSI Transport Layer (Layer 4) to
control the Network Layer (Layer 3).
● Using Autonomous System (AS) Number as router identity
● Each router maintains a routing table controlling how packets are directed.
Lab
BGP on Debian
● Install FRR (https://frrouting.org/)
○ # apt install frr
● Enable BGP Daemon
○ # vim /etc/frr/daemons
bgpd=yes
# vtysh
Command
write memory
Show running-config
show ip route
vrrp_instance VI_1 {
state MASTER
interface enp0s8
virtual_router_id 10
nopreempt
priority 101
advert_int 1
authentication {
auth_type PASS
auth_pass 1111
}
virtual_ipaddress {
10.99.99.252
}
}
Keepalived Backup on Debian
● Install keepalive
○ # apt install keepalived
● Configure Keepalive
○ # vim /etc/keepalived/keepalived.conf
global_defs {
}
vrrp_instance VI_1 {
state BACKUP
interface enp0s8
virtual_router_id 10
nopreempt
priority 101
advert_int 1
authentication {
auth_type PASS
auth_pass 1111
}
virtual_ipaddress {
10.99.99.252
}
}