浮动静态路由
 

r1 配置

router>en
router#conf t
router(config)#host r1
r1(config)#no ip domain-lookup
r1(config)#ena sec 123
r1(config)#ban mot #Welcome to r1#
r1(config)#line con 0
r1(config-line)#no exec-timeout
r1(config-line)#line vty 0 4
r1(config-line)#no login
r1(config-line)#int f 0/0
r1(config-if)#des link to r2
r1(config-if)#ip add 192.168.1.1 255.255.255.0
r1(config-if)#no shut
r1(config-if)#router eigrp 1
r1(config-route)#network 192.168.1.0 0.0.0.255
r1(config-route)#end
r1#

r2 配置

router>en
router#conf t
router(config)#host r2
r2(config)#no ip domain-lookup
r2(config)#ena sec 123
r2(config)#ban mot #Welcome to r2#
r2(config)#line con 0
r2(config-line)#no exec-timeout
r2(config-line)#line vty 0 4
r2(config-line)#no login
r2(config-line)#int f 0/0
r2(config-if)#des link to r1
r2(config-if)#ip add 192.168.1.2 255.255.255.0
r2(config-if)#no shut
r2(config-if)#int f 1/0
r2(config-if)#des link to r3
r2(config-if)#ip add 192.168.2.1 255.255.255.0
r2(config-if)#no shut
r2(config-if)#int f 2/0
r2(config-if)#des link to r3
r2(config-if)#ip add 192.168.3.1 255.255.255.0
r2(config-if)#no shut
r2(config-if)#router eigrp 1
r2(config-route)#network 192.168.1.0 0.0.0.255
r2(config-route)#redistribute static metric 10000 100 255 1 1500
r2(config-route)#exit
r2(config)#ip route 192.168.4.0 255.255.255.0 192.168.2.2
r2(config)#ip route 192.168.4.0 255.255.255.0 192.168.3.2 permanent 80
r2(config)#end
r2#


r3 配置

router>en
router#conf t
router(config)#host r3
r3(config)#no ip domain-lookup
r3(config)#ena sec 123
r3(config)#ban mot #Welcome to r2#
r3(config)#line con 0
r3(config-line)#no exec-timeout
r3(config-line)#line vty 0 4
r3(config-line)#no login
r3(config-line)#int f 0/0
r3(config-if)#des link to r4
r3(config-if)#ip add 192.168.4.2 255.255.255.0
r3(config-if)#no shut
r3(config-if)#int f 1/0
r3(config-if)#des link to r2
r3(config-if)#ip add 192.168.2.2 255.255.255.0
r3(config-if)#no shut
r3(config-if)#int f 2/0
r3(config-if)#des link to r2
r3(config-if)#ip add 192.168.3.2 255.255.255.0
r3(config-if)#no shut
r3(config-if)#router ospf 1
r3(config-route)#network 192.168.4.0 0.0.0.255 aera 0
r3(config-route)#redistribute static metric 10 subnets
r3(config-route)#exit
r3(config)#ip route 192.168.1.0 255.255.255.0 192.168.2.1
r3(config)#ip route 192.168.4.0 255.255.255.0 192.168.3.1 permanent 80
r3(config)#end
r3#


r4 配置

router>en
router#conf t
router(config)#host r4
r4(config)#no ip domain-lookup
r4(config)#ena sec 123
r4(config)#ban mot #Welcome to r1#
r4(config)#line con 0
r4(config-line)#no exec-timeout
r4(config-line)#line vty 0 4
r4(config-line)#no login
r4(config-line)#int f 0/0
r4(config-if)#des link to r3
r4(config-if)#ip add 192.168.4.1 255.255.255.0
r4(config-if)#no shut
r4(config-if)#router ospf 1
r4(config-route)#network 192.168.4.0 0.0.0.255 area 0
r4(config-route)#end
r4#

 


r1#show run
Building configuration...

Current configuration : 671 bytes
!
version 12.3
service timestamps debug datetime msec
service timestamps log datetime msec
no service password-encryption
!
hostname r1
!
boot-start-marker
boot-end-marker
!
enable secret 5 $1$93MJ$RIJuOjEbg3U1o76DlTq.k0
!
no aaa new-model
ip subnet-zero
!
!
no ip domain lookup
!
ip cef
!
!
!
!
!
!
!
!
!
!
!
!
!
!
!
interface FastEthernet0/0
 description link to r2
 ip address 192.168.1.1 255.255.255.0
 duplex half
!
router eigrp 1
 network 192.168.1.0
 auto-summary
!
ip classless
no ip http server
!
!
!
!
!
!
!
!
!
gatekeeper
 shutdown
!
banner motd ^CWelcome to r1^C
!
line con 0
 exec-timeout 0 0
 stopbits 1
line aux 0
 stopbits 1
line vty 0 4
 no login
!
!
end

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

D EX 192.168.4.0/24 [170/284160] via 192.168.1.2, 00:03:12, FastEthernet0/0
C    192.168.1.0/24 is directly connected, FastEthernet0/0
r1#192.168.1.2
Trying 192.168.1.2 ... Open
Welcome to r2
r2>en
Password:
r2#show run
Building configuration...

Current configuration : 1033 bytes
!
version 12.3
service timestamps debug datetime msec
service timestamps log datetime msec
no service password-encryption
!
hostname r2
!
boot-start-marker
boot-end-marker
!
enable secret 5 $1$nfX9$iEsXqZ3O7GoyxbNOiuu1q/
!
no aaa new-model
ip subnet-zero
!
!
no ip domain lookup
!
ip cef
!
!
!
!
!
!
!
!
!
!
!
!
!
!
!
interface FastEthernet0/0
 description link to r1
 ip address 192.168.1.2 255.255.255.0
 duplex half
!
interface FastEthernet1/0
 description link to r3
 ip address 192.168.2.1 255.255.255.0
 duplex half
!
interface FastEthernet2/0
 description link to r3
 ip address 192.168.3.1 255.255.255.0
 duplex half
!
router eigrp 1
 redistribute static metric 10000 100 255 1 1500
 network 192.168.1.0
 auto-summary
!
ip classless
ip route 192.168.4.0 255.255.255.0 192.168.2.2
ip route 192.168.4.0 255.255.255.0 192.168.3.2 80 permanent
no ip http server
!
!
!
!
!
!
!
!
!
gatekeeper
 shutdown
!
banner motd ^CWelcome to r2^C
!
line con 0
 exec-timeout 0 0
 stopbits 1
line aux 0
 stopbits 1
line vty 0 4
 no login
!
!
end

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

S    192.168.4.0/24 [1/0] via 192.168.2.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, FastEthernet2/0
r2#192.168.2.2
Trying 192.168.2.2 ... Open
Welcome to r3
r3>en
Password:
r3#show run
Building configuration...

Current configuration : 1048 bytes
!
version 12.3
service timestamps debug datetime msec
service timestamps log datetime msec
no service password-encryption
!
hostname r3
!
boot-start-marker
boot-end-marker
!
enable secret 5 $1$/xXM$Kk2tFIse.3tzw0fk91QEB0
!
no aaa new-model
ip subnet-zero
!
!
no ip domain lookup
!
ip cef
!
!
!
!
!
!
!
!
!
!
!
!
!
!
!
interface FastEthernet0/0
 description link to r4
 ip address 192.168.4.2 255.255.255.0
 duplex half
!
interface FastEthernet1/0
 description link to r2
 ip address 192.168.2.2 255.255.255.0
 duplex half
!
interface FastEthernet2/0
 description link to r2
 ip address 192.168.3.2 255.255.255.0
 duplex half
!
router ospf 1
 log-adjacency-changes
 redistribute static metric 10 subnets
 network 192.168.4.0 0.0.0.255 area 0
!
ip classless
ip route 192.168.1.0 255.255.255.0 192.168.2.1
ip route 192.168.1.0 255.255.255.0 192.168.3.1 80 permanent
no ip http server
!
!
!
!
!
!
!
!
!
gatekeeper
 shutdown
!
banner motd ^CWelcome to r3^C
!
line con 0
 exec-timeout 0 0
 stopbits 1
line aux 0
 stopbits 1
line vty 0 4
 no login
!
!
end

r3#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, FastEthernet0/0
S    192.168.1.0/24 [1/0] via 192.168.2.1
C    192.168.2.0/24 is directly connected, FastEthernet1/0
C    192.168.3.0/24 is directly connected, FastEthernet2/0
r3#192.168.4.1
Trying 192.168.4.1 ... Open
Welcome to r4
r4>en
Password:
r4#show run
Building configuration...

Current configuration : 696 bytes
!
version 12.3
service timestamps debug datetime msec
service timestamps log datetime msec
no service password-encryption
!
hostname r4
!
boot-start-marker
boot-end-marker
!
enable secret 5 $1$.MgA$oiZzev3uV86CoCVvsPjoo0
!
no aaa new-model
ip subnet-zero
!
!
no ip domain lookup
!
ip cef
!
!
!
!
!
!
!
!
!
!
!
!
!
!
!
interface FastEthernet0/0
 description link to r3
 ip address 192.168.4.1 255.255.255.0
 duplex half
!
router ospf 1
 log-adjacency-changes
 network 192.168.4.0 0.0.0.255 area 0
!
ip classless
no ip http server
!
!
!
!
!
!
!
!
!
gatekeeper
 shutdown
!
banner motd ^CWelcome to r4^C
!
line con 0
 exec-timeout 0 0
 stopbits 1
line aux 0
 stopbits 1
line vty 0 4
 no login
!
!
end

r4#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, FastEthernet0/0
O E2 192.168.1.0/24 [110/10] via 192.168.4.2, 00:11:04, FastEthernet0/0

r4#traceroute 192.168.1.1

Type escape sequence to abort.
Tracing the route to 192.168.1.1

  1 192.168.4.2 124 msec 120 msec 64 msec
  2 192.168.2.1 164 msec 236 msec 284 msec
  3 192.168.1.1 452 msec *  308 msec
r4#

 

 

将 R2 的 F1/0 关闭

 

Welcome to r2
r2>en
Password:
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

S    192.168.4.0/24 [80/0] via 192.168.3.2
C    192.168.1.0/24 is directly connected, FastEthernet0/0
C    192.168.3.0/24 is directly connected, FastEthernet2/0
r2#192.168.3.2
Trying 192.168.3.2 ... Open
Welcome to r3
r3>en
Password:
r3#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, FastEthernet0/0
S    192.168.1.0/24 [80/0] via 192.168.3.1
C    192.168.3.0/24 is directly connected, FastEthernet2/0
r3#192.168.4.1
Trying 192.168.4.1 ... Open
Welcome to r4
r4>en
Password:

r4#traceroute 192.168.1.1

Type escape sequence to abort.
Tracing the route to 192.168.1.1

  1 192.168.4.2 156 msec 68 msec 68 msec
  2 192.168.3.1 236 msec 284 msec 188 msec
  3 192.168.1.1 524 msec *  452 msec