Cisco静态路由实验:
-----------------------------------------------
实验拓朴如下:
R1 F0/0 <----> VPCS V0/1
R1 S1/0 <----> R2 S0/0
R2 S0/1 <----> R3 S1/0
R3 F0/0 <----> VPCS V0/2
-----------------------------------------------
通过配置静态路由,确保能从VPCS1 Ping通VPCS2
Router1配置如下:
R1#show run
Building configuration...
Current configuration : 1267 bytes
!
version 12.4
service timestamps debug datetime msec
service timestamps log datetime msec
service password-encryption
!
hostname R1
!
boot-start-marker
boot-end-marker
!
enable secret 5 $1$0Z5T$h011csxL/HhGdQYg27p3w.
enable password 7 00071A150754
!
no aaa new-model
!
resource policy
!
memory-size iomem 5
!
!
ip cef
!
!
!
!
!
!
!
!
!
!
!
!
!
!
!
!
!
!
!
!
!
!
!
interface FastEthernet0/0
ip address 192.168.1.1 255.255.255.0
duplex auto
speed auto
!
interface Serial1/0
ip address 192.168.10.1 255.255.255.0
serial restart-delay 0
no dce-terminal-timing-enable
!
interface Serial1/1
no ip address
shutdown
serial restart-delay 0
no dce-terminal-timing-enable
!
interface Serial1/2
no ip address
shutdown
serial restart-delay 0
no dce-terminal-timing-enable
!
interface Serial1/3
no ip address
shutdown
serial restart-delay 0
no dce-terminal-timing-enable
!
ip http server
no ip http secure-server
ip route 192.168.2.0 255.255.255.0 Serial1/0
ip route 192.168.30.0 255.255.255.0 Serial1/0
!
!
!
!
!
!
control-plane
!
!
!
!
!
!
!
!
!
banner motd ^C Welcome to connect to Router1 ^C
!
line con 0
exec-timeout 0 0
password 7 121A0C041104
logging synchronous
login
line aux 0
line vty 0 4
exec-timeout 0 0
password 7 1511021F0725
login
!
!
end
R1#
Router2配置如下:
R2#show run
Building configuration...
Current configuration : 1225 bytes
!
version 12.4
service timestamps debug datetime msec
service timestamps log datetime msec
service password-encryption
!
hostname R2
!
boot-start-marker
boot-end-marker
!
enable secret 5 $1$mXR4$OAO5nV5rPKbE5jFa4lby90
enable password 7 01100F175804
!
no aaa new-model
!
resource policy
!
memory-size iomem 5
!
!
ip cef
!
!
!
!
!
!
!
!
!
!
!
!
!
!
!
!
!
!
!
!
!
!
!
interface Serial0/0
ip address 192.168.10.2 255.255.255.0
serial restart-delay 0
clock rate 64000
no dce-terminal-timing-enable
!
interface Serial0/1
ip address 192.168.30.1 255.255.255.0
serial restart-delay 0
clock rate 64000
no dce-terminal-timing-enable
!
interface Serial0/2
no ip address
shutdown
serial restart-delay 0
no dce-terminal-timing-enable
!
interface Serial0/3
no ip address
shutdown
serial restart-delay 0
no dce-terminal-timing-enable
!
ip http server
no ip http secure-server
ip route 192.168.1.0 255.255.255.0 Serial0/0
ip route 192.168.2.0 255.255.255.0 Serial0/1
!
!
!
!
!
!
control-plane
!
!
!
!
!
!
!
!
!
banner motd ^C Welcome to connect to Router2 ^C
!
line con 0
exec-timeout 0 0
password 7 01100F175804
logging synchronous
login
line aux 0
line vty 0 4
exec-timeout 0 0
password 7 030752180500
login
!
!
end
R2#
Router3配置如下:
R3#
R3#show run
Building configuration...
Current configuration : 1267 bytes
!
version 12.4
service timestamps debug datetime msec
service timestamps log datetime msec
service password-encryption
!
hostname R3
!
boot-start-marker
boot-end-marker
!
enable secret 5 $1$OO0i$143OCvGvDka4w2md0TM3J.
enable password 7 104D000A0618
!
no aaa new-model
!
resource policy
!
memory-size iomem 5
!
!
ip cef
!
!
!
!
!
!
!
!
!
!
!
!
!
!
!
!
!
!
!
!
!
!
!
interface FastEthernet0/0
ip address 192.168.2.1 255.255.255.0
duplex auto
speed auto
!
interface Serial1/0
ip address 192.168.30.2 255.255.255.0
serial restart-delay 0
no dce-terminal-timing-enable
!
interface Serial1/1
no ip address
shutdown
serial restart-delay 0
no dce-terminal-timing-enable
!
interface Serial1/2
no ip address
shutdown
serial restart-delay 0
no dce-terminal-timing-enable
!
interface Serial1/3
no ip address
shutdown
serial restart-delay 0
no dce-terminal-timing-enable
!
ip http server
no ip http secure-server
ip route 192.168.1.0 255.255.255.0 Serial1/0
ip route 192.168.10.0 255.255.255.0 Serial1/0
!
!
!
!
!
!
control-plane
!
!
!
!
!
!
!
!
!
banner motd ^C Welcome to connect to Router3 ^C
!
line con 0
exec-timeout 0 0
password 7 02050D480809
logging synchronous
login
line aux 0
line vty 0 4
exec-timeout 0 0
password 7 00071A150754
login
!
!
end
R3#
VPCS1和VPCS2配置如下:
NAME IP/CIDR GATEWAY LPORT RPORT
PC1 192.168.1.2/24 192.168.1.1 10001 11100
PC2 192.168.2.2/24 192.168.2.1 10002 11300
VPCS 1 >ping 192.168.2.2
192.168.2.2 icmp_seq=1 time=25.000 ms
192.168.2.2 icmp_seq=2 time=82.000 ms
192.168.2.2 icmp_seq=3 time=43.000 ms
192.168.2.2 icmp_seq=4 time=41.000 ms
192.168.2.2 icmp_seq=5 time=13.000 ms
VPCS 1 >2
VPCS 2 >ping 192.168.1.2
192.168.1.2 icmp_seq=1 time=63.000 ms
192.168.1.2 icmp_seq=2 time=58.000 ms
192.168.1.2 icmp_seq=3 time=44.000 ms
192.168.1.2 icmp_seq=4 time=78.000 ms
192.168.1.2 icmp_seq=5 time=47.000 ms
----------------------------------------------------------------
========================================
========================================
静态路由汇总:
在R3上添加Loopback
R3#show ip interface brief
Interface IP-Address OK? Method Status Protocol
FastEthernet0/0 192.168.2.1 YES manual up up
Serial1/0 192.168.30.2 YES manual up up
Serial1/1 unassigned YES NVRAM administratively down down
Serial1/2 unassigned YES NVRAM administratively down down
Serial1/3 unassigned YES NVRAM administratively down down
Loopback0 30.30.1.1 YES manual up up
Loopback1 30.30.2.1 YES manual up up
Loopback2 30.30.3.1 YES manual up up
R3#
在R1和R2配置静态路由:
R1(config)#ip route 30.30.0.0 255.255.0.0 s1/0
R2(config)#ip route 30.30.0.0 255.255.0.0 s0/1
R2#show ip route
Codes: C - connected, S - static, R - RIP, M - mobile, B - BGP
D - EIGRP, EX - EIGRP external, O - OSPF, IA - OSPF inter area
N1 - OSPF NSSA external type 1, N2 - OSPF NSSA external type 2
E1 - OSPF external type 1, E2 - OSPF external type 2
i - IS-IS, su - IS-IS summary, L1 - IS-IS level-1, L2 - IS-IS level-2
ia - IS-IS inter area, * - candidate default, U - per-user static route
o - ODR, P - periodic downloaded static route
Gateway of last resort is not set
C 192.168.30.0/24 is directly connected, Serial0/1
C 192.168.10.0/24 is directly connected, Serial0/0
S 192.168.1.0/24 is directly connected, Serial0/0
S 192.168.2.0/24 is directly connected, Serial0/1
30.0.0.0/16 is subnetted, 1 subnets
S 30.30.0.0 is directly connected, Serial0/1
R2#
#####################
Cisco静态浮动路由
ip route xxx.xxx.xxx.xxx xxx.xxx.xxx.xxx xxx.xxx.xxx.xxx metric或者ip route xxx.xxx.xxx.xxx xxx.xxx.xxx.xxx interface-name metric命令用来设定静态浮动路由。
静态路由默认的Metric值为1,Metric值越小越优先。
网络拓朴如下:
R1 F0/0 <----> R2 F0/0
R1 F1/0 <----> R2 F1/0
R1与R2通过两条Ethernet连接,当一条链路down,另一条链路会自动启动。
-----------------------------------------------
-----------------------------------------------
Router1配置如下:
R1#show run
Building configuration...
Current configuration : 1002 bytes
!
version 12.4
service timestamps debug datetime msec
service timestamps log datetime msec
ser
hostname R1
!
boot-start-marker
boot-end-marker
!
enable secret 5 $1$uUg4$bl.lLeNvXggFU6NNniuv30
enable password 7 121A0C041104
!
no aaa new-model
!
resource policy
!
memory-size iomem 5
!
!
ip cef
!
!
!
!
!
!
!
!
!
!
!
!
!
!
!
!
!
!
!
!
!
!
!
interface Loopback0
ip address 192.168.3.1 255.255.255.0
!
interface FastEthernet0/0
ip address 192.168.1.1 255.255.255.0
duplex auto
speed auto
!
interface FastEthernet1/0
ip address 192.168.2.1 255.255.255.0
duplex auto
speed auto
!
ip http server
no ip http secure-server
ip route 192.168.4.0 255.255.255.0 192.168.1.2
ip route 192.168.4.0 255.255.255.0 192.168.2.2 50
!
!
!
!
!
!
control-plane
!
!
!
!
!
!
!
!
!
banner motd ^C Welcome to connect to Router1 ^C
!
line con 0
exec-timeout 0 0
password 7 045802150C2E
logging synchronous
login
line aux 0
line vty 0 4
exec-timeout 0 0
password 7 094F471A1A0A
login
!
!
end
R1#
Router2配置如下:
R2#show run
Building configuration...
Current configuration : 1005 bytes
!
version 12.4
service timestamps debug datetime msec
service timestamps log datetime msec
service password-encryption
!
hostname R2
!
boot-start-marker
boot-end-marker
!
enable secret 5 $1$cLVF$eo1uPrkF5Lz1KIUaH1qT71
enable password 7 13061E010803
!
no aaa new-model
!
resource policy
!
memory-size iomem 5
!
!
ip cef
!
!
!
!
!
!
!
!
!
!
!
!
!
!
!
!
!
!
!
!
!
!
!
interface Loopback0
ip address 192.168.4.1 255.255.255.0
!
interface FastEthernet0/0
ip address 192.168.1.2 255.255.255.0
shutdown
duplex auto
speed auto
!
interface FastEthernet1/0
ip address 192.168.2.2 255.255.255.0
duplex auto
speed auto
!
ip http server
no ip http secure-server
ip route 192.168.3.0 255.255.255.0 192.168.1.1
ip route 192.168.3.0 255.255.255.0 192.168.2.1 50
!
!
!
!
!
!
control-plane
!
!
!
!
!
!
!
!
!
banner motd ^CWelcome to connect to R2^C
!
line con 0
exec-timeout 0 0
password 7 030752180500
logging synchronous
login
line aux 0
line vty 0 4
exec-timeout 0 0
password 7 14141B180F0B
login
!
!
end
R2#
---------------------------------------------
验证:
R1#ping 192.168.4.1
Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 192.168.4.1, timeout is 2 seconds:
!!!!!
Success rate is 100 percent (5/5), round-trip min/avg/max = 4/40/100 ms
R1#
R2#ping 192.168.3.1
Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 192.168.3.1, timeout is 2 seconds:
!!!!!
Success rate is 100 percent (5/5), round-trip min/avg/max = 8/24/68 ms
R2#
R1#show ip route
Codes: C - connected, S - static, R - RIP, M - mobile, B - BGP
D - EIGRP, EX - EIGRP external, O - OSPF, IA - OSPF inter area
N1 - OSPF NSSA external type 1, N2 - OSPF NSSA external type 2
E1 - OSPF external type 1, E2 - OSPF external type 2
i - IS-IS, su - IS-IS summary, L1 - IS-IS level-1, L2 - IS-IS level-2
ia - IS-IS inter area, * - candidate default, U - per-user static route
o - ODR, P - periodic downloaded static route
Gateway of last resort is not set
S 192.168.4.0/24 [1/0] via 192.168.1.2
C 192.168.1.0/24 is directly connected, FastEthernet0/0
C 192.168.2.0/24 is directly connected, FastEthernet1/0
C 192.168.3.0/24 is directly connected, Loopback0
R1#
R2#show ip route
Codes: C - connected, S - static, R - RIP, M - mobile, B - BGP
D - EIGRP, EX - EIGRP external, O - OSPF, IA - OSPF inter area
N1 - OSPF NSSA external type 1, N2 - OSPF NSSA external type 2
E1 - OSPF external type 1, E2 - OSPF external type 2
i - IS-IS, su - IS-IS summary, L1 - IS-IS level-1, L2 - IS-IS level-2
ia - IS-IS inter area, * - candidate default, U - per-user static route
o - ODR, P - periodic downloaded static route
Gateway of last resort is not set
C 192.168.4.0/24 is directly connected, Loopback0
C 192.168.1.0/24 is directly connected, FastEthernet0/0
C 192.168.2.0/24 is directly connected, FastEthernet1/0
S 192.168.3.0/24 [1/0] via 192.168.1.1
R2#
用tracerout命令跟踪数据包.
R1#tracerout 192.168.4.1
Type escape sequence to abort.
Tracing the route to 192.168.4.1
1 192.168.1.2 24 msec 40 msec *
R1#
R2#tracerout 192.168.3.1
Type escape sequence to abort.
Tracing the route to 192.168.3.1
1 *
192.168.1.1 48 msec 48 msec
R2#
-----------------------------------
当fa0/0链路当掉后
R1(config)#interface fa0/0
R1(config-if)#shutdown
R1(config-if)#
R1#show ip interface brief
Interface IP-Address OK? Method Status Protocol
FastEthernet0/0 192.168.1.1 YES manual administratively down down
FastEthernet1/0 192.168.2.1 YES manual up up
Loopback0 192.168.3.1 YES manual up up
R2也必须将FA0/0端口“当掉“,否则R2无法PING通R1的回环网卡Loopback0.
R2(config)#interface fa0/0
R2(config-if)#shutdown
查看路由表: 发现另一条静态路已开启。
R1#show ip route
Codes: C - connected, S - static, R - RIP, M - mobile, B - BGP
D - EIGRP, EX - EIGRP external, O - OSPF, IA - OSPF inter area
N1 - OSPF NSSA external type 1, N2 - OSPF NSSA external type 2
E1 - OSPF external type 1, E2 - OSPF external type 2
i - IS-IS, su - IS-IS summary, L1 - IS-IS level-1, L2 - IS-IS level-2
ia - IS-IS inter area, * - candidate default, U - per-user static route
o - ODR, P - periodic downloaded static route
Gateway of last resort is not set
S 192.168.4.0/24 [50/0] via 192.168.2.2
C 192.168.2.0/24 is directly connected, FastEthernet1/0
C r 192.168.3.0/24 is directly connected, Loopback0
R1#
R2#show ip route
Codes: C - connected, S - static, R - RIP, M - mobile, B - BGP
D - EIGRP, EX - EIGRP external, O - OSPF, IA - OSPF inter area
N1 - OSPF NSSA external type 1, N2 - OSPF NSSA external type 2
E1 - OSPF external type 1, E2 - OSPF external type 2
i - IS-IS, su - IS-IS summary, L1 - IS-IS level-1, L2 - IS-IS level-2
ia - IS-IS inter area, * - candidate default, U - per-user static route
o - ODR, P - periodic downloaded static route
Gateway of last resort is not set
C 192.168.4.0/24 is directly connected, Loopback0
C 192.168.2.0/24 is directly connected, FastEthernet1/0
S 192.168.3.0/24 [50/0] via 192.168.2.1
R2#
跟踪数据包:
R2#tracerout 192.168.3.1
Type escape sequence to abort.
Tracing the route to 192.168.3.1
1 192.168.2.1 48 msec 52 msec *
R2#
R1#tracerout 192.168.4.1
Type escape sequence to abort.
Tracing the route to 192.168.4.1
1 192.168.2.2 48 msec 80 msec *
R1#
-----------------------------------------------------
当fa0/0链路恢复以后:
R1(config)#interfac fa0/0
R1(config-if)#no shutdown
R2(config)#interface fa0/0
R2(config-if)#no shutdown
查看路由表:
R1#show ip route
Codes: C - connected, S - static, R - RIP, M - mobile, B - BGP
D - EIGRP, EX - EIGRP external, O - OSPF, IA - OSPF inter area
N1 - OSPF NSSA external type 1, N2 - OSPF NSSA external type 2
E1 - OSPF external type 1, E2 - OSPF external type 2
i - IS-IS, su - IS-IS summary, L1 - IS-IS level-1, L2 - IS-IS level-2
ia - IS-IS inter area, * - candidate default, U - per-user static route
o - ODR, P - periodic downloaded static route
Gateway of last resort is not set
S 192.168.4.0/24 [1/0] via 192.168.1.2
C 192.168.1.0/24 is directly connected, FastEthernet0/0
C 192.168.2.0/24 is directly connected, FastEthernet1/0
C 192.168.3.0/24 is directly connected, Loopback0
R1#
R2(config-if)#end
R2#show i
*Mar 1 00:37:28.691: %SYS-5-CONFIG_I: Configured from console by console
R2#show ip route
Codes: C - connected, S - static, R - RIP, M - mobile, B - BGP
D - EIGRP, EX - EIGRP external, O - OSPF, IA - OSPF inter area
N1 - OSPF NSSA external type 1, N2 - OSPF NSSA external type 2
E1 - OSPF external type 1, E2 - OSPF external type 2
i - IS-IS, su - IS-IS summary, L1 - IS-IS level-1, L2 - IS-IS level-2
ia - IS-IS inter area, * - candidate default, U - per-user static route
o - ODR, P - periodic downloaded static route
Gateway of last resort is not set
C 192.168.4.0/24 is directly connected, Loopback0
C 192.168.1.0/24 is directly connected, FastEthernet0/0
C 192.168.2.0/24 is directly connected, FastEthernet1/0
S 192.168.3.0/24 [1/0] via 192.168.1.1
R2#
跟踪数据包:
R1#tracerout 192.168.4.1
Type escape sequence to abort.
Tracing the route to 192.168.4.1
1 192.168.1.2 60 msec 48 msec *
R1#
R2#tracerout 192.168.3.1
Type escape sequence to abort.
Tracing the route to 192.168.3.1
1 *
192.168.1.1 48 msec 48 msec
R2#
============================================
将下一跳的地址配置为本地路由器上的接口。
R1配置如下.
interface Loopback0
ip address 192.168.3.1 255.255.255.0
!
interface FastEthernet0/0
ip address 192.168.1.1 255.255.255.0
shutdown
duplex auto
speed auto
!
interface FastEthernet1/0
ip address 192.168.2.1 255.255.255.0
duplex auto
speed auto
!
ip http server
no ip http secure-server
ip classless
ip route 192.168.4.0 255.255.255.0 FastEthernet0/0
ip route 192.168.4.0 255.255.255.0 FastEthernet1/0 50
R2配置如下.
interface Loopback0
ip address 192.168.4.1 255.255.255.0
!
interface FastEthernet0/0
ip address 192.168.1.2 255.255.255.0
shutdown
duplex auto
speed auto
!
interface FastEthernet1/0
ip address 192.168.2.2 255.255.255.0
duplex auto
speed auto
!
ip http server
no ip http secure-server
ip classless
ip route 192.168.3.0 255.255.255.0 FastEthernet0/0
ip route 192.168.3.0 255.255.255.0 FastEthernet1/0 50
========================================================
========================================================
杂项
在R1上telnet R2
R1#telnet 192.168.4.1
Trying 192.168.4.1 ... Open
Welcome to connect to Router2!
User Access Verification
Password:
R2>
R2>show line
Tty Typ Tx/Rx A Modem Roty AccO AccI Uses Noise Overruns Int
* 0 CTY - - - - - 0 1 0/0 -
129 AUX 9600/9600 - - - - - 0 0 0/0 -
* 130 VTY - - - - - 4 0 0/0 -
131 VTY - - - - - 0 0 0/0 -
132 VTY - - - - - 0 0 0/0 -
133 VTY - - - - - 0 0 0/0 -
134 VTY - - - - - 0 0 0/0 -
Line(s) not in async mode -or- with no hardware support:
1-128
R2>
在R2上踢除R1上的Telnet连接.
R2#show line
Tty Typ Tx/Rx A Modem Roty AccO AccI Uses Noise Overruns Int
* 0 CTY - - - - - 0 1 0/0 -
129 AUX 9600/9600 - - - - - 0 0 0/0 -
* 130 VTY - - - - - 5 0 0/0 -
131 VTY - - - - - 0 0 0/0 -
132 VTY - - - - - 0 0 0/0 -
133 VTY - - - - - 0 0 0/0 -
134 VTY - - - - - 0 0 0/0 -
Line(s) not in async mode -or- with no hardware support:
1-128
R2#clear line vty 0
[confirm]
[OK]
R2#show line
Tty Typ Tx/Rx A Modem Roty AccO AccI Uses Noise Overruns Int
* 0 CTY - - - - - 0 1 0/0 -
129 AUX 9600/9600 - - - - - 0 0 0/0 -
130 VTY - - - - - 5 0 0/0 -
131 VTY - - - - - 0 0 0/0 -
132 VTY - - - - - 0 0 0/0 -
133 VTY - - - - - 0 0 0/0 -
134 VTY - - - - - 0 0 0/0 -
Line(s) not in async mode -or- with no hardware support:
1-128
R2#
###############
拓朴如下图所示: