实验:调整路由的AD值
【实验名称】调整路由的AD值 (注意:PT有可能不支持distance 99 192.168.1.2 0.0.0.0这条命令,所以我们做实验的时候最好用小凡模拟器)
【实验目的】通过调整路由的管理距离值,实现路由的管理和控制
【实验背景】某企业的3台路由器(RA、RB、RC)运行了RIP路由协议,RA分别与RB、RC连接
【需求分析】通过配置RA的管理距离,使RA只能学到RB的通告路由,并忽略所有路由器的路由,且从RB学到路由的管理距离为99.
【实验拓扑】
【实验设备】路由器3台
【预备知识】路由器基本配置知识、IP路由知识、RIP
【实验原理】修改管理距离来过滤和控制路由
【实验步骤】
步骤1:在路由器上配置IP路由选择和IP地址
Router>enable
Router#conf t
Enter configuration commands, one per line. End with CNTL/Z.
Router(config)#no ip domain lookup
Router(config)#hostname RzA
RzA(config)#int fa0/0
RzA(config-if)#ip address 192.168.1.1 255.255.255.0
RzA(config-if)#no shut
RzA(config-if)#exit
RzA(config)#int fa0/1
RzA(config-if)#ip address 192.168.2.1 255.255.255.0
RzA(config-if)#no shut
RzA(config-if)#exit
RzA(config)#int lo0
RzA(config-if)#ip address 10.1.1.1 255.255.255.0
RzA(config-if)#no shut
RzA(config-if)#
Router>enable
Router#conf t
Enter configuration commands, one per line. End with CNTL/Z.
Router(config)#no ip domain lookup
Router(config)#hostname RzB
RzB(config)#int fa0/0
RzB(config-if)#ip address 192.168.1.2 255.255.255.0
RzB(config-if)#no shut
RzB(config-if)#exit
RzB(config)#int lo0
RzB(config-if)#ip address 192.168.10.1 255.255.255.0
RzB(config-if)#no shut
RzB(config-if)#
Router>enable
Router#conf t
Enter configuration commands, one per line. End with CNTL/Z.
Router(config)#no ip domain lookup
Router(config)#hostname RzC
RzC(config)#int fa0/0
RzC(config-if)#ip address 192.168.2.2 255.255.255.0
RzC(config-if)#no shut
RzC(config-if)#exit
RzC(config)#int lo0
RzC(config-if)#ip address 192.168.20.1 255.255.255.0
RzC(config-if)#no shut
RzC(config-if)#
步骤2:配置RIP协议
RzA(config-if)#exit
RzA(config)#router rip
RzA(config-router)#version 2
RzA(config-router)#network 192.168.1.0
RzA(config-router)#network 192.168.2.0
RzA(config-router)#network 10.1.1.0
RzA(config-router)#no auto-summary
RzA(config-router)#end
RzA#write
Building configuration...
[OK]
RzA#
RzB(config-if)#exit
RzB(config)#router rip
RzB(config-router)#version 2
RzB(config-router)#network 192.168.1.0
RzB(config-router)#network 192.168.10.0
RzB(config-router)#no auto-summary
RzB(config-router)#end
RzB#write
Building configuration...
[OK]
RzB#
RzC(config-if)#exit
RzC(config)#router rip
RzC(config-router)#version 2
RzC(config-router)#network 192.168.2.0
RzC(config-router)#network 192.168.20.0
RzC(config-router)#no auto-summary
RzC(config-router)#end
%SYS-5-CONFIG_I: Configured from console by console
RzC#write
Building configuration...
[OK]
RzC#
步骤3:修改管理距离
RzA(config)#router rip
RzA(config-router)#distance 255
RzA(config-router)#distance 99 192.168.1.2 0.0.0.0
步骤4:验证测试
在路由器A上用命令show ip route 和show ip rip来验证配置
RzA#show ip route
Codes: C - connected, S - static, I - IGRP, 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, E - EGP
i - IS-IS, 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
10.0.0.0/24 is subnetted, 1 subnets
C 10.1.1.0 is directly connected, Loopback0
C 192.168.1.0/24 is directly connected, FastEthernet0/0
C 192.168.2.0/24 is directly connected, FastEthernet0/1
R 192.168.10.0/24 [99/1] via 192.168.1.2, 00:00:14, FastEthernet0/0
R 192.168.20.0/24 [99/1] via 192.168.2.2, 00:00:13, FastEthernet0/1
RzA#
RzA#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 = 31/31/32 ms
RzA#
RzB#ping 10.1.1.1
Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 10.1.1.1, timeout is 2 seconds:
!!!!!
Success rate is 100 percent (5/5), round-trip min/avg/max = 15/28/32 ms
RzB#
RzC>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 = 62/62/63 ms
RzC>
参考配置:
RzA#show running-config
Building configuration...
Current configuration : 664 bytes
!
version 12.4
no service timestamps log datetime msec
no service timestamps debug datetime msec
no service password-encryption
!
hostname RzA
!
!
!
!
!
!
!
!
!
!
!
!
no ip domain-lookup
!
!
!
!
!
!
interface Loopback0
ip address 10.1.1.1 255.255.255.0
!
interface FastEthernet0/0
ip address 192.168.1.1 255.255.255.0
duplex auto
speed auto
!
interface FastEthernet0/1
ip address 192.168.2.1 255.255.255.0
duplex auto
speed auto
!
interface Vlan1
no ip address
shutdown
!
router rip
version 2
network 10.0.0.0
network 192.168.1.0
network 192.168.2.0
distance 255
distance 99 192.168.1.2 0.0.0.0
no auto-summary
!
ip classless
!
!
!
!
!
!
!
line con 0
line vty 0 4
login
!
!
!
end
RzA#
RzB#show running-config
Building configuration...
Current configuration : 625 bytes
!
version 12.4
no service timestamps log datetime msec
no service timestamps debug datetime msec
no service password-encryption
!
hostname RzB
!
!
!
!
!
!
!
!
!
!
!
!
no ip domain-lookup
!
!
!
!
!
!
interface Loopback0
ip address 192.168.10.1 255.255.255.0
!
interface FastEthernet0/0
ip address 192.168.1.2 255.255.255.0
duplex auto
speed auto
!
interface FastEthernet0/1
no ip address
duplex auto
speed auto
shutdown
!
interface Vlan1
no ip address
shutdown
!
router rip
version 2
network 192.168.1.0
network 192.168.10.0
no auto-summary
!
ip classless
!
!
!
!
!
!
!
line con 0
line vty 0 4
login
!
!
!
end
RzB#
RzC#show running-config
Building configuration...
Current configuration : 625 bytes
!
version 12.4
no service timestamps log datetime msec
no service timestamps debug datetime msec
no service password-encryption
!
hostname RzC
!
!
!
!
!
!
!
!
!
!
!
!
no ip domain-lookup
!
!
!
!
!
!
interface Loopback0
ip address 192.168.20.1 255.255.255.0
!
interface FastEthernet0/0
ip address 192.168.2.2 255.255.255.0
duplex auto
speed auto
!
interface FastEthernet0/1
no ip address
duplex auto
speed auto
shutdown
!
interface Vlan1
no ip address
shutdown
!
router rip
version 2
network 192.168.2.0
network 192.168.20.0
no auto-summary
!
ip classless
!
!
!
!
!
!
!
line con 0
line vty 0 4
login
!
!
!
end
RzC#
【实验总结】
通过本节课的学习,通过调整路由的管理距离,实现路由的过滤和控制。
转载于:https://blog.51cto.com/19880423/1053582