Skip to content

Instantly share code, notes, and snippets.

@pebeto
Last active September 25, 2019 18:04
Show Gist options
  • Select an option

  • Save pebeto/99d817f941caced12ce8e6695f0c1862 to your computer and use it in GitHub Desktop.

Select an option

Save pebeto/99d817f941caced12ce8e6695f0c1862 to your computer and use it in GitHub Desktop.

Routing and Switching Essentials Bible 📖

Chapter 1: Routing Concepts

Characteristics of a Network

Network allows us to communicate, collaborate, and interact in ways we never did before. Ther are many key structures and performance-related characteristics referred referred to when discussing networks.

  • Topology - There are physical and logical topologies
  • Speed - Measure of the data rate in b/s of a given link in the network
  • Cost - Indicates the general expense for purchasing of network components, and installation and maintenance of the network
  • Security - Indicates how protected the network is, including the information that is transmitted over the network
  • Availability - Is the likelihood that the network is available for use when it is required
  • Scalability - Indicates how easily the network can accommodate more users and data transmission requirements
  • Reliability - Indicates the dependability of the components that make up the network, such as the routers, switches, PCs, and servers

Routers Are Computers

Most network capable devices require the following components to operate.

  • Central processing unit (CPU)
  • Operating system (OS)
  • Memory and storage (RAM, ROM, NVRAM, Flash, hard drive)

A router is essentially a specialized computer. Unlike a personal computer, a router does not have video adapters or sound card adapters. Instead, routers have specialized ports and network interface cards to interconnect devices to other networks.

  • RAM
    • Running IOS
    • Running configuration file
    • IP routing and ARP tables
    • Packet buffer
  • ROM
    • Bootup Instructions
    • Basic diagnostic software
    • Limited IOS in case the router cannot load the full featured IOS
  • NVRAM
    • Startup configuration file
  • Flash
    • IOS
    • Other system-related files

Packet Forwarding Mechanisms

Routers support three packet-forwarding mechanisms.

  • Process switching - An older packet forwarding mechanism still available for Cisco routers. When a packet arrives on an interface, it is forwarded to the control plane where the CPU matches the destination address with an entry in its routing table, and then determines the exit interface and forwards the packet. This process-switching mechanism is very slow and rearely implemented in modern networks because takes every packet with the same destination address as an independent one

  • Fast switching - This is a common packet forwarding mechanism which uses a fast-switching cache to store next-hop information. When a packet arrives on an interface, it is forwarded to the control plane where the CPU searches for a match in the fast-switching cache. If it is not there, it is process-switched and forwarded to the exit interface. The flow information for the packet is also stored in the fast-switching cache. If another packet going to the same destination arrives on an interface, the next-hop information in the cache is re-used without CPU intervention

  • Cisco Express Forwarding (CEF) - CEF is the most recent and preferred Cisco IOS packet-forwarding mechanism. Like fast switching, CEF builds a Forwarding Information Base (FIB), and an adjacency table. However, the table entries are not packet-triggered like fast switching but change-triggered such as when something changes in the network topology. Therefore, when a network has converged, the FIB and adjacency tables contain all the information a router would have to consider when forwarding a packet. The FIB contains pre-computed reverse lookups, next hop information for routes including the interface and Layer 2 information

Default Gateways

To enable network access, devices must be configured with IP address information to identify the appropriate.

  • IP address - Identifies a unique host on a local network
  • Subnet mask - Identifies with which network subnet the host can communicate
  • Default gateway - Identifies the IP address of the router to send a packet to when the destination is not on the same local network subnet

Note: A router is also usually configured with its own default gateway. This is known as the Gateway of Last Resort.

Device LEDs

Network infrastructure devices commonly use multiple LED indicators to provide a quick status view. These LEDs are generally lit green when the switch is functioning normally and lit amber when there is a malfunction.

Cisco ISRs use various LED indicators to provide status information.

  • Gigabit Ethernet Port
    • S (Speed)
      • 1 blink + pause = Por toperating at 10 MB/s
      • 2 blink + pause = Por toperating at 100 MB/s
      • 3 blink + pause = Por toperating at 1000 MB/s
    • L (Link)
      • Green = Link is active
      • Off = Link is inactive
  • Console
    • EN
      • Green = Port is active
      • Off = Port is inactive
  • USB
    • EN
      • Green = Port is active
      • Off = Port is inactive

Configure an IPv4 Loopback Interface

The loopback interface is a logical interface internal to the router. It is not assigned to a physical port and can therefore never be connected to any other device. It is considered a software interface that is automatically placed in an "up" state, as long as the router is functioning.

The loopback interface is useful in testing and managing a Cisco IOS device because it ensures that at least one interface will always be available.

By enabling a loopback interface, the router will use the always available loopback interface address for identification, rather than an IP address assigned to a physical port that may go down.

Enabling and assigning a loopback address is simple:

  • interface loopback #number
  • ip address #ip-address #subnet-mask
  • exit

Multiple loopback interfaces can be enabled on a router. The IPv4 address for each loopback interface must be unique and unused by any other interface.

Verify Interface Settings

There are several show commands that can be used to verify the operation and configuration of an interface.

  • show ip[v6] interface brief - Displays a summary for all interfaces including the IPv4 address of the interface and current operational status
  • show ip[v6] route - Displays the contents of the IPv4 routing table stored in RAM. In Cisco IOS 15, active interfaces should appear in the routing table with two related entries identified by the code 'C' (Connected) or 'L' (Local)
  • show running-config interface #interface-id - Displays the commands configured on the specified interface

Filter Show Command Output

Another very useful feature that improves the user experience in the command-line interface (CLI) is the filtering of show output. Filtering commands can be used to display specific sections of output. To enable the filtering command, enter a pipe (|) character after the show command and then enter a filtering parameter and a filtering expression.

The filtering parameters that can be configured after the pipe include:

  • section - Shows entire section that starts with the filtering expression
  • include - Includes all output lines that match the filtering expression
  • exclude - Excludes al loutput lines that match the filtering expression
  • begin - Shows all the output lines from a certain point, starting with the line that matches the filtering expression

Note: Output filters can be used in combination with any show command.

Routing Decisions

A primary function of a router is to determine the best path to use to send packets. To determine the best path, the router searches its routing table for a network address that matches the destination IP address of the packet.

The routing table search results in one of three path determinations:

  • Directly connected network - If the destination IP address of the packet belongs to a device on a network that is directly connected to one of the interfaces of the router, the packet is forwarded directly to the destination device
  • Remote network - If the destination IP address of the packet belongs to a remote network, then the packet is forwarded to another router
  • No route determined - If the destination IP address of the packet does not belong to either a connected or remote network, the router determines if there is a Gateway of Last Resort available. If there is a default route, the packet is forwarded to him. If the router does not have a default route, then the packet is discarded

Best Path

The best path is selected by a routing protocol based on the value or metric it uses to determine the distance to reach a network. A metric is the quantitative value used to measure the distance to a given network. The best path to a network is the path with the lowest metric.

Dynamic routing protocols typically use their own rules and metrics to build and update routing tables. The routing algorithm generates a value, or a metric, for each path through the network. Metrics can be based on either a single characteristic or several characteristics of a path. Some routing protocols can base route selection on multiple metrics, combining them into a single metric.

The following lists some dynamic protocols and the metrics they use:

  • Routing Information Protocol (RIP) - Hop count
  • Open Shortest Path First (OSPF) - Cisco's cost based on cumulative bandwidth from source to destination
  • Enhanced Interior Gateway Routing Protocol (EIGRP) - Bandwidth, delay, load, reliability

Load Balancing

When a router has two or more paths to a destination with equal cost metrics, then the router forwards the packets using both paths equally. This is called equal cost load balancing. The routing table contains the single destination network, but has multiple exit interfaces, one for each equal cost path. The router forwards packets using the multiple exit interfaces listed in the routing table.

If configured correctly, load balancing can increase the effectiveness and performance of the network. Equal cost load balancing can be configured to use both dynamic routing protocols and static routes.

Note: Only EIGRP supports unequal cost load balancing.

Administrative Distance

Cisco IOS uses what is known as the administrative distance (AD) to determine the route to install into the IP routing table. The AD represents the "trustworthiness" of the route; the lower the AD, the more trustworthy the route source.

Route Source Administrative Distance
Connected 0
Static 1
EIGRP summary route 5
External BGP 20
Internal EIGRP 90
IGRP 100
OSPF 110
IS-IS 115
RIP 120
External EIGRP 170
Internal BGP 200

The Routing Table

The routing table of a router stores information about:

  • Directly connected routes - These routes come from the active router interfaces
  • Remote routes - These are remote networks connected to the other routers

It stores information about directly connected and remote networks in RAM. The routing table contains network or next hop associations.

Routing Table Sources

On a Cisco router, the show ip route command can be used to display the IPv4 routing table of a router.

Entires in the routing table can be added as:

  • Local Route Interfaces - Added when an interface is configured and active
  • Directly Connected Interfaces - Added to the routing table when an interface is configured and active
  • Static Routes - Added when a route is manually configured and the exit interface is active
  • Dynamic Routing Protocol - Added when routing protocols that dynamically learn about the network, such as EIGRP or OSPF, are implemented and networks are identified

The sources of the routing table entires are identified by a code. The code identifies how the route was learned.

  • L - Identifies the address assigned to a router's interface
  • C - Identifies a directly connected network
  • S - Identifies a static route created to reach a specific network
  • D - Identifies a dynamically learned network from another router using EIGRP
  • O - Identifies a dynamically learned network from another router using OSPF
  • R - Identifies a dynamically learned network from another router using RIP

Remote Network Routing Entries

The entry identifies the following information:

  1. Route source - Identifies how the route was learned
  2. Destination network - Identifies the address of the remote network
  3. Administrative distance - Identifies the trustworthiness of the route source
  4. Metric - Identifies the value assigned to reach the remote network
  5. Next-hop - Identifies the IPv4 address of the next router to forward the packet to
  6. Route timestamp - Identifies how much time has passed since the route was learned
  7. Outgoing interface - Identifies the exit interface to use to forward a packet toward the final destination
-1-  -----2----- -3- ---4---         -------5------- ---6----    -----7-----
 D   10.1.1.0/24 [90/2170112]    via 209.165.200.226 00:00:05,   Serial0/0/0

Directly Connected Routing Table Entries

The routing table entry for directly connected interfaces is simpler than the entries for remote networks. The entries contain the following information:

  1. Route source - Identifies how the route was learned. Directly connected interfaces have two route source codes
    • 'C' identifies a directly connected network
    • 'L' identifies the IPv4 address assigned to the router's interface
  2. Destination network - The address of the remote network
  3. Outgoing Interface - Identifies the exit interface to use when forwarding packets to the destination network
-1-  -----------------2-------------------   --------3---------
 C   192.168.10.0/24 is directly connected,  GigabitEthernet0/0
 L   192.168.10.1/32 is directly connected,  GigabitEthernet0/0

IPv4 Routing Protocols

A router running a dynamic routing protocol does not only make a best path determination to a network, it also determines a new best path if the initial path becomes unusable (or if the topology changes). For these reasons, dynamic routing protocols hav ean advantage over static routes. Routers that use dynamic routing protocols automatically share routing information with other routers and compensate for any topology changes without involving the network administrator.

Cisco routers can support a variety of dynamic IPv4 routing protocols including:

  • EIGRP - Enhanced Interior Gateway Routing Protocol
  • OSPF - Open Shortest Path First
  • IS-IS - Intermediate System-to-Intermediate System
  • RIP - Routing Information Protocol

IPv6 Routing Protocols

ISR devices suppor tdynamic routing protocols including:

  • RIPng (RIP next generation)
  • OSPFv3
  • EIGRP for IPv6

Support for dynamic IPv6 routing protocols is dependent on hardware and IOS version. Most of the modifications in the routing protocols are to support the longer IPv6 addresses and different header structures.

To enable IPv6 routers to forward traffic, you must configure the ipv6 unicast-routing command.

Chapter 2: Static Routing

Why Use Static Routing?

Static routing provides some advantages over dynamic routing, including:

  • Static routes are not advertised over the network, resulting in better security
  • Static routes use less bandwidth than dynamic routing protocols, no CPU cycles are used to calculate and communicate routes
  • The path a static route uses to send data is known

Static routing has the following disadvantages:

  • Initial configuration and maintenance is time-consuming
  • Configuration is error-prone, especially in large networks
  • Administrator intervention is required to maintain changing route information
  • Doest not scale well with growing networks; maintenance becomes cumbersome
  • Requires complete knowledge of the whole network for proper implementation

When to Use Static Routes

Static routing has three primary uses:

  • Providing ease of routing table maintenance in smaller networks that are not expected to grow significantly
  • Routing to and from stub networks. A stub network is a network accessed by a single route, and the router has only one neighbor
  • Using a single default route to represent a path to any network that does not have a more specific match with another route in the routing table

Static Route Applications

Static routes are most often used to connect to a specific network or to provide a Gateway of Last Resort for a stub network. They can also be used to:

  • Reduce the number of routes advertised by summarizing several contiguous networks as one static route
  • Create a backup route in case a primary route link fails

Standard Static Route

Both IPv4 and IPv6 support the configuration of static routes. Static routes are useful when connecting to a specific remote network.

Default Static Route

A default static route is simply a static route with 0.0.0.0/0 as the destination IPv4 address. Configuring a default static route creates a Gateway of Last Resort.

Default static routes are used:

  • When no other routes in the routing table match the packet destination IP address
  • When a router has only one other router to which it is connected. In this situation, the router is known as a stub router

Summary Static Route

To reduce the number of routing table entries, multiple static routes can be summarized into a single static route if:

  • The destination networks are contiguous and can be summarized into a single network address
  • The multiple static routes all use the same exit interface or next-hop IP address

Floating Static Route

Floating static routes are static routes that are used to provide a backup path to a primary static or dynamic route, in th eevent of a link failure. The floating static route is only used when the primary route is not available. The floating static route is configured with a higher administrative distance than the primary route.

ip route Command

Static routes are configured using the ip route global configuration command.

ip route network-address subnet-mask {ip-address | exit intf} {distance}

The following arguments are required to configure static routing:

  • network-address - Destination network address of the remote network to be added to the routing table
  • subnet-mask - Subnet mask of the remote network to be added to the routing table. The subnet mask can be summarized to group networks

One or both of the following parameters must also be used:

  • ip-address - The IP address of the connecting router to use to forward the packet to the remote destination network (next hop)
  • exit-intf - The outgoing interface to use to forward the packet to the next hop

The distance parameter is used to create a floating static route by setting an administrative distance that is higher than a dynamically learned route.

Next-Hop Options

The next hop can be identified by an IP address, exit interface, or both. How the destination is specified creates one of the three following route types:

  • Next-hop route - Only the next-hop IP address is specified
  • Directly connected static route - Only the router exit interface is specified
  • Fully specified static route - The next-hop IP address and exit interface are specified

Default Static Route

A default route is used when no other routes in the routing table match the destination IP address of the packet. In other words, if a more specific match does not exist, then the default route is used as the Gateway of Last Resort.

ip route 0.0.0.0 0.0.0.0 {ip-address | exit-intf}

Default static routes are commonly used when connecting:

  • An edge router to a srevice provider network
  • A stub router (a router with only one upstream neighbor router)

Note: An IPv4 default static route is commonly referred to as a quad-zero route

Floating Static Routes

Floating static routes are static routes that have an administrative distance greater than the administrative distance of another static route or dynamic routes. They are very useful when providing a backup to a primary link.

Configure an IPv4 Floating Static Route

IPv4 floating static routes are configured using the ip route global configuration command and specifying an administrative distance. If no administrative distance is configured, the default value (1) is used.

ALL IPV6 ROUTING CONFIGURATION WAS OMITTED BECAUSE IT'S THE SAME AS ABOVE

Automatically Installed Host Routes

A host route is an IPv4 address with a 32-bit mask or an IPv6 address with a 128-bit mask. There are three ways a host route can be added to the routing table:

  • Automatically installed when an IP address is configured on the router
  • Configured as a static host route
  • Host route automatically obtained through other methods

Configure IPv4 and IPv6 Static Host Routes

A host route can be a manually configured static route to direct traffic to a specific destination device, such as an authentication server. The static route uses a destination IP address and a 255.255.255.255(/32) mask for IPv4 host routes and a /128 prefix length for IPv6 host routes. Static routes are marked with "S" in the output of the routing table. An IPv4 and an IPv6 host route is configured on the BRANCH router to access the server in the topology.

For IPv6 static routes, the next-hop address can be the link-local address of the adjacent router. However, you must specify an interface type and an interface number when using a link-local address as the next hop.

Chapter 3: Dynamic Routing

Dynamic Routing Protocol Components

The main components of dynamic routing protocols include:

  • Data structures - Routing protocols typically use tables or databases for its operations. This information is kept in RAM
  • Routing protocol messages - Routing protocols use various types of messages to discover neighboring routers, exchange routing information, and other tasks to learn and maintain accurate information about the network
  • Algorithm - Routing protocols use algorithms for facilitating routing information and for best path determination

Routing protocols allow routers to dynamically share information about remote networks and automatically offer this information to their own routing tables.

Dynamic Protocols Uses

  • Dynamic routing protocols help the network administrator manage the time-consuming and exacting process of configuring and maintaining static routes
  • Dynamic routing is the best choice for large networks

Dynamic Routing Advantages and Disadvantages

  • Advantages
    • Suitable in all topologies where multiple routers are required
    • Generally independent of the network size
    • Automatically adapts topology to reroute traffic if possible
  • Disadvantages
    • Can be more complex to implement
    • Less secure. Additional configuration settings are required to secure
    • Route depends on the current topology
    • Require additional CPU, RAM, and link bandwidth

Router RIP Configuration Mode

To enable RIP use the router rip command. This command does not directly start the RIP process. Instead, it provides access to the router configuration mode where the RIP routing settings are configured. When enabling RIP, the default version is RIPv1

To disable and eliminate RIP, use the no router rip global configuration command. This command stops the RIP process and erases all existing RIP configurations.

Advertise Networks

To enable RIP routing for a network, use the network #network-address router configuration mode command. Enter the classful network address for each directly connected network. This command:

  • Enables RIP on all interfaces that belong to a specific network. Associated interfaces now both send and receive RIP updates
  • Advertises the specified network in RIP routing updates sent to other routers every 30 seconds

Note: RIPv1 is a classful routing protocol for IPv4. Therefore, if a subnet address is entered, the IOS automatically converts it to the classful network address.

Enable and Verify RIPv2

By default, when a RIP process is configured on a Cisco router, it is running RIPv1. However, even though the router only sends RIPv1 messages, it can interpret both RIPv1 and RIPv2 messages. A RIPv1 router ignores the RIPv2 fields in the route entry.

Use the version 2 router configuration mode command to enable RIPv2. The RIP process now includes the subnet mask in all updates, making RIPv2 a classless routing protocol.

Note: Configuring version 1 enables RIPv1 only, while configuring no version return the router to the default setting of sending version1 updates but listening for versoin 1 and version 2 updates.

Disable Auto Summarization

RIPv2 automatically summarizes networks at major network boundaries by default, just like RIPv1

To modify the default RIPv2 behavior of automatic summarization, use the no auto-summary router configuration mode command. This command has no effect when using RIPv1. When automatic summarization has been disabled, RIPv2 no longer summarizes networks to their calssful address at boundary routers. RIPv2 no longer summarizes networks to their classful address at boundary routers. RIPv2 now includes all subnets and their appropriate masks in its routing updates. The show ip protocols now states that "automatic network summarization is not in effect".

Note: RIPv2 must be enabled before automatic summarization is disabled.

Configure Passive Interfaces

By default, RIP updates are forwarded out all RIP-enabled interfaces. However, RIP updates really only need to be sent out interfaces that are connected to other RIPenabled routers.

Sending out unneeded updates on a LAN impacts the network in three ways:

  • Wasted Bandwidth - Bandwidth is used to transport unnecessary updates. Because RIP updates are either broadcasted or multicasted, sitches also forward the updates out all ports
  • Wasted Resources - All devices on the LAN must process the update up to the transport layers, at which point the devices will discard the update
  • Security Risk - Advertising updates on a broadcast network is a security risk. RIP updates can be intercepted with packet sniffing software. Routing updates can be modified and sent back to the router, corrupting the routing table with false metrics that misdirect traffic

Use the passive-interface router configuration command to prevent the transmission of routing updates through a router interface, but still allow that network to be advertised to other routers.

Note: All routing protocols support the passive-interface #interface command.

As an alternative, all interfaces can be made passive using the passive-interface default command. Interfaces that should not be passive can be re-enabled using the no passive-interface command.

Propagate a Default Route

To provide internet connectivity to all other networks in the RIP routing domain, the default static route needs to be advertised to all other routers that use the dynamic routing protocol.

To propagate a default route in RIP, the edge router must be configured with:

  • A default static route using the ip route 0.0.0.0 0.0.0.0 command
  • The default-information originate router configuration command. This instructs router to originate default information, by propagating the static default route in RIP updates

Routing Table Terms

The Cisco IP routing table is not a flat database. The routing table is actually a hierarcihcal structure that is used to speed up the lookup process when locating routes and forwarding packets. Within this structure, the hierarchy includes several levels.

Routes are discussed in terms of:

  • Ultimate route
  • Level 1 route
  • Level 1 parent route
  • Level 2 child routes

Ultimate Route

An ultimate route is a routing table entry that contains either a next-hop IPv4 address or an exit interface. Directly connected, dynamically learned, and local routes are ultimate routes.

Level 1 Route

A level 1 route is a route with a subnet mask equal to or less than the classful mask of the network address. Therefore, a level 1 route can be a:

  • Network route - A network route that has a subnet mask equal to that of the classful mask
  • Supernet route - A supernet route is a network address with a mask less than the classful mask, for example, a summary address
  • Default route - A default route is a static route with the address 0.0.0.0/0

The source of the level 1 route can be a directly connected network, static route, or a dynamic routing protocol.

Level 1 Parent Route

A parent route is a level 1 network route that is subnetted. A parent route can never be an ultimate route.

Level 2 Child Route

A level 2 child route is a route that is a subnet of a classful network address.

Like a level 1 route, the source of a level 2 route can be a directly connected network, a static route, or a dynamically learned route. Level 2 child routes are also ultimate routes.

Route Lookup Process

When a packet arrives on a router interface ,the router examines the IPv4 header, identifies the destination IPv4 address, and proceeds through the router lookup process. The router examines level 1 network routes for the best match with the destination address of the IPv4 packet:

  1. If the best match is a level 1 ultimate route, then this route is used to forward the packet
  2. If the best match is a level 1 parent route, proceed to the next step
  3. If there is a match with a level 2 child route, that subnet is used to forward the packet
  4. If there is not a match with any of the level 2 child routes, proceed to the next step
  5. If there is now alesser match with a level 1 supernet or default routes, the router uses that route to forward the packet
  6. if there is not a match with any route in th erouting table, the router drops the packet

Note: A route referencing only a next-hop IP address and not an exit interface, must be resolved to a route with an exit interface, if Cisco Express Forwarding (CEF) is not being used. Without CEF, a recursive lookup is performed on th enext-hop IP address until the route is resolved to an exit interface. CEF is enabled by default.

Best Route = Longest Match

The best match is the route in the routing table that has the most number of far left matching bits with the destination IPv4 address of the packet. The route with th egreates number of equivalent far left bits, or the longest match, is alwasy the preferred route.

ALL IPV6 ROUTING CONFIGURATION WAS OMITTED BECAUSE IT'S THE SAME AS ABOVE
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment