venerdì 24 giugno 2011

Static Routing & CDP

The figure shows the topology used in this section:

 
Examing Router interfaces

The status of each interface can be examined by using several commands:
  • show interfaces
  • show ip interface brief
  • show running-config



Notice that the interface is administratively down and the line protocol is down. Administratively down means that the interface is currently in the shutdown mode, or turned off. Line protocol is down means, in this case, that the interface is not receiving a carrier signal from a switch or the hub. This condition may also be due to the fact that the interface is in shutdown mode.

In generale per aggiungere o rimuovere una route direttamente connessa (quindi indicata dal comando show ip route con la lettera C) si deve semplicemente abilitare/disabilitare l'interfaccia seriale o ethernet e la route verrà aggiunta/rimossa nella routing table. Si può verificare ciò con il comando show ip route (dopo che l'interfaccia in questione è stata attivata/disattivata) oppure anche con il comando debug ip routing, vedi figura:


Per rimuovere il debug: undebug ip routing oppure undebug all. Introduciamo adesso il concetto delle static route. Supponendo di aver assegnato tutti gli ip a tutte le interfacce e dispositivi come nella prima figura di questo post, avremo le seguenti routing table per i router R1, R2 e R3:


Ogni router conosce le strade per le network direttamente connesse... Ma come fare se per esempio PC1 intende "parlare" con PC3 o PC2 (o viceversa)? I 3 router non conoscono le strade per permettere tale comunicazione. Prima di risolvere questa questione introduciamo il Cisco Discovery Protocol.

Cisco Discovery Protocol (CDP)

Cisco Discovery Protocol (CDP) is a powerful network monitoring and troubleshooting tool. CDP is an information-gathering tool used by network administrators to get information about directly connected Cisco devices. CDP is a Cisco proprietary tool. By default, each Cisco device sends periodic messages, which are known as CDP advertisements, to directly connected Cisco devices. These advertisements contain information such as the types of devices that are connected, the router interfaces they are connected to, the interfaces used to make the connections, and the model numbers of the devices. CDP can be used as a network discovery tool, helping you to build a logical topology of a network when such documentation is missing or lacking in detail. Familiarity with the general concept of neighbors is important for understanding CDP. CDP operates at Layer 2 only. Therefore, CDP neighbors are Cisco devices that are directly connected physically and share the same data link. Prendendo in esame sempre la prima figura di questo post avremo i seguenti neighbors:

  • R1 and S1 are CDP neighbors.
  • R1 and R2 are CDP neighbors.
  • R2 and S2 are CDP neighbors.
  • R2 and R3 are CDP neighbors.
  • R3 and S3 are CDP neighbors.

The switches are not neighbors to the routers at Layer 3, because the switches are operating at Layer 2 only. However, the switches are Layer 2 neighbors to their directly connected routers. Examine the output from the show cdp neighbors and show cdp neighbors detail commands in the figure:


Notice that R3 has gathered some detailed information about R2 and the switch connected to the Fast Ethernet interface on R3. When a Cisco device boots up, CDP starts up by default. CDP automatically discovers neighboring Cisco devices running CDP, regardless of which protocol or suites are running. CDP exchanges hardware and software device information with its directly connected CDP neighbors.

CDP be a security risk. If you need to disable CDP globally, for the entire device, use this command:

Router(config)#no cdp run

If you want to use CDP but need to stop CDP advertisements on a particular interface, use this command:

Router(config-if)#no cdp enable

Static Routes with "Next Hop" Addresses

Torniamo adesso alla questione in sospeso, introducendo le static routes. Static routes are commonly used when routing from a network to a stub network. A stub network is a network accessed by a single route. For an example, see the figure. Here we see that any network attached to R1 would only have one way to reach other destinations, whether to networks attached to R2 or to destinations beyond R2. Therefore, network 172.16.3.0 is a stub network and R1 is a stub router.


The command for configuring a static route is ip route

Router(config)#ip route network-address subnet-mask {ip-address | exit-interface }

The following parameters are used:

  • 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 modified to summarize a group of networks.

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

  • ip-address (or Next-hop) - Commonly referred to as the next-hop router's IP address
  • exit-interface - Outgoing interface that would be used in forwarding packets to the destination network

Proviamo adesso a risolvere il problema in sospeso, cioè il fatto che PC1 voglia comunicare con PC2 o PC3. Sappiamo che R1 non conosce le network 192.168.1.0/24; 192.168.2.0/24 e 172.16.1.0/24. First, enable debug ip routing to have the IOS display a message when the new route is added to the routing table. Then, use the ip route command to configure static routes on R1 for each of these networks:

R1#debug ip routing
R1#conf t
R1(config)#ip route 172.16.1.0 255.255.255.0 172.16.2.2


Let's examine each element in this output:

  • ip route - Static route command
  • 172.16.1.0 - Network address of remote network
  • 255.255.255.0 - Subnet mask of remote network
  • 172.16.2.2 - Serial 0/0/0 interface IP address on R2, which is the "next-hop" to this network

Notice in the figure that entering show ip route on R1 shows the new routing table. The static route entry is highlighted.




Let's examine this output:

  • S - Routing table code for static route
  • 172.16.1.0 - Network address for the route
  • /24 - Subnet mask for this route; this is displayed in the line above, known as the parent route, and discussed in Chapter 8
  • [1/0] - Administrative distance and metric for the static route (explained later)
  • via 172.16.2.2 - IP address of the next-hop router, the IP address of R2's Serial 0/0/0 interface

Any packets with a destination IP address that have the 24 left-most bits matching 172.16.1.0 will use this route. The commands to configure the routes for the other two remote networks are shown in the figure. Notice that all three static routes configured on R1 have the same next-hop IP address: 172.16.2.2. Using the topology diagram as a reference, we can see that this is true because packets for all of the remote networks must be forwarded to router R2, the next-hop router.


Ancora però PC1 non riuscirà a pingare ne PC2 e neanche PC3, per il motivo delle Routing Table Principles. In pratica bisogna configuare anche su R3 e R2 le "strade" per il ritorno del pacchetto.


Adesso i tre PC saranno finalmente in grado di pingarsi. 

Recursive Route Lookup
Before any packet is forwarded by a router, the routing table process must determine the exit interface to use to forward the packet. This is known as route resolvability. Let's examine this process by looking at the routing table for R1 (see the figure). 




R1 has a static route for the remote network 192.168.2.0/24, which forwards all packets to the next-hop IP address 172.16.2.2.

S 192.168.2.0/24 [1/0] via 172.16.2.2

Finding a route is only the first step in the lookup process. R1 must determine how to reach the next-hop IP address 172.16.2.2. It will do a second search looking for a match for 172.16.2.2. In this case, the IP address 172.16.2.2 matches the route for the directly connected network 17216.2.0/24.

C 172.16.2.0 is directly connected, Serial0/0/0

The 172.16.2.0 route is a directly connected network with the exit interface Serial 0/0/0. This lookup tells the routing table process that this packet will be forwarded out that interface. Therefore, it actually takes two routing table lookup processes to forward any packet to the 192.168.2.0/24 network. When the router has to perform multiple lookups in the routing table before forwarding a packet, it is performing a process known as a recursive lookup. Every route that references only a next-hop IP address, and does not reference an exit-interface, must have the next-hop IP address resolved using another route in the routing table that has an exit interface. We will see in the next section that static routes can be configured with an exit interface. This means that they do not need to be resolve using another route entry.

Exit interface is Down

Let's consider what would happen if an exit interface goes down. If the static route cannot be resolved to an exit interface, the static route is removed from the routing table. However, the static routes are still in the R1's running configuration. If the interface comes back up (is enabled again with no shutdown), the IOS routing table process will reinstall these static routes back into the routing table.

Static Routes with an Exit Interface

Let's investigate another way to configure the same static routes. Currently, R1's static route for the 192.168.2.0/24 network is configured with the next-hop IP address of 172.16.2.2. In the running configuration, note the following line:

ip route 192.168.2.0 255.255.255.0 172.16.2.2

However, most static routes can be configured with an exit interface, which allows the routing table to resolve the exit interface in a single search instead of two searches. Let's reconfigure this static route to use an exit interface instead of a next-hop IP address. The first thing to do is to delete the current static route. This is done using the no ip route command.


Next, configure R1's static route to 192.168.2.0/24 using the exit interface Serial 0/0/0. Notice that the entry in the routing table no longer refers to the next-hop IP address but refers directly to the exit interface. This exit interface is the same one that the static route was resolved to when it used the next-hop IP address.

S 192.168.2.0/24 is directly connected, Serial0/0/0


Now, when the routing table process has a match for a packet and this static route, it will be able to resolve the route to an exit interface in a single lookup. Static routes that are configured with exit interfaces instead of next-hop IP addresses are ideal for most serial point-to-point networks. Point-to-point networks that use protocols such as HDLC and PPP do not use the next-hop IP address in the packet forwarding process. These types of point-to-point serial links are like pipes. A pipe has only two ends. What enters one end can only have a single destination - the other end of the pipe

Static Routes with Ethernet Interfaces

Sometimes the exit interface is an Ethernet network. We known that the IP packet must be encapsulated into an Ethernet frame with an Ethernet destination MAC address. If the packet should be sent to a next-hop router, the destination MAC address will be the address of the next-hop router's Ethernet interface. In this case, the Ethernet destination MAC address will be matched to the next-hop IP address. If this entry is not in the ARP table, R1 sends an ARP request via its FastEthernet 0/1 interface. The Layer 2 broadcast is requesting that if any device has the IP address 172.16.2.2, it should respond with its MAC address. Because R2's FastEthernet 0/1 interface has the IP address 172.16.2.2, it sends back an ARP reply with the MAC address for that interface.

R1 receives the ARP reply and adds the 172.16.2.2 IP address, and the associated MAC address, to its ARP table. The IP packet is now encapsulated into an Ethernet frame with the destination MAC address found in the ARP table. The Ethernet frame with the encapsulated packet is then sent out the FastEthernet 0/1 interface to router R2.Let's configure a static route with an Ethernet exit interface instead of a next-hop IP address. Change the static route for 192.168.2.0/24 to use an exit interface with this command:

R1(config)#ip route 192.168.2.0 255.255.255.0 fastethernet 0/1

The difference between an Ethernet network and a point-to-point serial network is that a point-to-point network has only one other device on that network - the router at the other end of the link. With Ethernet networks, there may be many different devices sharing the same multi-access network, including hosts and even multiple routers. By only designating the Ethernet exit interface in the static route, the router will not have sufficient information to determine which device is the next-hop device.

R1 knows that the packet needs to be encapsulated in an Ethernet frame and sent out the FastEthernet 0/1 interface. However, R1 does not know the next-hop IP address and therefore it cannot determine the destination MAC address for the Ethernet frame. It is recommended that when the exit interface is an Ethernet network, you do not use only the exit interface in the static route. A possible solutions may be used next hop address and exit interfaces together:

R1(config)#ip route 192.168.2.0 255.255.255.0 fastethernet 0/1 172.16.2.2

The routing table entry for this route would be:

S 192.168.2.0/24 [1/0] via 172.16.2.2 FastEthernet0/1

The routing table process will only need to perform a single lookup to get both the exit interface and the next-hop IP address. For static routes with outbound point-to-point serial networks, it is best to configure static routes with only the exit interface. For point-to-point serial interfaces, the next-hop address in the routing table is never used by the packet delivery procedure, and so it is not needed.

For static routes with outbound Ethernet networks, it is best to configure the static routes with both the next-hop address and the exit-interface.

Summary Static Routes

Creating smaller routing tables makes the routing table lookup process more efficient, because there are fewer routes to search. If one static route can be used instead of multiple static routes, the size of the routing table will be reduced. In many cases, a single static route can be used to represent dozens, hundreds, or even thousands of routes.

We can use a single network address to represent multiple subnets. For example, the networks 10.0.0.0/16, 10.1.0.0/16, 10.2.0.0/16, 10.3.0.0/16, 10.4.0.0/16, 10.5.0.0/16, all the way through 10.255.0.0/16 can be represented by a single network address: 10.0.0.0/8.

Route Summarization

Multiple static routes can be summarized into a single static route if:
  • The destination networks can be summarized into a single network address, and
  • The multiple static routes all use the same exit-interface or next-hop IP address
In our example, R3 has three static routes. All three routes are forwarding traffic out the same Serial0/0/1 interface. The three static routes on R3 are:

ip route 172.16.1.0 255.255.255.0 Serial0/0/1
ip route 172.16.2.0 255.255.255.0 Serial0/0/1
ip route 172.16.3.0 255.255.255.0 Serial0/0/1


If possible, we would like to summarize all of these routes into a single static route. 172.16.1.0/24, 172.16.2.0/24 and 172.16.3.0/24 can be summarized to the 172.16.0.0/22 network. Because all three routes use the same exit interface, they can be summarized to the single 172.16.0.0 255.255.252.0 network, and we can create a single summary route.

Calculating a summary route

Here's the process of creating the summary route 172.16.0.0/22, as shown in the figure:

  1. Write out the networks that you want to summarize in binary.
  2. To find the subnet mask for summarization, start with the left-most bit. 
  3. Work your way to the right, finding all the bits that match consecutively.
  4. When you find a column of bits that do not match, stop. You are at the summary boundary. 
  5. Now, count the number of left-most matching bits, which in our example is 22. This number becomes your subnet mask for the summarized route, /22 or 255.255.252.0
  6. To find the network address for summarization, copy the matching 22 bits and add all 0 bits to the end to make 32 bits.


By following these steps, we can discover that the three static routes on R3 can be summarized into a single static route, using the summary network address of 172.16.0.0 255.255.252.0:

ip route 172.16.0.0 255.255.252.0 Serial0/0/1

Default Static Route

The default static route matches all packets

A default static route is a route that will match all packets. Default static routes are used:
  • When no other routes in the routing table match the packet's destination IP address. In other words, when a more specific match does not exist. A common use is when connecting a company's edge router to the ISP network.
  • When a router has only one other router to which it is connected. This condition is known as a stub router.
The syntax for a default static route is similar to any other static route, except that the network address is 0.0.0.0 and the subnet mask is 0.0.0.0:

Router(config)#ip route 0.0.0.0 0.0.0.0 [exit-interface | ip-address ]

The 0.0.0.0 0.0.0.0 network address and mask is called a "quad-zero" route. R1 is a stub router. It is only connected to R2. Currently R1 has three static routes, which are used to reach all of the remote networks in our topology. All three static routes have the exit interface Serial 0/0/0, forwarding packets to the next-hop router R2. R1 is an ideal candidate to have all of its static routes replaced by a single default route. Configure the single default static route using the same Serial 0/0/0 exit interface as the three previous static routes:

R1(config)#ip route 0.0.0.0 0.0.0.0 serial 0/0/0

Verify the change to the routing table with the show ip route command:

S* 0.0.0.0/0 is directly connected, Serial0/0/0

Note the * or asterisk next to the S. As you can see from the Codes table in the figure, the asterisk indicates that this static route is a candidate default route. That is why it is called a "default static" route. The key to this configuration is the /0 mask. We previously said that it is the subnet mask in the routing table that determines how many bits must match between the destination IP address of the packet and the route in the routing table. A /0 mask indicates that zero or no bits are needed to match. As long as a more specific match doesn't exist, the default static route will match all packets.




Nessun commento:

Posta un commento