A routing table is a data structure in a router or host that maps destination network prefixes to next-hop addresses and interfaces. Longest prefix match determines which route applies. Routes come from static configuration, DHCP (default route), or dynamic protocols (BGP, OSPF). An empty routing table means no connectivity.
The routing table stores network reachability information: which destination prefixes can be reached via which next-hop routers and interfaces. When a packet arrives, the router performs longest prefix match – the most specific matching route wins. A route to 10.1.2.0/24 is preferred over 10.1.0.0/16 for destination 10.1.2.5. Routes have metrics (cost/preference) to choose between multiple paths. Static routes are manually configured and do not adapt to failures. Dynamic routing protocols (OSPF for intra-AS, BGP for inter-AS) populate routes automatically and converge around link failures. The default route (0.0.0.0/0) matches everything – it is used when no more specific route exists. Linux maintains multiple routing tables (main, local, custom) selected by policy routing rules.
Subnet
A subnet is a logical division of an IP network defined by a subnet mask (e.g., /24 = 255.255.255.0). Hosts within a subnet communicate directly via ARP without routing. Hosts in different subnets must send traffic through a router. Subnetting reduces broadcast domains and enables hierarchical IP allocation.
Gateway (Default Gateway)
A default gateway is the router a host sends packets to when the destination is not on the local subnet. Every host needs a default gateway to reach the internet or other networks. If the gateway is unreachable, all off-subnet communication fails – even if the host has a valid IP and DNS.
BGP Peering
BGP peering is a TCP session on port 179 between two routers that exchange routing information. eBGP peers are in different autonomous systems (inter-provider). iBGP peers are in the same AS (intra-network). Peering requires explicit configuration on both sides – BGP does not auto-discover neighbors.