ptg29743230
380 CCNA 200-301 Official Cert Guide, Volume 1
Example 16-3 shows the configuration of a couple of sample static routes. In particular,
it shows routes on Router R1 in Figure 16-12, for the two subnets on the right side of the
figure.
A
.1
.9
G0/0
.9
.2
B
G0/0
Subnet 172.16.1.0/24
Subnet 172.16.4.0/24
Subnet
172.16.2
.0/24
.9
.3
C
G0/0
Subnet
172.16.3
.0/24
Subnet 172.16.5.0/24
R2
.1
.1
.2
.3
S0/0/0
S0/0/1
G0/1/0
G0/0/0
R1
R3
Figure 16-12
Sample Network Used in Static Route Configuration Examples
Example 16-3
Static Routes Added to R1
ip route 172.16.2.0 255.255.255.0 S0/0/0
ip route 172.16.3.0 255.255.255.0 172.16.5.3
The two example ip route commands show the two different styles of forwarding instruc-
tions. The first command shows subnet 172.16.2.0, mask 255.255.255.0, which sits on a LAN
near Router R2. That same first command lists R1’s S0/0/0 interface as the outgoing interface.
This route basically states: To send packets to the subnet off Router R2, send them out my
own local S0/0/0 interface (which happens to connect to R2).
The second route has the same kind of logic, except for using different forwarding instruc-
tions. Instead of referencing R1’s outgoing interface, it instead lists the neighboring router’s IP
address on the WAN link as the next-hop router. This route basically says this: To send pack-
ets to the subnet off Router R3, send them to R3—specifically, R3’s WAN IP address next.
The routes created by these two ip route commands actually look a little different in the IP
routing table compared to each other. Both are static routes. However, the route that used
the outgoing interface configuration is also noted as a connected route; this is just a quirk of
the output of the show ip route command.
Example 16-4 lists these two routes using the show ip route static command. This command
lists the details of static routes only, but it also lists a few statistics about all IPv4 routes. For
example, the example shows two lines, for the two static routes configured in Example 16-4,
but statistics state that this router has routes for eight subnets.
Example 16-4
Static Routes Added to R1
R1# show ip route static
Codes: L - local, C - connected, S - static, R - RIP, M - mobile, B - BGP
! lines omitted for brevity
Gateway of last resort is not set
Technet24
||||||||||||||||||||
||||||||||||||||||||
ptg29743230
16
Chapter 16: Configuring IPv4 Addresses and Static Routes 381
172.16.0.0/16 is variably subnetted, 8 subnets, 2 masks
S 172.16.2.0/24 is directly connected, Serial0/0/0
S 172.16.3.0/24 [1/0] via 172.16.5.3
IOS adds and removes these static routes dynamically over time, based on whether the out-
going interface is working or not. For example, in this case, if R1’s S0/0/0 interface fails, R1
removes the static route to 172.16.2.0/24 from the IPv4 routing table. Later, when the inter-
face comes up again, IOS adds the route back to the routing table.
Note that most sites use a dynamic routing protocol to learn all the routes to remote subnets
rather than using static routes. However, when not using a dynamic routing protocol, the
engineer would need to configure static routes to each subnet on each router. For example,
if the routers had only the configuration shown in the examples so far, PC A (from Figure
16-12) would not be able to receive packets back from PC B because Router R2 does not
have a route for PC A’s subnet. R2 would need static routes for other subnets, as would R3.
Finally, note that static routes that will send packets out an Ethernet interface—LAN or
WAN—should use the next-hop IP address option on the ip address command, as shown in
Example 16-4. Routers expect their Ethernet interfaces to be able to reach any number of
other IP addresses in the connected subnet. Referencing the next-hop router identifies the
specific device in the connected subnet, while referencing the local router’s outgoing inter-
face does not identify the specific neighboring router.
Do'stlaringiz bilan baham: