Cisco RIP路由协议
:IT学习乐园
:Builder
:20230201
:269

RIP---Routing Information Protocol(路由信息协议).属于OSI网络层协议。它是一种距离矢量协议(DV).最大跳数为15跳,超过15跳视为网络不可达.

----------------------------

RIP默认参数

RIP协议使用UDP报文发送路由更新,端口号为520.

RIP的管理距离为120.

RIP协议默认更新时为30秒,失效时间为180秒,保持时间为180秒,清除时间240秒。

RIP协议有两个版本.

----------------------------

网络拓朴如下:

Router1 S0/1 <----> Router2 S0/1 
Router2 S0/3 <----> Router3 S0/3

 

Router1配置如下:

R1#show run
R1#show running-config 
Building configuration...

Current configuration : 1145 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$w365$wUdb8bOszkvoDVQKssKuR/
enable password 7 0822455D0A16
!
no aaa new-model
!
resource policy
!
memory-size iomem 5
!
!
ip cef    
!
!
!
!
!
!
!
!
!
!
!
!
!
!
!
!
!
!

!
!
!
!         
interface Loopback0
 ip address 192.168.11.1 255.255.255.0
!
interface Serial0/0
 no ip address
 shutdown
 serial restart-delay 0
 no dce-terminal-timing-enable
!
interface Serial0/1
 ip address 192.168.2.1 255.255.255.0
 serial restart-delay 0
 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
!
!
!
!
!
!
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 0822455D0A16
 login
!
!
end

R1#

 

Router2配置如下:

R2#show run
Building configuration...

Current configuration : 1283 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$v9pE$v2MFyAM6DX9WrG3sPa2or0
enable password 7 110A1016141D
!
no aaa new-model
!
resource policy
!
memory-size iomem 5
!
!
ip cef    
!
!
!
!
!
!
!
!
!
!
!
!
!
!
!
!
!
!

!
!
!
!         
interface Loopback0
 ip address 192.168.22.1 255.255.255.0
!
interface Loopback1
 ip address 182.168.32.1 255.255.255.0
!
interface Serial0/0
 no ip address
 shutdown
 serial restart-delay 0
 no dce-terminal-timing-enable
!
interface Serial0/1
 bandwidth 64
 ip address 192.168.2.2 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
 bandwidth 64
 ip address 192.168.3.2 255.255.255.0
 serial restart-delay 0
 clock rate 64000
 no dce-terminal-timing-enable
!
ip http server
no ip http secure-server
!
!
!
!
!
!
control-plane
!
!
!
!
!         
!
!
!
!
banner motd ^C Welcome to connect to Router2 ^C
!
line con 0
 exec-timeout 0 0
 password 7 14141B180F0B
 logging synchronous
 login
line aux 0
line vty 0 4
 exec-timeout 0 0
 password 7 00071A150754
 login
!
!
end

R2#

 

Router3配置如下:

R3#show run
R3#show running-config 
Building configuration...

Current configuration : 1145 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$TDAx$Z8E9CLkxVOKtHWTazuXm0/
enable password 7 094F471A1A0A
!
no aaa new-model
!
resource policy
!
memory-size iomem 5
!
!
ip cef    
!
!
!
!
!
!
!
!
!
!
!
!
!
!
!
!
!
!

!
!
!
!         
interface Loopback0
 ip address 192.168.33.1 255.255.255.0
!
interface Serial0/0
 no ip address
 shutdown
 serial restart-delay 0
 no dce-terminal-timing-enable
!
interface Serial0/1
 no ip address
 shutdown
 serial restart-delay 0
 no dce-terminal-timing-enable
!
interface Serial0/2
 no ip address
 shutdown
 serial restart-delay 0
 no dce-terminal-timing-enable
!
interface Serial0/3
 ip address 192.168.3.1 255.255.255.0
 serial restart-delay 0
 no dce-terminal-timing-enable
!
ip http server
no ip http secure-server
!
!
!
!
!
!
control-plane
!
!
!
!
!
!
!
!
!
banner motd ^C Welcome to connect to Router3 ^C
!         
line con 0
 exec-timeout 0 0
 password 7 13061E010803
 logging synchronous
 login
line aux 0
line vty 0 4
 exec-timeout 0 0
 password 7 104D000A0618
 login
!
!
end

R3#

--------------------------------------------

 配置RIP路由:

R1#show ip interface brief
Interface                  IP-Address      OK? Method Status                Protocol
Serial0/0                  unassigned      YES NVRAM  administratively down down    
Serial0/1                  192.168.2.1     YES manual up                    up      
Serial0/2                  unassigned      YES NVRAM  administratively down down    
Serial0/3                  unassigned      YES NVRAM  administratively down down    
Loopback0                  192.168.11.1    YES manual up                    up      
R1#configure terminal
Enter configuration commands, one per line.  End with CNTL/Z.
R1(config)#router rip
R1(config-router)#network 192.168.2.0
R1(config-router)#network 192.168.11.0
R1(config-router)#^Z
R1#

 

R2#show ip interface brief
Interface                  IP-Address      OK? Method Status                Protocol
Serial0/0                  unassigned      YES NVRAM  administratively down down    
Serial0/1                  192.168.2.2     YES manual up                    up      
Serial0/2                  unassigned      YES NVRAM  administratively down down    
Serial0/3                  192.168.3.2     YES manual up                    up      
Loopback0                  192.168.22.1    YES manual up                    up      
Loopback1                  182.168.32.1    YES manual up                    up      
R2#configure terminal
Enter configuration commands, one per line.  End with CNTL/Z.
R2(config)#router rip
R2(config-router)#network 192.168.2.0
R2(config-router)#network 192.168.3.0
R2(config-router)#network 192.168.22.0
R2(config-router)#network 192.168.32.0
R2(config-router)#end
R2#

 

R3#show ip interface brief
Interface                  IP-Address      OK? Method Status                Protocol
Serial0/0                  unassigned      YES NVRAM  administratively down down    
Serial0/1                  unassigned      YES NVRAM  administratively down down    
Serial0/2                  unassigned      YES NVRAM  administratively down down    
Serial0/3                  192.168.3.1     YES manual up                    up      
Loopback0                  192.168.33.1    YES manual up                    up      
R3#con       
R3#conf
R3#configure t
R3#configure terminal 
Enter configuration commands, one per line.  End with CNTL/Z.
R3(config)#router rip 
R3(config-router)#network 192.168.3.0
R3(config-router)#network 192.168.33.0
R3(config-router)#end

---------------------------------------

Ping测试

R1#ping 192.168.33.1

Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 192.168.33.1, timeout is 2 seconds:
!!!!!
Success rate is 100 percent (5/5), round-trip min/avg/max = 36/52/88 ms
R1#

 

R3#ping 192.168.11.1

Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 192.168.11.1, timeout is 2 seconds:
!!!!!
Success rate is 100 percent (5/5), round-trip min/avg/max = 8/42/92 ms
R3#

--------------------------------------

 R2#show ip rip database
192.168.2.0/24    auto-summary
192.168.2.0/24    directly connected, Serial0/1
192.168.3.0/24    auto-summary
192.168.3.0/24    directly connected, Serial0/3
192.168.11.0/24    auto-summary
192.168.11.0/24
    [1] via 192.168.2.1, 00:00:11, Serial0/1
192.168.22.0/24    auto-summary
192.168.22.0/24    directly connected, Loopback0
192.168.33.0/24    auto-summary
192.168.33.0/24
    [1] via 192.168.3.1, 00:00:04, Serial0/3
R2#

 

R1#show ip rip database
192.168.2.0/24    auto-summary
192.168.2.0/24    directly connected, Serial0/1
192.168.3.0/24    auto-summary
192.168.3.0/24
    [1] via 192.168.2.2, 00:00:12, Serial0/1
192.168.11.0/24    auto-summary
192.168.11.0/24    directly connected, Loopback0
192.168.22.0/24    auto-summary
192.168.22.0/24
    [1] via 192.168.2.2, 00:00:12, Serial0/1
192.168.33.0/24    auto-summary
192.168.33.0/24
    [2] via 192.168.2.2, 00:00:12, Serial0/1
R1#

 

R3#show ip rip database
192.168.2.0/24    auto-summary
192.168.2.0/24
    [1] via 192.168.3.2, 00:00:22, Serial0/3
192.168.3.0/24    auto-summary
192.168.3.0/24    directly connected, Serial0/3
192.168.11.0/24    auto-summary
192.168.11.0/24
    [2] via 192.168.3.2, 00:00:22, Serial0/3
192.168.22.0/24    auto-summary
192.168.22.0/24
    [1] via 192.168.3.2, 00:00:22, Serial0/3
192.168.33.0/24    auto-summary
192.168.33.0/24    directly connected, Loopback0
-----------------------------------------------

R1#show ip protocols 
Routing Protocol is "rip"
  Outgoing update filter list for all interfaces is not set
  Incoming update filter list for all interfaces is not set
  Sending updates every 30 seconds, next due in 27 seconds
  Invalid after 180 seconds, hold down 180, flushed after 240
  Redistributing: rip
  Default version control: send version 1, receive any version
    Interface             Send  Recv  Triggered RIP  Key-chain
    Serial0/1             1     1 2                                  
    Loopback0             1     1 2                                  
  Automatic network summarization is in effect
  Maximum path: 4
  Routing for Networks:
    192.168.2.0
    192.168.11.0
  Routing Information Sources:
    Gateway         Distance      Last Update
    192.168.2.2          120      00:00:11
  Distance: (default is 120)

R1#


 

 R2#show ip protocols    
Routing Protocol is "rip"
  Outgoing update filter list for all interfaces is not set
  Incoming update filter list for all interfaces is not set
  Sending updates every 30 seconds, next due in 22 seconds
  Invalid after 180 seconds, hold down 180, flushed after 240
  Redistributing: rip
  Neighbor(s):
    192.168.3.1
    192.168.2.1
  Default version control: send version 1, receive any version
    Interface             Send  Recv  Triggered RIP  Key-chain
    Serial0/1             1     1 2                                  
    Serial0/3             1     1 2                                  
    Loopback0             1     1 2                                  
  Automatic network summarization is in effect
  Maximum path: 4
  Routing for Networks:
    192.168.2.0
    192.168.3.0
    192.168.22.0
    192.168.32.0
  Routing Information Sources:
    Gateway         Distance      Last Update
    Gateway         Distance      Last Update
    192.168.3.1          120      00:00:02
    192.168.2.1          120      00:00:18
  Distance: (default is 120)

R2#

 

R3#show ip protocols
Routing Protocol is "rip"
  Outgoing update filter list for all interfaces is not set
  Incoming update filter list for all interfaces is not set
  Sending updates every 30 seconds, next due in 21 seconds
  Invalid after 180 seconds, hold down 180, flushed after 240
  Redistributing: rip
  Default version control: send version 1, receive any version
    Interface             Send  Recv  Triggered RIP  Key-chain
    Serial0/3             1     1 2                                  
    Loopback0             1     1 2                                  
  Automatic network summarization is in effect
  Maximum path: 4
  Routing for Networks:
    192.168.3.0
    192.168.33.0
  Routing Information Sources:
    Gateway         Distance      Last Update
    192.168.3.2          120      00:00:15
  Distance: (default is 120)

R3# 

------------------------------

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

C    192.168.11.0/24 is directly connected, Loopback0
R    192.168.22.0/24 [120/1] via 192.168.2.2, 00:00:04, Serial0/1
C    192.168.2.0/24 is directly connected, Serial0/1
R    192.168.3.0/24 [120/1] via 192.168.2.2, 00:00:04, Serial0/1
R    192.168.33.0/24 [120/2] via 192.168.2.2, 00:00:04, Serial0/1
R1#show ip route rip
R    192.168.22.0/24 [120/1] via 192.168.2.2, 00:00:12, Serial0/1
R    192.168.3.0/24 [120/1] via 192.168.2.2, 00:00:12, Serial0/1
R    192.168.33.0/24 [120/2] via 192.168.2.2, 00:00:12, Serial0/1
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

R    192.168.11.0/24 [120/1] via 192.168.2.1, 00:00:24, Serial0/1
C    192.168.22.0/24 is directly connected, Loopback0
     182.168.0.0/24 is subnetted, 1 subnets
C       182.168.32.0 is directly connected, Loopback1
C    192.168.2.0/24 is directly connected, Serial0/1
C    192.168.3.0/24 is directly connected, Serial0/3
R    192.168.33.0/24 [120/1] via 192.168.3.1, 00:00:00, Serial0/3
R2#show ip route rip
R    192.168.11.0/24 [120/1] via 192.168.2.1, 00:00:03, Serial0/1
R    192.168.33.0/24 [120/1] via 192.168.3.1, 00:00:05, Serial0/3
R2#

 

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

R    192.168.11.0/24 [120/2] via 192.168.3.2, 00:00:15, Serial0/3
R    192.168.22.0/24 [120/1] via 192.168.3.2, 00:00:15, Serial0/3
R    192.168.2.0/24 [120/1] via 192.168.3.2, 00:00:15, Serial0/3
C    192.168.3.0/24 is directly connected, Serial0/3
C    192.168.33.0/24 is directly connected, Loopback0
R3#show ip route rip
R    192.168.11.0/24 [120/2] via 192.168.3.2, 00:00:21, Serial0/3
R    192.168.22.0/24 [120/1] via 192.168.3.2, 00:00:21, Serial0/3
R    192.168.2.0/24 [120/1] via 192.168.3.2, 00:00:21, Serial0/3
R3#

 

修改RIP默认更新时间,失效时间,保持时间,清除时间.

R1#show ip protocol 
Routing Protocol is "rip"
  Outgoing update filter list for all interfaces is not set
  Incoming update filter list for all interfaces is not set
  Sending updates every 30 seconds, next due in 18 seconds
  Invalid after 180 seconds, hold down 180, flushed after 240
  Redistributing: rip
  Default version control: send version 1, receive any version
    Interface             Send  Recv  Triggered RIP  Key-chain
    Serial0/1             1     1 2                                  
    Loopback0             1     1 2                                  
  Automatic network summarization is in effect
  Maximum path: 4
  Routing for Networks:
    192.168.2.0
    192.168.11.0
  Routing Information Sources:
    Gateway         Distance      Last Update
    192.168.2.2          120      00:00:21
  Distance: (default is 120)

R1#configure terminal

R1(config)#router rip

R1(config-router)#timers basic 60 240 240 360 
R1(config-router)#end
R1#show
*Mar  1 02:51:32.799: %SYS-5-CONFIG_I: Configured from console by console
R1#show ip protocol 
Routing Protocol is "rip"
  Outgoing update filter list for all interfaces is not set
  Incoming update filter list for all interfaces is not set
  Sending updates every 60 seconds, next due in 10 seconds
  Invalid after 240 seconds, hold down 240, flushed after 360 
  Redistributing: rip
  Default version control: send version 1, receive any version
    Interface             Send  Recv  Triggered RIP  Key-chain
    Serial0/1             1     1 2                                  
    Loopback0             1     1 2                                  
  Automatic network summarization is in effect
  Maximum path: 4
  Routing for Networks:
    192.168.2.0
    192.168.11.0
  Routing Information Sources:
    Gateway         Distance      Last Update
    192.168.2.2          120      00:00:09
  Distance: (default is 120)

R1#

----------------------

RIP靠跳数判别路径的优劣。

RIP靠定期广播传送路径信息(V1)。

-----------------------

 修改管理距离为115

R1(config-router)#distance ?
  <1-255>  Administrative distance

R1(config-router)#distance 115

 -----------------------------------

网络拓朴如下:

Router1 F1/0 <----> Router2 F1/0 
Router2 F0/0 <----> VPCS V0/1 
Router1 F0/0 <----> VPCS V0/2 
Router1 F0/1 <----> VPCS V0/3

Router1配置如下: 

 
SW1#show run 
Building configuration...

Current configuration : 1848 bytes
!
version 12.3
service timestamps debug datetime msec
service timestamps log datetime msec
service password-encryption
!
hostname SW1
!
boot-start-marker
boot-end-marker
!
enable secret 5 $1$Ioze$Y/gu5jyiTl3a8yTJ7.PjP1
enable password 7 060506324F41
!
memory-size iomem 5
no aaa new-model
ip subnet-zero
!
!
!
!
ip cef    
ip ips po max-events 100
no ftp-server write-enable
!
!
!
!
!
!
!
!
!
!
!
!
!
!
!

!
!
!
!
interface FastEthernet0/0
 switchport access vlan 10
 no ip address
!
interface FastEthernet0/1
 switchport access vlan 20
 no ip address
!
interface FastEthernet0/2
 no ip address
 shutdown
!
interface FastEthernet0/3
 no ip address
 shutdown
!
interface FastEthernet0/4
 no ip address
 shutdown
!
interface FastEthernet0/5
 no ip address
 shutdown
!         
interface FastEthernet0/6
 no ip address
 shutdown
!
interface FastEthernet0/7
 no ip address
 shutdown
!
interface FastEthernet0/8
 no ip address
 shutdown
!
interface FastEthernet0/9
 no ip address
 shutdown
!
interface FastEthernet0/10
 no ip address
 shutdown
!
interface FastEthernet0/11
 no ip address
 shutdown 
!
interface FastEthernet0/12
 no ip address
 shutdown
!
interface FastEthernet0/13
 no ip address
 shutdown
!
interface FastEthernet0/14
 no ip address
 shutdown
!
interface FastEthernet0/15
 no ip address
 shutdown
!
interface FastEthernet1/0
 ip address 192.168.1.1 255.255.255.0
 duplex auto
 speed auto
!
interface Vlan1
 no ip address
!
interface Vlan10
 ip address 192.168.10.1 255.255.255.0
!
interface Vlan20
 ip address 192.168.20.1 255.255.255.0
!
ip http server
no ip http secure-server
ip classless
!
!
!
!
!
!
control-plane
!
!
!
!
!         
!
!
!
banner motd ^C Welcome to connect to Switch1 ^C
!
line con 0
 exec-timeout 0 0
 password 7 094F471A1A0A
 logging synchronous
 login
line aux 0
line vty 0 4
 exec-timeout 0 0
 password 7 01100F175804
 login
!
!
end

SW1#

Router2配置如下:

R1#show run 
Building configuration...

Current configuration : 902 bytes
!
version 12.3
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$QJ.m$W3i2Zy861iSanUTu0xmDw0
enable password 7 110A1016141D
!
memory-size iomem 5
no aaa new-model
ip subnet-zero
!
!
!
!
ip cef    
ip ips po max-events 100
no ftp-server write-enable
!
!
!
!
!
!
!
!
!
!
!
!
!
!
!

!
!
!
!
interface FastEthernet0/0
 ip address 192.168.30.1 255.255.255.0
 duplex auto
 speed auto
!
interface FastEthernet1/0
 ip address 192.168.1.2 255.255.255.0
 duplex auto
 speed auto
!
ip http server
no ip http secure-server
ip classless
!
!
!
!
!
!
control-plane
!
!
!
!         
!
!
!
!
banner motd ^C Welcome to connect to Router1 ^C
!
line con 0
 exec-timeout 0 0
 password 7 0822455D0A16
 logging synchronous
 login
line aux 0
line vty 0 4
 exec-timeout 0 0
 password 7 01100F175804
 login
!
!
end

各PC IP网关配置如下:

VPCS 3 >show

NAME   IP/CIDR              GATEWAY           LPORT   RPORT
PC1    192.168.30.2/24       192.168.30.1       10001   11200
PC2    192.168.10.2/24       192.168.10.1       10002   11100
PC3    192.168.20.2/24      192.168.20.1       10003   11101

--------------------------------

RIP协议V2,可采用组播传送路由信息。在SW1和R1配置RIP协议。

neighbor---采用单播送报文信息

passive-interface---被动接口,此接口只接收RIP分组,不发送RIP分组. 

 

SW1(config-if)#do show ip interface brief 
Interface                  IP-Address      OK? Method Status                Protocol
FastEthernet0/0            unassigned      YES unset  up                    up      
FastEthernet0/1            unassigned      YES unset  up                    up      
FastEthernet0/2            unassigned      YES unset  administratively down down    
FastEthernet0/3            unassigned      YES unset  administratively down down    
FastEthernet0/4            unassigned      YES unset  administratively down down    
FastEthernet0/5            unassigned      YES unset  administratively down down    
FastEthernet0/6            unassigned      YES unset  administratively down down    
FastEthernet0/7            unassigned      YES unset  administratively down down    
FastEthernet0/8            unassigned      YES unset  administratively down down    
FastEthernet0/9            unassigned      YES unset  administratively down down    
FastEthernet0/10           unassigned      YES unset  administratively down down    
FastEthernet0/11           unassigned      YES unset  administratively down down    
FastEthernet0/12           unassigned      YES unset  administratively down down    
FastEthernet0/13           unassigned      YES unset  administratively down down    
FastEthernet0/14           unassigned      YES unset  administratively down down    
FastEthernet0/15           unassigned      YES unset  administratively down down    
FastEthernet1/0            192.168.1.1     YES manual up                    up      
Vlan1                      unassigned      YES NVRAM  up                    down    
Vlan10                     192.168.10.1    YES manual up                    up      
Vlan20                     192.168.20.1    YES manual up                    up      
SW1(config-if)#

 

SW1#configure terminal
Enter configuration commands, one per line.  End with CNTL/Z.
SW1(config)#router rip
SW1(config-router)#version 2
 

SW1(config-router)#no auto
SW1(config-router)#no auto-summary 
SW1(config-router)#network 192.168.10.0
SW1(config-router)#network 192.168.20.0
SW1(config-router)#network 192.168.1.0
 

SW1(config-router)#neig
SW1(config-router)#neighbor ?
  A.B.C.D  Neighbor address

SW1(config-router)#neighbor 192.168.1.2 
SW1(config-router)#end

 

R1(config)#router rip
R1(config-router)#version 2
R1(config-router)#no auto
R1(config-router)#no auto-summary 
R1(config-router)#network 192.168.1.0   
R1(config-router)#network 192.168.30.0
 

R1(config-router)#nei
R1(config-router)#neighbor 192.168.1.1 
R1(config-router)#passive
R1(config-router)#passive-interface f1/0 
R1(config-router)#end
R1#

--------------------------------------------

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

C    192.168.30.0/24 is directly connected, FastEthernet0/0
R    192.168.10.0/24 [120/1] via 192.168.1.1, 00:00:00, FastEthernet1/0
R    192.168.20.0/24 [120/1] via 192.168.1.1, 00:00:00, FastEthernet1/0
C    192.168.1.0/24 is directly connected, FastEthernet1/0
R1#

 

SW1#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

R    192.168.30.0/24 [120/1] via 192.168.1.2, 00:00:17, FastEthernet1/0
C    192.168.10.0/24 is directly connected, Vlan10
C    192.168.20.0/24 is directly connected, Vlan20
C    192.168.1.0/24 is directly connected, FastEthernet1/0

 

R1#show ip protocol 
Routing Protocol is "rip"
  Sending updates every 30 seconds, next due in 21 seconds
  Invalid after 180 seconds, hold down 180, flushed after 240
  Outgoing update filter list for all interfaces is not set
  Incoming update filter list for all interfaces is not set
  Redistributing: rip
  Neighbor(s):
    192.168.1.1
  Default version control: send version 2, receive version 2
    Interface             Send  Recv  Triggered RIP  Key-chain
    FastEthernet0/0       2     2                                    
  Automatic network summarization is not in effect
  Maximum path: 4
  Routing for Networks:
    192.168.1.0
    192.168.30.0
  Passive Interface(s):
    FastEthernet1/0
  Routing Information Sources:
    Gateway         Distance      Last Update
    192.168.1.1          120      00:00:17
  Distance: (default is 120)

R1#

 

SW1#show ip protocol 
Routing Protocol is "rip"
  Sending updates every 30 seconds, next due in 24 seconds
  Invalid after 180 seconds, hold down 180, flushed after 240
  Outgoing update filter list for all interfaces is not set
  Incoming update filter list for all interfaces is not set
  Redistributing: rip
  Neighbor(s):
    192.168.1.2
  Default version control: send version 2, receive version 2
    Interface             Send  Recv  Triggered RIP  Key-chain
    FastEthernet1/0       2     2                                    
    Vlan10                2     2                                    
    Vlan20                2     2                                    
  Automatic network summarization is not in effect
  Maximum path: 4
  Routing for Networks:
    192.168.1.0
    192.168.10.0
    192.168.20.0
  Routing Information Sources:
    Gateway         Distance      Last Update
    192.168.1.2          120      00:00:19
  Distance: (default is 120)
          
SW1#

----------------------------------------

调试

SW1#show ip rip ?
  database  IP RIP database

SW1#show ip rip database 
192.168.1.0/24    auto-summary
192.168.1.0/24    directly connected, FastEthernet1/0
192.168.10.0/24    auto-summary
192.168.10.0/24    directly connected, Vlan10
192.168.20.0/24    auto-summary
192.168.20.0/24    directly connected, Vlan20
192.168.30.0/24    auto-summary
192.168.30.0/24
    [1] via 192.168.1.2, 00:00:09, FastEthernet1/0

 


SW1#debug ip rip 
RIP protocol debugging is on
SW1#
*Mar  1 00:57:53.995: RIP: sending v2 update to 224.0.0.9 via Vlan10 (192.168.10.1)
*Mar  1 00:57:53.995: RIP: build update entries
*Mar  1 00:57:53.995:   192.168.1.0/24 via 0.0.0.0, metric 1, tag 0
*Mar  1 00:57:53.995:   192.168.20.0/24 via 0.0.0.0, metric 1, tag 0
*Mar  1 00:57:53.999:   192.168.30.0/24 via 0.0.0.0, metric 2, tag 0
*Mar  1 00:57:54.815: RIP: sending v2 update to 224.0.0.9 via Vlan20 (192.168.20.1)
*Mar  1 00:57:54.815: RIP: build update entries
*Mar  1 00:57:54.815:   192.168.1.0/24 via 0.0.0.0, metric 1, tag 0
*Mar  1 00:57:54.815:   192.168.10.0/24 via 0.0.0.0, metric 1, tag 0
*Mar  1 00:57:54.819:   192.168.30.0/24 via 0.0.0.0, metric 2, tag 0
SW1#

 

SW1#debug ip rip database 
RIP database events debugging is on
SW1#
*Mar  1 00:58:31.563: RIP-DB: network_update with 192.168.30.0/24 succeeds
*Mar  1 00:58:31.563: RIP-DB: adding 192.168.30.0/24 (metric 1) via 192.168.1.2 on FastEthernet1/0 to RIP database
SW1#

 

SW1#debug ip rip events 
RIP event debugging is on
SW1#
*Mar  1 00:59:37.487: RIP: sending v2 update to 224.0.0.9 via FastEthernet1/0 (192.168.1.1)
*Mar  1 00:59:37.487: RIP: Update contains 2 routes
*Mar  1 00:59:37.487: RIP: Update queued
*Mar  1 00:59:37.487: RIP: sending v2 update to 192.168.1.2 via FastEthernet1/0 (192.168.1.1)
*Mar  1 00:59:37.491: RIP: Update contains 2 routes
*Mar  1 00:59:37.491: RIP: Update queued
*Mar  1 00:59:37.491: RIP: Update sent via FastEthernet1/0
*Mar  1 00:59:37.491: RIP: Update sent via FastEthernet1/0
SW1#
 

SW1#show ip route rip 
R    192.168.30.0/24 [120/1] via 192.168.1.2, 00:00:15, FastEthernet1/0
SW1#

--------------------------

 在接口上禁用广播

R1(config-if)#no ip directed-broadcast

 

#############


 RIP V2默认用组播发送路由更新信息,其组播地址为224.0.0.9.

 

 RIP-1采用广播形式发送报文;RIP-2有两种传送方式,广播方式和组播方式,缺省将采用多播发送报文。多播发送报文的好处是在同一网 络中那些未运行RIP的主机可以避免接收RIP的广播报文。当接口运行RIP-1时,接收和发送RIP-1与接收RIP-2报文;当接口运行在RIP-2组播方式时,只接收和发送RIP-2报文,不接收RIP-1报文。在缺省情况下,一个接口既可接收 RIP更新报文,也可发送RIP更新报文。

在接口上使用ip rip v2-broadcast 命令启用V2广播报文。

 

Cisco RIP常用命令

Router(config)#router rip—启动RIP路由协议
Router(config-router)# network [network range | all]—指定工作网段,RIP只在指定网段上的接口工作;对于不在指定网段上的接口,RIP既不在它上面接收和发送路由,也不将它的接口路由转发出去。
Router(config-router)# version [1|2—指定RIP的版本
Router(config-router)# maximum-paths [1-6]—指定等价路由的最多使用条数
Router(config-router)# passive-interface e0—可以使eth0口只接收RIP分组,但不发送rip分组,这个命令只有在需要的时候才配置。
Router(config-router)#int s0—进入单独的接口进行配置
Router(config-if)#ip rip [send|receive] version [1|2]—可以指定某个接口做发送或接口
功能,并且执行哪一个版本的RIP
Router(config-if)#ip split-horizon—可以设置是否启用水平分割

Neighbor--命令能够定义一个RIP邻居路由器来与之进行单播更新信息的交换,它要和passive-interface命令配合使用


 

IP RIP分组格式
下面描述IP RIP V1和IP RIP V2的分组格式。
1、RIP V1分组格式

rip100.jpg

 · 命令--表示该分组是请求还是响应。请求分组要求路由器发送其路由表的全部或部分。响应分组可以是主动提供的周期性路由更新或对请求的响应。大的路由表可以使用多个RIP分组来传递信息。
· 版本号--指明使用的RIP版本,此域可以通知不同版本的不兼容。
· 零--未使用。
· 地址族标志(AFI)--指明使用的地址族。RIP设计用于携带多种不同协议的路由信息。每个项都有地址族标志来表明使用的地址类型,IP的AFI是2。
· 地址--指明该项的IP地址。

· metric--表示到目的的过程中经过了多少跳数(路由器数)。有效路径的值在1和15之间,16表示不可达路径。
注:在一个IP RIP分组中最多可有25个AFI、地址和metric域,即一个RIP分组中最多可含有25个地址项。
2、RIP V2分组格式
RIP2规范(RFC1723)允许RIP分组包含更多的信息,并提供了简单的认证机制,如下图所示.

rip101.jpg

· 命令--表示该分组是请求还是响应。请求分组要求路由器发送其路由表的全部或部分。响应分组可以是主动提供的周期性路由更新或对请求的响应。大的路由表可以使用多个RIP分组来传递信息。
· 版本--指明使用的RIP版本,在实现RIP2或进行认证的RIP分组中,此值为2。
· 未使用--值为0。
· 地址族标志(AFI)--指明使用的地址族。RIP设计用于携带多种不同协议的路由信息。每个项都有地址族标志来表明使用的地址类型,IP的AFI是2。如果第一项的AFI为0xFFFF,该项剩下的部分就是认证信息。目前,唯一的认证类型就是简单的口令。
· 路由标记--提供区分内部路由(由RIP学得)和外部路由(由其它协议学得)的方法。
· IP地址--指明该项的IP地址。
· 子网掩码--包含该项的子网掩码。如果此域为0,则该项不指定子网掩码。
· 下一跳--指明下一跳的IP地址。
· metric--表示到目的的过程中经过了多少跳数(路由器数)。有效路径的值在1和15之间,16表示不可达路径。
注:在一个IP RIP分组中最多可有25个AFI、地址和metric域,即一个RIP分组中最多可含有25个地址项。如果AFI指明为认证信息,则只能有24个路由表项。


RIP数据包工作过程

1 初始化——RIP 初始化时,会从每个参与工作的接口上发送请求数据包。该请求数据包会向所有的RIP路由器请求一份完整的路由表。该请求通过LAN上的广播形式发送LAN或者在点到点链路发送到下一跳地址来完成。这是一个特殊的请求,向相邻设备请求完整的路由更新。
2 接收请求——RIP有两种类型的消息,响应和接收消息。请求数据包中的每个路由条目都会被处理,从而为路由建立度量以及路径。RIP采用跳数度量,值为1的意为着一个直连的网络,16,为网络不可达。路由器会把整个路由表作为接收消息的应答返回。
3接收到响应——路由器接收并处理响应,它会通过对路由表项进行添加,删除或者修改作出更新。
4 常规路由更新和定时——路由器以30秒一次地将整个路由表以应答消息地形式发送到邻居路由器。路由器收到新路由或者现有路由地更新信息时,会设置一个 180秒地超时时间。如果180秒没有任何更新信息,路由的跳数设为16。路由器以度量值16宣告该路由,直到刷新计时器从路由表中删除该路由。清除计时器的时间设为240秒,或者说比过期计时器时间多60秒。Cisco还用了第三个计时器,称为抑制计时器。接收到一个度量更高的路由之后的180秒时间就是 抑制计时器的时间,在此期间,路由器不会用它接收到的新信息对路由表进行更新,这样能够为网路的收敛提供一段额外的时间。
5 触发路由更新——当某个路由度量发生改变时,路由器只发送与改变有关的路由,并不发送完整的路由表。

RIP V1是一个有类的路由选择协议,因此路由宣告中不携带子网掩码。RIP-1采用接收路由的接口的子网掩码来确定目的网络的子网 掩码。这种做法仅对接收到的路由和直连网络处于同一主网的情况有效。如果接收到的路由不是同一个主网,路由器就会试着去匹配该路由的主网掩码,可能是 A,B,C类。因此整个RIP路由域中保持每个主网掩码长度的一致很重要。当重发布时,如果redistribute的子网和本地接口的不符,则不会发送该网络,要用ip sum-address来调整.

RIP V2 支持VLSM。路由器在路由更新中包含了子网掩码,使得路由器能够处理VLSM寻址,支持MD5认证.

通过 ip rip triggered 学习到的条目显示为permanent,即在路由表里和数据库没有计时。

查看cisco网站12.3/12.4版本的文档,triggered的Feature在较高版本又消失了,v2-broadcast你的debug就知道这条命令敲下去后,打开了广播更新的开关,而关闭了组播更新的开关.

---------------------------------------------------

RIP V2在接口上启用验证

网络拓朴如下.

Router1 F0/0 <----> Router2 F0/0 
Router1 F1/0 <----> VPCS V0/1 
Router2 F1/0 <----> Router3 F1/0 
Router3 F0/0 <----> VPCS V0/2

-----------------------------------------------------

配置Key,在相应的端口上启用验证

R1#configure terminal
Enter configuration commands, one per line.  End with CNTL/Z.
R1(config)#key chain rip-key
R1(config-keychain)#key 1
R1(config-keychain-key)#key-string BuilderZou
R1(config-keychain-key)#end


R1#configure terminal
Enter configuration commands, one per line.  End with CNTL/Z.
R1(config)#interface f0/0
R1(config-if)#ip rip authentication ?
  key-chain  Authentication key-chain
  mode       Authentication mode

R1(config-if)#ip rip authentication key-chain ?
  LINE  name of key-chain

R1(config-if)#ip rip authentication key-chain rip-key
R1(config-if)#   
----------------------------------------------------------------

R1,R2, R3,VPC1,VPC2分别配置如下:

 

 R1#show run
R1#show running-config 
Building configuration...

Current configuration : 1065 bytes
!
version 12.3
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$T86S$P2BXihGq/VhxHQO9ZadVk.
enable password 7 045802150C2E
!
memory-size iomem 5
no aaa new-model
ip subnet-zero
!
!
!
!
ip cef    
ip ips po max-events 100
no ftp-server write-enable
!
!
key chain rip-key
 key 1
  key-string 7 08035947051D0005280419
!
!
!
!
!
!
!
!
!
!
!
!
!
!

!         
!
!
!
interface FastEthernet0/0
 ip address 192.168.1.1 255.255.255.0
 ip rip authentication key-chain rip-key
 duplex auto
 speed auto
!
interface FastEthernet1/0
 ip address 1.1.1.1 255.255.255.0
 duplex auto
 speed auto
!
router rip
 version 2
 network 1.0.0.0
 network 192.168.1.0
!
ip http server
no ip http secure-server
ip classless
!         
!
!
!
!
!
control-plane
!
!
!
!
!
!
!
!
banner motd ^C Welcome to connect to Router1 ^C
!
line con 0
 exec-timeout 0 0
 password 7 14141B180F0B
 logging synchronous
 login
line aux 0
line vty 0 4
 exec-timeout 0 0
 password 7 045802150C2E
 login
!
!
end

R1#

 

R2#show running-config 
Building configuration...

Current configuration : 1114 bytes
!
version 12.3
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$rjoV$NQ434UZnuxd46fmXhbV4Y.
enable password 7 121A0C041104
!
memory-size iomem 5
no aaa new-model
ip subnet-zero
!
!
!
!
ip cef    
ip ips po max-events 100
no ftp-server write-enable
!
!
key chain rip-key
 key 1
  key-string 7 052913062D484B1B230A02
!
!
!
!
!
!
!
!
!
!
!
!
!
!

!         
!
!
!
interface FastEthernet0/0
 ip address 192.168.1.2 255.255.255.0
 ip rip authentication key-chain rip-key
 duplex auto
 speed auto
!
interface FastEthernet1/0
 ip address 192.168.2.1 255.255.255.0
 ip rip authentication key-chain rip-key
 duplex auto
 speed auto
!
router rip
 version 2
 network 192.168.1.0
 network 192.168.2.0
!
ip http server
no ip http secure-server
ip classless
!
!
!
!
!
!
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 045802150C2E
 login
!
!
end

R2#

 

R3(config)#do show run
Building configuration...

Current configuration : 1065 bytes
!
version 12.3
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$S6vf$3W8HBA0n3t4Oy3YI9qpK//
enable password 7 094F471A1A0A
!
memory-size iomem 5
no aaa new-model
ip subnet-zero
!
!
!
!
ip cef    
ip ips po max-events 100
no ftp-server write-enable
!
!
key chain rip-key
 key 1
  key-string 7 0131130D570F031D1B435B
!
!
!
!
!
!
!
!
!
!
!
!
!
!

!         
!
!
!
interface FastEthernet0/0
 ip address 3.3.3.1 255.255.255.0
 duplex auto
 speed auto
!
interface FastEthernet1/0
 ip address 192.168.2.1 255.255.255.0
 ip rip authentication key-chain rip-key
 duplex auto
 speed auto
!
router rip
 version 2
 network 3.0.0.0
 network 192.168.2.0
!
ip http server
no ip http secure-server
ip classless
!         
!
!
!
!
!
control-plane
!
!
!
!
!
!
!
!
banner motd ^C Welcome to connect to Router3 ^C
!
line con 0
 exec-timeout 0 0
 password 7 094F471A1A0A
 logging synchronous
 login
line aux 0
line vty 0 4
 exec-timeout 0 0
 password 7 01100F175804
 login
!
!
end

R3(config)#

 

NAME   IP/CIDR              GATEWAY           LPORT   RPORT
PC1    1.1.1.2/24           1.1.1.1           10001   11110
PC2    3.3.3.2/24           3.3.3.1           10002   11300

-----------------------------------------

验证

R1#debug ip rip 
RIP protocol debugging is on
R1#
*Mar  1 02:09:33.627: RIP: received packet with text authentication BuilderZou

-------------------------------------------

MD5验证

R1#configure terminal
Enter configuration commands, one per line.  End with CNTL/Z.
R1(config)#interface f0/0
R1(config-if)#ip rip authenti
R1(config-if)#ip rip authentication mode ?
  md5   Keyed message digest
  text  Clear text authentication

R1(config-if)#ip rip authentication mode md5
R1(config-if)#

如果在一端起用MD5验证,在另一端也要启用MD5,否则网络没法通讯.

 R1#debug ip rip 
RIP protocol debugging is on
R1#
*Mar  1 04:13:24.938: RIP: sending v2 update to 224.0.0.9 via FastEthernet1/0 (1.1.1.1)
*Mar  1 04:13:24.938: RIP: build update entries
*Mar  1 04:13:24.938:   3.0.0.0/8 via 0.0.0.0, metric 3, tag 0
*Mar  1 04:13:24.938:   192.168.1.0/24 via 0.0.0.0, metric 1, tag 0
*Mar  1 04:13:24.942:   192.168.2.0/24 via 0.0.0.0, metric 2, tag 0
R1#
*Mar  1 04:13:26.334: RIP: received packet with MD5 authentication
*Mar  1 04:13:26.334: RIP: received v2 update from 192.168.1.2 on FastEthernet0/0
*Mar  1 04:13:26.338:      3.0.0.0/8 via 0.0.0.0 in 2 hops
*Mar  1 04:13:26.338:      192.168.2.0/24 via 0.0.0.0 in 1 hops
R1#

--------------------------------------------------------


####################### 


路由环路,路由过滤,路由条目自动汇总


RIP协议通过最大跳数,水平分割,带毒性逆转的水平分割,抑制计时,触发更新来防止路由环路。

--------------------------------------

网络拓朴如下:

Router1 F0/0 <----> Router2 F0/0 
Router2 F1/0 <----> Router3 F0/0

--------------------------------------
Router1配置如下:

 R1#show run
Building configuration...

Current configuration : 801 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$f/lk$z0GGo6gsEoe9FvepINX8.0
enable password 7 104D000A0618
!
no aaa new-model
!
resource policy
!
memory-size iomem 5
!
!
ip cef    
!
!
!
!
!
!
!
!
!
!
!
!
!
!
!
!
!
!

!
!
!
!         
interface FastEthernet0/0
 ip address 192.168.10.1 255.255.255.0
 duplex auto
 speed auto
!
router rip
 version 2
 network 192.168.10.0

!
ip http server
no ip http secure-server
!
!
!
!
!
!
control-plane
!
!
!
!
!         
!
!
!
!
banner motd ^C Welcome to connect to Router1 ^C
!
line con 0
 exec-timeout 0 0
 password 7 094F471A1A0A
 logging synchronous
 login
line aux 0
line vty 0 4
 exec-timeout 0 0
 password 7 02050D480809
 login
!
!
end

R1#

 

Router2配置如下:

R2#show run
Building configuration...

Current configuration : 915 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$fvzl$woarRpIuoP0obRjdgtJyu0
enable password 7 030752180500
!
no aaa new-model
!
resource policy
!
memory-size iomem 5
!
!
ip cef    
!
!
!
!
!
!
!
!
!
!
!
!
!
!
!
!
!
!

!
!
!
!         
interface FastEthernet0/0
 ip address 192.168.10.2 255.255.255.0
 duplex auto
 speed auto
!
interface FastEthernet1/0
 ip address 192.168.20.1 255.255.255.0
 duplex auto
 speed auto
!
router rip
 version 2
 network 192.168.10.0
 network 192.168.20.0

!
ip http server
no ip http secure-server
!
!
!
!
!
!         
control-plane
!
!
!
!
!
!
!
!
!
banner motd ^C Welcome to connect to Router2 ^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 0822455D0A16
 login
!         
!
end

R2#

 

Router3配置如下:

R3#show run
Building configuration...

Current configuration : 884 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$h7DA$JoAJ0PW8f5khP4mFme2Dd1
enable password 7 05080F1C2243
!
no aaa new-model
!
resource policy
!
memory-size iomem 5
!
!
ip cef    
!
!
!
!
!
!
!
!
!
!
!
!
!
!
!
!
!
!

!
!
!
!         
interface Loopback0
 ip address 192.168.30.1 255.255.255.0

!
interface FastEthernet0/0
 ip address 192.168.20.2 255.255.255.0
 duplex auto
 speed auto
!
router rip
 version 2
 network 192.168.20.0
 network 192.168.30.0

!
ip http server
no ip http secure-server
!
!
!
!
!
!
control-plane
!         
!
!
!
!
!
!
!
!
banner motd ^C Welcome to connect to Router3 ^C
!
line con 0
 exec-timeout 0 0
 password 7 0822455D0A16
 logging synchronous
 login
line aux 0
line vty 0 4
 exec-timeout 0 0
 password 7 0822455D0A16
 login
!
!
end      

R3# 

-----------------------

R2认为通过R3可以到达192.168.30.0.假如,R3的loopback 0当掉了,而且此时R2向R3发送路由更新条目,R3以为可以通过R2到达192.168.30.0,并将跳数加1.这样循环下去,而形成路由环路。这里我们在接口上采用水平分割的方法来防止路由环路.

R1(config)#interface  fa0/0
R1(config-if)#ip split-horizon


R2(config-if)#interface fa0/0
R2(config-if)#ip split-horizon 
R2(config-if)#interface  fa1/0
R2(config-if)#ip split-horizon 

R3(config)#interface fa0/0
R3(config-if)#ip split-horizon

-------------------------

 

RIP路由过滤.

在R3上新增回环接口192.168.40.1,并配置好RIP路由。

R3(config)#interface loopback 1

R3(config-if)#ip address 192.168.40.1 255.255.255.0
R3(config)#router rip
R3(config-router)#network 192.168.40.0

现在R3的路由表中不允许发送192.168.40.0的路由更新信息,允许发送其它段的路由更新。

新建一标准访问控制列表.

R3(config)#access-list 1 deny 192.168.40.0 0.0.0.255 
R3(config)#access-list 1 permit any

RIP路由中配置路由分发列表。

R3(config)#router rip


R3(config-router)#distribute-list 1 out fa0/0

验证:

在R2上无192.168.40.0网段的路由条目,在R1无法Ping R3上的loopback 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

R    192.168.30.0/24 [120/1] via 192.168.20.2, 00:00:21, FastEthernet1/0
C    192.168.10.0/24 is directly connected, FastEthernet0/0
C    192.168.20.0/24 is directly connected, FastEthernet1/0
R2#

 R1#ping 192.168.40.1

Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 192.168.40.1, timeout is 2 seconds:
.....
Success rate is 0 percent (0/5)
R1#

 

--------------------------------------------------------------

 

 RIP V1和V2的默认设置,路由条目都将自动汇总,在V1中用命令no auto-summary企图来关闭路由汇总是徒劳的,系统仍将路由条目自动汇总。V2则可以用此命令来关闭路由自动汇总。

在R3上新建三个回环网卡:

loopback 2                30.30.30.1

loopback 3                30.30.40.1

loopback 4                 30.30.50.1

 

若启用自动汇总,在R1和R2上查看RIP路由表。

R1#show ip route rip 
R    192.168.30.0/24 [120/2] via 192.168.10.2, 00:00:02, FastEthernet0/0
R    192.168.20.0/24 [120/1] via 192.168.10.2, 00:00:02, FastEthernet0/0
R    30.0.0.0/8 [120/2] via 192.168.10.2, 00:00:02, FastEthernet0/0
R1#

R2#show ip route rip
R    192.168.30.0/24 [120/1] via 192.168.20.2, 00:00:16, FastEthernet1/0
R    30.0.0.0/8 [120/1] via 192.168.20.2, 00:00:16, FastEthernet1/0
R2#

关闭自动汇总后在R1和R2上查看RIP路由表。

R3(config-router)#network 30.30.30.0
R3(config-router)#network 30.30.40.0
R3(config-router)#network 30.30.50.0

 

 router rip
 version 2
 network 30.0.0.0
 network 192.168.20.0
 network 192.168.30.0
 network 192.168.40.0
 distribute-list 1 out FastEthernet0/0
 no auto-summary

  

R2#show ip route rip
R    192.168.30.0/24 [120/1] via 192.168.20.2, 00:00:11, FastEthernet1/0
     30.0.0.0/24 is subnetted, 3 subnets
R       30.30.30.0 [120/1] via 192.168.20.2, 00:00:11, FastEthernet1/0
R       30.30.40.0 [120/1] via 192.168.20.2, 00:00:11, FastEthernet1/0
R       30.30.50.0 [120/1] via 192.168.20.2, 00:00:11, FastEthernet1/0

R2#

 

R1#show ip route rip
R    192.168.30.0/24 [120/2] via 192.168.10.2, 00:00:24, FastEthernet0/0
R    192.168.20.0/24 [120/1] via 192.168.10.2, 00:00:24, FastEthernet0/0
R    30.0.0.0/8 [120/2] via 192.168.10.2, 00:00:24, FastEthernet0/0
R1#

 

在R1上所得到的仍是汇总后的路由信息,因为R1的路由信息从R2上获得,R2未关闭路由汇总

R2(config)#router rip
R2(config-router)#no auto-summary

R1#show ip route rip
R    192.168.30.0/24 [120/2] via 192.168.10.2, 00:00:06, FastEthernet0/0
R    192.168.20.0/24 [120/1] via 192.168.10.2, 00:00:06, FastEthernet0/0
     30.0.0.0/24 is subnetted, 3 subnets
R       30.30.30.0 [120/2] via 192.168.10.2, 00:00:06, FastEthernet0/0
R       30.30.40.0 [120/2] via 192.168.10.2, 00:00:06, FastEthernet0/0
R       30.30.50.0 [120/2] via 192.168.10.2, 00:00:06, FastEthernet0/0

R1#

 

#############################


重分布路由


Cisco RIP重分布静态路由.

网络拓朴如下:

rip102.jpg


在R1上启用RIP V2,在R2上启用静态路由和RIP V2,在R3上启用静态路由或默认路由.

确保各点的连通性.

R1配置如下:

R1#
R1#show run
Building configuration...

Current configuration : 965 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$fzTc$wl/SSJD6uihmCuQGnrv3h1
enable password 7 094F471A1A0A
!
no aaa new-model
!
resource policy
!
memory-size iomem 5
!
!
ip cef    
!
!
!
!
!
!
!
!
!
!
!
!
!
!
!
!
!
!

!
!
!
!         
interface Loopback0
 ip address 192.168.10.1 255.255.255.0
!
interface Loopback1
 ip address 192.168.20.1 255.255.255.0
!
interface FastEthernet0/0
 ip address 192.168.1.1 255.255.255.0
 duplex auto
 speed auto
!
router rip
 version 2
 network 192.168.1.0
 network 192.168.10.0
 network 192.168.20.0

!
ip http server
no ip http secure-server
!
!
!
!         
!
!
control-plane
!
!
!
!
!
!
!
!
!
banner motd ^C Welcome to connect to Router1 ^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 00071A150754
 login
!
!
end

R1#


R2配置如下:

R2#show run
Building configuration...

Current configuration : 1113 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$GIC0$Xm8dGNTijhpOJCj/8ZWoO.
enable password 7 110A1016141D
!
no aaa new-model
!
resource policy
!
memory-size iomem 5
!
!
ip cef    
!
!
!
!
!
!
!
!
!
!
!
!
!
!
!
!
!
!

!
!
!
!         
interface FastEthernet0/0
 ip address 192.168.1.2 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
!
router rip
 version 2
 redistribute static metric 2           //重分布静态路由和默认路由
 network 192.168.1.0
 network 192.168.2.0

!
ip http server
no ip http secure-server
ip route 192.168.30.0 255.255.255.0 FastEthernet1/0
ip route 192.168.40.0 255.255.255.0 FastEthernet1/0

!
!
!         
!
!
control-plane
!
!
!
!
!
!
!
!
!
banner motd ^C Welcome to connect to Router2 ^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 121A0C041104
 login
!
!
end

R2#?1?3

 

R3配置如下:

R3#show run
Building configuration...

Current configuration : 1019 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$wPzZ$C/EY79QOz8vhYCL.iUk8L0
enable password 7 030752180500
!
no aaa new-model
!
resource policy
!
memory-size iomem 5
!
!
ip cef    
!
!
!
!
!
!
!
!
!
!
!
!
!
!
!
!
!
!

!
!
!
!         
interface Loopback0
 ip address 192.168.30.1 255.255.255.0
!
interface Loopback1
 ip address 192.168.40.1 255.255.255.0
!
interface FastEthernet0/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.1.0 255.255.255.0 192.168.2.1
ip route 192.168.10.0 255.255.255.0 192.168.2.1
ip route 192.168.20.0 255.255.255.0 192.168.2.1

!
!
!
!
!
!
control-plane
!
!
!
!
!
!
!
!
!
banner motd ^C Welcome to connect to Router3 ^C
!
line con 0
 exec-timeout 0 0
 password 7 060506324F41
 logging synchronous
 login
line aux 0
line vty 0 4
 exec-timeout 0 0
 password 7 02050D480809
 login
!
!         
end

R3#

---------------------------

测试&验证:

R1#
R1#ping 192.168.30.1

Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 192.168.30.1, timeout is 2 seconds:
!!!!!
Success rate is 100 percent (5/5), round-trip min/avg/max = 12/39/104 ms
R1#ping 192.168.40.1

Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 192.168.40.1, timeout is 2 seconds:
!!!!!
Success rate is 100 percent (5/5), round-trip min/avg/max = 8/37/64 ms
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

R    192.168.30.0/24 [120/2] via 192.168.1.2, 00:00:04, FastEthernet0/0
C    192.168.10.0/24 is directly connected, Loopback0
R    192.168.40.0/24 [120/2] via 192.168.1.2, 00:00:04, FastEthernet0/0
C    192.168.20.0/24 is directly connected, Loopback1
C    192.168.1.0/24 is directly connected, FastEthernet0/0
R    192.168.2.0/24 [120/1] via 192.168.1.2, 00:00:04, FastEthernet0/0
R1#
R1#tracerout 192.168.30.1

Type escape sequence to abort.
Tracing the route to 192.168.30.1

  1 192.168.1.2 32 msec 32 msec 40 msec
  2 192.168.2.2 40 msec 44 msec * 
R1#tracerout 192.168.40.1

Type escape sequence to abort.
Tracing the route to 192.168.40.1

  1 192.168.1.2 44 msec 24 msec 56 msec
  2 192.168.2.2 16 msec 60 msec * 
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

S    192.168.30.0/24 is directly connected, FastEthernet1/0
R    192.168.10.0/24 [120/1] via 192.168.1.1, 00:00:25, FastEthernet0/0
S    192.168.40.0/24 is directly connected, FastEthernet1/0
R    192.168.20.0/24 [120/1] via 192.168.1.1, 00:00:25, FastEthernet0/0
C    192.168.1.0/24 is directly connected, FastEthernet0/0
C    192.168.2.0/24 is directly connected, FastEthernet1/0
R2#show ip protocols
Routing Protocol is "rip"
  Outgoing update filter list for all interfaces is not set
  Incoming update filter list for all interfaces is not set
  Sending updates every 30 seconds, next due in 9 seconds
  Invalid after 180 seconds, hold down 180, flushed after 240
  Redistributing: static, rip
  Default version control: send version 2, receive version 2
    Interface             Send  Recv  Triggered RIP  Key-chain
    FastEthernet0/0       2     2                                    
    FastEthernet1/0       2     2                                    
  Automatic network summarization is in effect
  Maximum path: 4
  Routing for Networks:
    192.168.1.0
    192.168.2.0
  Routing Information Sources:
    Gateway         Distance      Last Update
    192.168.1.1          120      00:00:03
  Distance: (default is 120)

R2#

R3#ping 192.168.10.1

Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 192.168.10.1, timeout is 2 seconds:
.!!!!
Success rate is 80 percent (4/5), round-trip min/avg/max = 16/37/76 ms
R3#ping 192.168.20.1

Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 192.168.20.1, timeout is 2 seconds:
!!!!!
Success rate is 100 percent (5/5), round-trip min/avg/max = 8/47/80 ms
R3#tracerout 192.168.10.1

Type escape sequence to abort.
Tracing the route to 192.168.10.1

  1 192.168.2.1 52 msec 20 msec 80 msec
  2 192.168.1.1 100 msec 80 msec * 
R3#

-------------------------------

将R3上的静态路由改为默认路由

R3(config)#no ip route 192.168.10.0 255.255.255.0 192.168.2.1
R3(config)#no ip route 192.168.20.0 255.255.255.0 192.168.2.1
R3(config)#no ip route 192.168.1.0 255.255.255.0 192.168.2.1 
R3(config)#ip route 0.0.0.0 0.0.0.0 192.168.2.1
R3(config)#do 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 192.168.2.1 to network 0.0.0.0

C    192.168.30.0/24 is directly connected, Loopback0
C    192.168.40.0/24 is directly connected, Loopback1
C    192.168.2.0/24 is directly connected, FastEthernet0/0
S*   0.0.0.0/0 [1/0] via 192.168.2.1
R3(config)#

R1#ping 192.168.30.1

Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 192.168.30.1, timeout is 2 seconds:
!!!!!
Success rate is 100 percent (5/5), round-trip min/avg/max = 8/34/88 ms
R1#ping 192.168.40.1

Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 192.168.40.1, timeout is 2 seconds:
!!!!!
Success rate is 100 percent (5/5), round-trip min/avg/max = 28/49/96 ms
R1#

----------------------------------

如果我们在R2上只发布除192.168.30.0以外的静态路由,可以通过建访问控制列表及过滤路由来实现.

R2(config)#router rip

R2(config-router)#distribute-list 1 out static
R2(config-router)#exit  
R2(config)#access-list 1 deny 192.168.30.0
R2(config)#access-list 1 permit any

R1#ping 192.168.40.1

Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 192.168.40.1, timeout is 2 seconds:
!!!!!
Success rate is 100 percent (5/5), round-trip min/avg/max = 24/63/96 ms
R1#ping 192.168.30.1

Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 192.168.30.1, timeout is 2 seconds:
.....
Success rate is 0 percent (0/5)
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

C    192.168.10.0/24 is directly connected, Loopback0
R    192.168.40.0/24 [120/2] via 192.168.1.2, 00:00:22, FastEthernet0/0
C    192.168.20.0/24 is directly connected, Loopback1
C    192.168.1.0/24 is directly connected, FastEthernet0/0
R    192.168.2.0/24 [120/1] via 192.168.1.2, 00:00:22, FastEthernet0/0
R1#

----------------------

重分布默认路由.

R2(config)#ip route 0.0.0.0 0.0.0.0 192.168.2.2
R2(config)#end
R2#show i
*Mar  1 00:05:24.283: %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 192.168.2.2 to network 0.0.0.0

S    192.168.30.0/24 is directly connected, FastEthernet1/0
R    192.168.10.0/24 [120/1] via 192.168.1.1, 00:00:10, FastEthernet0/0
S    192.168.40.0/24 is directly connected, FastEthernet1/0
R    192.168.20.0/24 [120/1] via 192.168.1.1, 00:00:10, FastEthernet0/0
C    192.168.1.0/24 is directly connected, FastEthernet0/0
C    192.168.2.0/24 is directly connected, FastEthernet1/0
S*   0.0.0.0/0 [1/0] via 192.168.2.2

 

R2(config-router)#default-information originate            //只重分布默认路由

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 192.168.1.2 to network 0.0.0.0


C    192.168.10.0/24 is directly connected, Loopback0
R    192.168.40.0/24 [120/2] via 192.168.1.2, 00:00:09, FastEthernet0/0
C    192.168.20.0/24 is directly connected, Loopback1
C    192.168.1.0/24 is directly connected, FastEthernet0/0
R    192.168.2.0/24 [120/1] via 192.168.1.2, 00:00:09, FastEthernet0/0
R*   0.0.0.0/0 [120/2] via 192.168.1.2, 00:00:09, FastEthernet0/0
R1#

-----------------------------------------------

2.RIP重分布EIGRP路由.

网络拓朴如上图:

Router1 F0/0 <----> Router2 F0/0 
Router2 F1/0 <----> Router3 F0/0

Router1与Router2启用RIP V2,Router2与Router3启用EIGRP.

 

Router1配置如下:

R1#
R1#show run
Building configuration...

Current configuration : 965 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$CVZ5$kiSXa39orHOxjGuTIxDuM1
enable password 7 121A0C041104
!
no aaa new-model
!
resource policy
!
memory-size iomem 5
!
!
ip cef    
!
!
!
!
!
!
!
!
!
!
!
!
!
!
!
!
!
!

!
!
!
!         
interface Loopback0
 ip address 192.168.10.1 255.255.255.0
!
interface Loopback1
 ip address 192.168.20.1 255.255.255.0
!
interface FastEthernet0/0
 ip address 192.168.1.1 255.255.255.0
 duplex auto
 speed auto
!
router rip
 version 2
 network 192.168.1.0
 network 192.168.10.0
 network 192.168.20.0

!
ip http server
no ip http secure-server
!
!
!
!         
!
!
control-plane
!
!
!
!
!
!
!
!
!
banner motd ^C Welcome to connect to Router1 ^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 14141B180F0B
 login
!
!
end

R1#

?1?3

Router2配置如下:

R2#
R2#show run
Building configuration...

Current configuration : 1018 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$530f$aEplxPJjGcD7tX1syTK5x1
enable password 7 02050D480809
!
no aaa new-model
!
resource policy
!
memory-size iomem 5
!
!
ip cef    
!
!
!
!
!
!
!
!
!
!
!
!
!
!
!
!
!
!

!
!
!
!         
interface FastEthernet0/0
 ip address 192.168.1.2 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
!
router eigrp 1
 redistribute rip metric 1000 100 255 1 1500         //重分布RIP路由,分别指定带宽,延迟,可靠性,负载及MTU
 network 192.168.2.0

 auto-summary
!
router rip
 version 2
 redistribute eigrp 1 metric  2                            //重分布Eigrp,将跳数设为2
 network 192.168.1.0

!
ip http server
no ip http secure-server
!         
!
!
!
!
!
control-plane
!
!
!
!
!
!
!
!
!
banner motd ^C Welcome to connect to Router2 ^C
!
line con 0
 exec-timeout 0 0
 password 7 094F471A1A0A
 logging synchronous
 login
line aux 0
line vty 0 4
 exec-timeout 0 0
 password 7 110A1016141D
 login
!
!
end

R2#?1?3 

 Router3配置如下:

R3#
R3#show run
Building configuration...

Current configuration : 972 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$RSPC$IavWTBa/gHnrpHTQ6KXrK/
enable password 7 045802150C2E
!
no aaa new-model
!
resource policy
!
memory-size iomem 5
!
!
ip cef    
!
!
!
!
!
!
!
!
!
!
!
!
!
!
!
!
!
!

!
!
!
!         
interface Loopback0
 ip address 192.168.30.1 255.255.255.0
!
interface Loopback1
 ip address 192.168.40.1 255.255.255.0
!
interface FastEthernet0/0
 ip address 192.168.2.2 255.255.255.0
 duplex auto
 speed auto
!
router eigrp 1
 network 192.168.2.0
 network 192.168.30.0
 network 192.168.40.0

 auto-summary
!
ip http server
no ip http secure-server
!
!
!
!         
!
!
control-plane
!
!
!
!
!
!
!
!
!
banner motd ^C Welcome to connect to Router3 ^C
!
line con 0
 exec-timeout 0 0
 password 7 0822455D0A16
 logging synchronous
 login
line aux 0
line vty 0 4
 exec-timeout 0 0
 password 7 030752180500
 login
!
!
end

R3#

---------------------------

测试&验证:

R1#ping 192.168.30.1

Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 192.168.30.1, timeout is 2 seconds:
!!!!!
Success rate is 100 percent (5/5), round-trip min/avg/max = 8/37/84 ms
R1#ping 192.168.40.1

Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 192.168.40.1, timeout is 2 seconds:
!!!!!
Success rate is 100 percent (5/5), round-trip min/avg/max = 20/40/60 ms


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

R    192.168.30.0/24 [120/2] via 192.168.1.2, 00:00:13, FastEthernet0/0
C    192.168.10.0/24 is directly connected, Loopback0
R    192.168.40.0/24 [120/2] via 192.168.1.2, 00:00:13, FastEthernet0/0
C    192.168.20.0/24 is directly connected, Loopback1
C    192.168.1.0/24 is directly connected, FastEthernet0/0
R    192.168.2.0/24 [120/2] via 192.168.1.2, 00:00:13, FastEthernet0/0
R1#

 

R3#ping 192.168.10.1

Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 192.168.10.1, timeout is 2 seconds:
!!!!!
Success rate is 100 percent (5/5), round-trip min/avg/max = 16/46/88 ms
R3#ping 192.168.20.1

Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 192.168.20.1, timeout is 2 seconds:
!!!!!
Success rate is 100 percent (5/5), round-trip min/avg/max = 24/37/56 ms
R3#?1?3R2#
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

D    192.168.30.0/24 [90/156160] via 192.168.2.2, 01:26:43, FastEthernet1/0
R    192.168.10.0/24 [120/1] via 192.168.1.1, 00:00:02, FastEthernet0/0
D    192.168.40.0/24 [90/156160] via 192.168.2.2, 01:23:38, FastEthernet1/0
R    192.168.20.0/24 [120/1] via 192.168.1.1, 00:00:02, FastEthernet0/0

C    192.168.1.0/24 is directly connected, FastEthernet0/0
C    192.168.2.0/24 is directly connected, FastEthernet1/0
R2#

 

R3#
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.30.0/24 is directly connected, Loopback0
D EX 192.168.10.0/24 [170/2588160] via 192.168.2.1, 00:28:42, FastEthernet0/0
C    192.168.40.0/24 is directly connected, Loopback1
D EX 192.168.20.0/24 [170/2588160] via 192.168.2.1, 00:28:42, FastEthernet0/0
D EX 192.168.1.0/24 [170/2588160] via 192.168.2.1, 00:28:42, FastEthernet0/0

C    192.168.2.0/24 is directly connected, FastEthernet0/0
R3#

-------------------------------

3. RIP重分布OSPF。

网络拓朴如上图所示。

Router1 F0/0 <----> Router2 F0/0 
Router2 F1/0 <----> Router3 F0/0

Router1,Router2启用RIP V2,Router2和Router3启用ospf.

Router1配置如下: ?1?3

 
R1#show run
Building configuration...

Current configuration : 965 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$mgQL$S04LVSogutoL.0dWFAwig.
enable password 7 104D000A0618
!
no aaa new-model
!
resource policy
!
memory-size iomem 5
!
!
ip cef    
!
!
!
!
!
!
!
!
!
!
!
!
!
!
!
!
!
!

!
!
!
!         
interface Loopback0
 ip address 192.168.10.1 255.255.255.0
!
interface Loopback1
 ip address 192.168.20.1 255.255.255.0
!
interface FastEthernet0/0
 ip address 192.168.1.1 255.255.255.0
 duplex auto
 speed auto
!
router rip
 version 2
 network 192.168.1.0
 network 192.168.10.0
 network 192.168.20.0

!
ip http server
no ip http secure-server
!
!
!
!         
!
!
control-plane
!
!
!
!
!
!
!
!
!
banner motd ^C Welcome to connect to Router1 ^C
!
line con 0
 exec-timeout 0 0
 password 7 05080F1C2243
 logging synchronous
 login
line aux 0
line vty 0 4
 exec-timeout 0 0
 password 7 110A1016141D
 login
!
!
end

R1#

 

Router2配置如下:


R2#show run
Building configuration...

Current configuration : 1025 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$sBuC$pI1T3oJ0XGOBLA4EUxP3i/
enable password 7 110A1016141D
!
no aaa new-model
!
resource policy
!
memory-size iomem 5
!
!
ip cef    
!
!
!
!
!
!
!
!
!
!
!
!
!
!
!
!
!
!

!
!
!
!         
interface FastEthernet0/0
 ip address 192.168.1.2 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
!
router ospf 10
 log-adjacency-changes
 redistribute rip subnets
 network 192.168.2.0 0.0.0.255 area 0

!
router rip
 version 2
 redistribute ospf 10 metric 2
 network 192.168.1.0

!
ip http server
no ip http secure-server
!         
!
!
!
!
!
control-plane
!
!
!
!
!
!
!
!
!
banner motd ^C Welcome to connect to Router2 ^C
!
line con 0
 exec-timeout 0 0
 password 7 00071A150754
 logging synchronous
 login
line aux 0
line vty 0 4
 exec-timeout 0 0
 password 7 104D000A0618
 login
!
!
end

R2#


 Router3配置如下:

R3#show run
Building configuration...

Current configuration : 1110 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$2nFd$8lhHAmkUagG6uixLLnaEG.
enable password 7 110A1016141D
!
no aaa new-model
!
resource policy
!
memory-size iomem 5
!
!
ip cef    
!
!
!
!
!
!
!
!
!
!
!
!
!
!
!
!
!
!

!
!
!
!         
interface Loopback0
 ip address 192.168.30.1 255.255.255.0
!
interface Loopback1
 ip address 192.168.40.1 255.255.255.0
!
interface FastEthernet0/0
 ip address 192.168.2.2 255.255.255.0
 duplex auto
 speed auto
!
interface FastEthernet1/0
 no ip address
 shutdown
 duplex auto
 speed auto
!
router ospf 10
 log-adjacency-changes
 network 192.168.2.0 0.0.0.255 area 0
 network 192.168.30.0 0.0.0.255 area 0
 network 192.168.40.0 0.0.0.255 area 0

!         
ip http server
no ip http secure-server
!
!
!
!
!
!
control-plane
!
!
!
!
!
!
!
!
!
banner motd ^C Welcome to connect to Router3 ^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 05080F1C2243
 login
!
!
end

R3#

-------------------------

测试&验证:


R1#ping 192.168.30.1

Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 192.168.30.1, timeout is 2 seconds:
!!!!!
Success rate is 100 percent (5/5), round-trip min/avg/max = 12/51/128 ms
R1#ping 192.168.40.1

Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 192.168.40.1, timeout is 2 seconds:
!!!!!
Success rate is 100 percent (5/5), round-trip min/avg/max = 20/32/44 ms
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

R    192.168.30.0/24 [120/2] via 192.168.1.2, 00:00:10, FastEthernet0/0
C    192.168.10.0/24 is directly connected, Loopback0
R    192.168.40.0/24 [120/2] via 192.168.1.2, 00:00:10, FastEthernet0/0
C    192.168.20.0/24 is directly connected, Loopback1
C    192.168.1.0/24 is directly connected, FastEthernet0/0
R    192.168.2.0/24 [120/2] via 192.168.1.2, 00:00:10, FastEthernet0/0
R1#
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

     192.168.30.0/32 is subnetted, 1 subnets
O       192.168.30.1 [110/2] via 192.168.2.2, 00:23:10, FastEthernet1/0
R    192.168.10.0/24 [120/1] via 192.168.1.1, 00:00:15, FastEthernet0/0
     192.168.40.0/32 is subnetted, 1 subnets
O       192.168.40.1 [110/2] via 192.168.2.2, 00:23:10, FastEthernet1/0
R    192.168.20.0/24 [120/1] via 192.168.1.1, 00:00:15, FastEthernet0/0

C    192.168.1.0/24 is directly connected, FastEthernet0/0
C    192.168.2.0/24 is directly connected, FastEthernet1/0
R2#


R3#
R3#ping 192.168.10.1

Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 192.168.10.1, timeout is 2 seconds:
!!!!!
Success rate is 100 percent (5/5), round-trip min/avg/max = 12/36/92 ms
R3#ping 192.168.20.1

Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 192.168.20.1, timeout is 2 seconds:
!!!!!
Success rate is 100 percent (5/5), round-trip min/avg/max = 12/34/76 ms
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.30.0/24 is directly connected, Loopback0
O E2 192.168.10.0/24 [110/20] via 192.168.2.1, 00:24:29, FastEthernet0/0
C    192.168.40.0/24 is directly connected, Loopback1
O E2 192.168.20.0/24 [110/20] via 192.168.2.1, 00:24:29, FastEthernet0/0
O E2 192.168.1.0/24 [110/20] via 192.168.2.1, 00:24:29, FastEthernet0/0

C    192.168.2.0/24 is directly connected, FastEthernet0/0


#######################

VRF是VPN路由转发,用来支持私网时程。RIP支持VRF,在RIP进程中可创建多个RIP实例,分别管理对应的VRF。缺省情况下RIP进程只有一个实例,用来管理全局路由表。当VRF创建后,如需使用RIP管理VRF路由表,可以通过创建新的RIP实例管理该VRF路由表。使用address-family命令使路由设备进入地址族配置子模式(config-router-af)#。当第一次指定子模式关联的VRF时,RIP会创建对应该VRF的RIP实例。在该子模式下,可以配置相应的VRF的RIP实例。该模式下的RIP配置方法与全局路由中的RIP配置方法完全相同。要离开地址族配置子模式并返回路由配置模式,使用exit或者exit-address-family命令。

R1(config)#ip vrf vpn01
R1(config-vrf)#exit
R1(config)#router rip
R1(config-router)#address
R1(config-router)#address-family ?             
  ipv4  Address family

R1(config-router)#address-family ipv4 ?
  unicast  Address Family Modifier
  vrf      Specify parameters for a VPN Routing/Forwarding instance
  <cr>

R1(config-router)#address-family ipv4 vrf ?
  WORD  VPN Routing/Forwarding instance name

R1(config-router)#address-family ipv4 vrf vpn01
 
R1(config-router)#address-family ipv4 vrf vpn01 
R1(config-router-af)#exit

R1(config-router)#address-family ipv4 vrf vpn01 
R1(config-router-af)#exit-address-family 
R1(config-router-af)#?
Router Address Family configuration commands:
  auto-summary            Enable automatic network number summarization
  default                 Set a command to its defaults
  default-information     Control distribution of default information
  default-metric          Set metric of redistributed routes
  distance                Define an administrative distance
  distribute-list         Filter networks in routing updates
  exit-address-family     Exit from Address Family configuration mode
  help                    Description of the interactive help system
  maximum-paths           Forward packets over multiple paths
  neighbor                Specify a neighbor router
  network                 Enable routing on an IP network
  no                      Negate a command or set its defaults
  offset-list             Add or subtract offset from RIP metrics
  redistribute            Redistribute information from another routing
                          protocol
  timers                  Adjust routing timers
  validate-update-source  Perform sanity checks against source address of
                          routing updates
  version                 Set routing protocol version

R1(config-router-af)#exit
R1(config-router)#interface fa0/0
R1(config-if)#ip vrf ?
  forwarding  Configure forwarding table
  receive     Add Interface Address into VRF Table
  sitemap     Configure route-map for routes received from this site

R1(config-if)#ip vrf forwarding ?
  WORD  Table name

R1(config-if)#ip vrf forwarding vpn01
 

-------------------------------------------

 Offset-list通过访问列表来更改跳数.

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

R    192.168.10.0/24 [120/1] via 192.168.1.1, 00:00:07, FastEthernet0/0
R    192.168.20.0/24 [120/1] via 192.168.1.1, 00:00:07, FastEthernet0/0
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
R2#configure terminal
Enter configuration commands, one per line.  End with CNTL/Z.
R2(config)#access-list 1 permit 192.168.10.0
R2(config)#router rip
R2(config-router)#offset
R2(config-router)#offset-list ?
  <0-99>       Access list of networks to apply offset (0 selects all networks)
  <1300-1999>  Access list of networks to apply offset (expanded range)
  WORD         Access-list name

R2(config-router)#offset-list 1 ?
  in   Perform offset on incoming updates
  out  Perform offset on outgoing updates

R2(config-router)#offset-list 1 in  ?
  <0-16>  Offset

R2(config-router)#offset-list 1 in  10
R2(config-router)#exit
R2(config)#access
R2(config)#access-list 2 permit 192.168.2.0
R2(config)#router rip
R2(config-router)#offset-list 2 out 10
R2(config-router)#end
R2#show 
*Mar  1 01:47:14.931: %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

R    192.168.10.0/24 [120/11] via 192.168.1.1, 00:00:01, FastEthernet0/0
R    192.168.20.0/24 [120/1] via 192.168.1.1, 00:00:01, FastEthernet0/0
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
R2#

 R1#


R1#
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

C    192.168.10.0/24 is directly connected, Loopback0
C    192.168.20.0/24 is directly connected, Loopback1
C    192.168.1.0/24 is directly connected, FastEthernet0/0
R    192.168.2.0/24 [120/11] via 192.168.1.2, 00:00:03, FastEthernet0/0
R    192.168.3.0/24 [120/1] via 192.168.1.2, 00:00:03, FastEthernet0/0
R1#


开发者免费试用
开发者免费试用

9:30开抢,每天限量100份.个人认证新用户绑定邮箱后...

立刻前往...
注册认证上云抽好礼
注册认证上云抽好礼

汇聚全站年度销量TOP云产品,每天上午9点限量秒杀,优惠...

立刻前往...
新用户专属大礼包
新用户专属大礼包

新客户无门槛领取总价值高达2860元代金券,先到先得。...

立刻前往...
企业上云钜惠
企业上云钜惠

多款刚需产品,满足企业通用场景需求,云服务器2.5折起...

立刻前往...