--- id: 11. Routing Fundamentals aliases: [] tags: - Cisco - routers --- # Routing Fundamentals ## What is routing ? - **Routing** is the process taht routers use to determine the path that IP packets should take over a network to reach their destination. - Routers store routes to all of their known destinations in a routing table - When routers receive packets, they look in the **routing table** to find the best route to forward that packet. There are two main rounting methods (methods that routers use to learn routes): - **Dynamic Routing**: - Routers use [[dynamic routing protocols]] (ie. [[OSPF]]) to share routing information with each other automatically and build their routing tables. - **Static Routing**: - A network engineer/admin manually configures routes on the router. A route tells the router: to send a packet to destination X, you should send the [[packet]] to next-hop Y. next-hop= the next router in the path to the destination - or if the destination is directly connected to the router, send the packet directly to the destination. - or if the destination is the router/s own [[ip address]], receive the packet for yourself (don't forward it) [[WAN]] Wide Area Network = a network that extends over a large geographical area ## Routing table ### R1 Pre-configuration (IP address) [[08. IPv4 Addressing (Part 2)]] ### Show routing table On cisco router you can show routing table with this command ```cisco R1#show ip route ``` There are two main Output for this command: - **Codes** - **Routes** #### Codes The Codes legend in the output of show ip route lists the different protocols which routers can use to learn routes. - L - Local - A route to the actual IP address configured on the interface. (with a /32 netmask) - C - connected - A route to the network the interface is connected to. (with the actual netmask configured on the interface) #### Routes When you configure an IP address on an interface and enable it with no shutdown, 2 routes (per interface) will automatically be aded to the routing table - a connected route - a local route A connected route is a route to the network the interface is connected to - R1 G0/2 IP = 192.168.1.1/24 - network address = 192.168.1.0/24 - It provides a route to all hosts in that network (192.168.1.2 -> 192.168.1.254) - R1 knows "if i need to send a packet to any host in the 192.168.1.0/24 network, i should send it out of G0/2" A local route is a route to the exact IP address configured on the interface - A /32 netmask is used to specify the exact IP address of the interface. - /32 means all 32 bits are "fixed", they can't change. - Even though R1's G02 is configured as 192.168.1.1/24 the connected route is to 192.168.1.1/32 - R1 knows "if i receive a packet destined for this IP address, the message is for me" #### Clarification // bold part is fixed **192.168.1**.0/24 **255.255.255**.0 192.168.1.0/24 matches 192.168.1.0 ~ 192.168.1.255 - If R1 receives a packet with a destination in that range, it will send the packet out of G0/2 192.168.1.2 = match -> Send packet out of G0/2 192.168.1.56 = match -> Send packet out of G0/2 192.168.2.56 = no match -> Send the packet using a different route, -> or drop the packet there is no matching route a route matches a packet's destination if the packet's destination IP address is part of the network specified in the route. // bold part is fixed **192.168.1.1**/32 **255.255.255.255** 192.168.1.1/32 matches Only 192.168.1.1 ## Route Selection A packet destined for 192.168.1.1 is matched by both routes: - 192.168.1.0/24 - 192.168.1.1/32 it will choose the most **specific matching** route. - the route to 192.168.1.0/24 includes 256 different IP addresses (192.168.1.0 - 192.168.1.255) - the route to 192.168.1.1/32 includes only 1 IP addresses (192.168.1.1) - This route is **more specific** *Most specific matching route = the matching route with the longest prefix length* ### Cisco router lines ```cisco 192.168.1.0/24 is variably subnetted, 2 subnets, 2 masks 192.168.1.0/24 is directly connected, GigabitEthernet0.2 192.168.1.1/32 is directly connected, GigabitEthernet0.2 ``` these three lines are not routes, they mean the followong: - 192.168.1.0/24 is variably subnetted, 2 subnets, 2 masks - In the routing table, there are two routes to subnets that fit within the 192.168.1.0.24 Class C network with two different netmask (24/32). ## Review - What is routing? - The routing table on a Cisco [[router]] - Connected and local Routes - Routing fundamentals (route selection)