实验任务一:用route-policy控制引入路由
1.建立物理连接
2.RTA,RTB,RTC启用ripv2进行路由学习。
[RTA]ip route-static 10.1.0.0 24 10.0.1.2
[RTA]ip route-static 10.1.1.0 24 10.0.1.2
[RTA-rip-1]network 10.0.0.0
[RTA-rip-1]network 192.168.1.0
[RTA-rip-1]version 2
[RTA-rip-1]undo summary
[RTA-rip-1]import-route static
[RTA-rip-1]default cost 2
[RTB-rip-1]network 192.168.1.0
[RTB-rip-1]version 2
[RTB-rip-1]undo summary
[RTC-rip-1]network 192.168.1.0
[RTC-rip-1]version 2
[RTC-rip-1]undo summary
配置完后
[RTB-rip-1]display ip routing-table
Destinations : 20 Routes : 20
Destination/Mask Proto Pre Cost NextHop Interface
0.0.0.0/32 Direct 0 0 127.0.0.1 InLoop0
10.0.1.0/24 RIP 100 1 192.168.1.1 GE0/2
10.1.0.0/24 RIP 100 3 192.168.1.1 GE0/2
10.1.1.0/24 RIP 100 3 192.168.1.1 GE0/2
127.0.0.0/8 Direct 0 0 127.0.0.1 InLoop0
127.0.0.0/32 Direct 0 0 127.0.0.1 InLoop0
127.0.0.1/32 Direct 0 0 127.0.0.1 InLoop0
127.255.255.255/32 Direct 0 0 127.0.0.1 InLoop0
192.168.1.0/30 Direct 0 0 192.168.1.2 GE0/2
192.168.1.0/32 Direct 0 0 192.168.1.2 GE0/2
192.168.1.2/32 Direct 0 0 127.0.0.1 InLoop0
192.168.1.3/32 Direct 0 0 192.168.1.2 GE0/2
192.168.1.4/30 RIP 100 1 192.168.1.1 GE0/2
192.168.2.0/30 Direct 0 0 192.168.2.1 GE0/0
192.168.2.0/32 Direct 0 0 192.168.2.1 GE0/0
192.168.2.1/32 Direct 0 0 127.0.0.1 InLoop0
192.168.2.3/32 Direct 0 0 192.168.2.1 GE0/0
224.0.0.0/4 Direct 0 0 0.0.0.0 NULL0
224.0.0.0/24 Direct 0 0 0.0.0.0 NULL0
255.255.255.255/32 Direct 0 0 127.0.0.1 InLoop0
3.使用router-policy对引入的路由过滤
[RTA]ip prefix-list abc index 10 permit 10.1.0.0 24
[RTA]route-policy abc permit node 10
[RTA-route-policy-abc-10]if-match ip address prefix-list abc
[RTA-rip-1]import-route static route-policy abc
[RTB-rip-1]display ip routing-table
Destinations : 19 Routes : 19
Destination/Mask Proto Pre Cost NextHop Interface
0.0.0.0/32 Direct 0 0 127.0.0.1 InLoop0
10.0.1.0/24 RIP 100 1 192.168.1.1 GE0/2
10.1.0.0/24 RIP 100 3 192.168.1.1 GE0/2
127.0.0.0/8 Direct 0 0 127.0.0.1 InLoop0
127.0.0.0/32 Direct 0 0 127.0.0.1 InLoop0
127.0.0.1/32 Direct 0 0 127.0.0.1 InLoop0
127.255.255.255/32 Direct 0 0 127.0.0.1 InLoop0
192.168.1.0/30 Direct 0 0 192.168.1.2 GE0/2
192.168.1.0/32 Direct 0 0 192.168.1.2 GE0/2
192.168.1.2/32 Direct 0 0 127.0.0.1 InLoop0
192.168.1.3/32 Direct 0 0 192.168.1.2 GE0/2
192.168.1.4/30 RIP 100 1 192.168.1.1 GE0/2
192.168.2.0/30 Direct 0 0 192.168.2.1 GE0/0
192.168.2.0/32 Direct 0 0 192.168.2.1 GE0/0
192.168.2.1/32 Direct 0 0 127.0.0.1 InLoop0
192.168.2.3/32 Direct 0 0 192.168.2.1 GE0/0
224.0.0.0/4 Direct 0 0 0.0.0.0 NULL0
224.0.0.0/24 Direct 0 0 0.0.0.0 NULL0
255.255.255.255/32 Direct 0 0 127.0.0.1 InLoop0
4.ospf路由配置
[RTB-ospf-1-area-0.0.0.0]network 192.168.2.0 0.0.0.3
[RTC-ospf-1-area-0.0.0.0]network 192.168.2.4 0.0.0.3
[RTD-ospf-1-area-0.0.0.0]network 192.168.2.0 0.0.0.3
[RTD-ospf-1-area-0.0.0.0]network 192.168.2.4 0.0.0.3
[RTD-ospf-1-area-0.0.0.0]network 10.0.2.0 0.0.0.255
5.双边界引入
[RTB-rip-1]import-route ospf
[RTC-ospf-1]import-route rip
Destinations : 24 Routes : 24
Destination/Mask Proto Pre Cost NextHop Interface
0.0.0.0/32 Direct 0 0 127.0.0.1 InLoop0
10.0.1.0/24 Direct 0 0 10.0.1.1 GE0/1
10.0.1.0/32 Direct 0 0 10.0.1.1 GE0/1
10.0.1.1/32 Direct 0 0 127.0.0.1 InLoop0
10.0.1.255/32 Direct 0 0 10.0.1.1 GE0/1
10.0.2.0/24 RIP 100 1 192.168.1.2 GE0/2
10.1.0.0/24 Static 60 0 10.0.1.2 GE0/1
10.1.1.0/24 Static 60 0 10.0.1.2 GE0/1
127.0.0.0/8 Direct 0 0 127.0.0.1 InLoop0
127.0.0.0/32 Direct 0 0 127.0.0.1 InLoop0
127.0.0.1/32 Direct 0 0 127.0.0.1 InLoop0
127.255.255.255/32 Direct 0 0 127.0.0.1 InLoop0
192.168.1.0/30 Direct 0 0 192.168.1.1 GE0/2
192.168.1.0/32 Direct 0 0 192.168.1.1 GE0/2
192.168.1.1/32 Direct 0 0 127.0.0.1 InLoop0
192.168.1.3/32 Direct 0 0 192.168.1.1 GE0/2
192.168.1.4/30 Direct 0 0 192.168.1.5 GE0/0
192.168.1.4/32 Direct 0 0 192.168.1.5 GE0/0
192.168.1.5/32 Direct 0 0 127.0.0.1 InLoop0
192.168.1.7/32 Direct 0 0 192.168.1.5 GE0/0
192.168.2.4/30 RIP 100 1 192.168.1.2 GE0/2
224.0.0.0/4 Direct 0 0 0.0.0.0 NULL0
224.0.0.0/24 Direct 0 0 0.0.0.0 NULL0
255.255.255.255/32 Direct 0 0 127.0.0.1 InLoop0
[RTD]display ip routing-table
Destinations : 23 Routes : 23
Destination/Mask Proto Pre Cost NextHop Interface
0.0.0.0/32 Direct 0 0 127.0.0.1 InLoop0
10.0.1.0/24 O_ASE2 150 1 192.168.2.5 GE0/2
10.0.2.0/24 Direct 0 0 10.0.2.1 GE0/1
10.0.2.0/32 Direct 0 0 10.0.2.1 GE0/1
10.0.2.1/32 Direct 0 0 127.0.0.1 InLoop0
10.0.2.255/32 Direct 0 0 10.0.2.1 GE0/1
10.1.0.0/24 O_ASE2 150 1 192.168.2.5 GE0/2
127.0.0.0/8 Direct 0 0 127.0.0.1 InLoop0
127.0.0.0/32 Direct 0 0 127.0.0.1 InLoop0
127.0.0.1/32 Direct 0 0 127.0.0.1 InLoop0
127.255.255.255/32 Direct 0 0 127.0.0.1 InLoop0
192.168.1.0/30 O_ASE2 150 1 192.168.2.5 GE0/2
192.168.2.0/30 Direct 0 0 192.168.2.2 GE0/0
192.168.2.0/32 Direct 0 0 192.168.2.2 GE0/0
192.168.2.2/32 Direct 0 0 127.0.0.1 InLoop0
192.168.2.3/32 Direct 0 0 192.168.2.2 GE0/0
192.168.2.4/30 Direct 0 0 192.168.2.6 GE0/2
192.168.2.4/32 Direct 0 0 192.168.2.6 GE0/2
192.168.2.6/32 Direct 0 0 127.0.0.1 InLoop0
192.168.2.7/32 Direct 0 0 192.168.2.6 GE0/2
224.0.0.0/4 Direct 0 0 0.0.0.0 NULL0
224.0.0.0/24 Direct 0 0 0.0.0.0 NULL0
255.255.255.255/32 Direct 0 0 127.0.0.1 InLoop0
5.路由环路产生
[RTA]ip route-static 10.1.0.0 24 10.0.1.2 preference 120
[RTB-rip-1]preference 200
产生环路:
[RTA]display ip routing-table
Destinations : 24 Routes : 24
Destination/Mask Proto Pre Cost NextHop Interface
0.0.0.0/32 Direct 0 0 127.0.0.1 InLoop0
10.0.1.0/24 Direct 0 0 10.0.1.1 GE0/1
10.0.1.0/32 Direct 0 0 10.0.1.1 GE0/1
10.0.1.1/32 Direct 0 0 127.0.0.1 InLoop0
10.0.1.255/32 Direct 0 0 10.0.1.1 GE0/1
10.0.2.0/24 RIP 100 1 192.168.1.2 GE0/2
10.1.0.0/24 RIP 100 1 192.168.1.2 GE0/2
10.1.1.0/24 Static 60 0 10.0.1.2 GE0/1
127.0.0.0/8 Direct 0 0 127.0.0.1 InLoop0
127.0.0.0/32 Direct 0 0 127.0.0.1 InLoop0
127.0.0.1/32 Direct 0 0 127.0.0.1 InLoop0
127.255.255.255/32 Direct 0 0 127.0.0.1 InLoop0
192.168.1.0/30 Direct 0 0 192.168.1.1 GE0/2
192.168.1.0/32 Direct 0 0 192.168.1.1 GE0/2
192.168.1.1/32 Direct 0 0 127.0.0.1 InLoop0
192.168.1.3/32 Direct 0 0 192.168.1.1 GE0/2
192.168.1.4/30 Direct 0 0 192.168.1.5 GE0/0
192.168.1.4/32 Direct 0 0 192.168.1.5 GE0/0
192.168.1.5/32 Direct 0 0 127.0.0.1 InLoop0
192.168.1.7/32 Direct 0 0 192.168.1.5 GE0/0
192.168.2.4/30 RIP 100 1 192.168.1.2 GE0/2
224.0.0.0/4 Direct 0 0 0.0.0.0 NULL0
224.0.0.0/24 Direct 0 0 0.0.0.0 NULL0
255.255.255.255/32 Direct 0 0 127.0.0.1 InLoop0
[RTB]display ip routing-table
Destinations : 21 Routes : 21
Destination/Mask Proto Pre Cost NextHop Interface
0.0.0.0/32 Direct 0 0 127.0.0.1 InLoop0
10.0.1.0/24 O_ASE2 150 1 192.168.2.2 GE0/0
10.0.2.0/24 O_INTRA 10 2 192.168.2.2 GE0/0
10.1.0.0/24 O_ASE2 150 1 192.168.2.2 GE0/0
127.0.0.0/8 Direct 0 0 127.0.0.1 InLoop0
127.0.0.0/32 Direct 0 0 127.0.0.1 InLoop0
127.0.0.1/32 Direct 0 0 127.0.0.1 InLoop0
127.255.255.255/32 Direct 0 0 127.0.0.1 InLoop0
192.168.1.0/30 Direct 0 0 192.168.1.2 GE0/2
192.168.1.0/32 Direct 0 0 192.168.1.2 GE0/2
192.168.1.2/32 Direct 0 0 127.0.0.1 InLoop0
192.168.1.3/32 Direct 0 0 192.168.1.2 GE0/2
192.168.1.4/30 RIP 200 1 192.168.1.1 GE0/2
192.168.2.0/30 Direct 0 0 192.168.2.1 GE0/0
192.168.2.0/32 Direct 0 0 192.168.2.1 GE0/0
192.168.2.1/32 Direct 0 0 127.0.0.1 InLoop0
192.168.2.3/32 Direct 0 0 192.168.2.1 GE0/0
192.168.2.4/30 O_INTRA 10 2 192.168.2.2 GE0/0
224.0.0.0/4 Direct 0 0 0.0.0.0 NULL0
224.0.0.0/24 Direct 0 0 0.0.0.0 NULL0
255.255.255.255/32 Direct 0 0 127.0.0.1 InLoop0
[RTC]display ip routing-table
Destinations : 21 Routes : 21
Destination/Mask Proto Pre Cost NextHop Interface
0.0.0.0/32 Direct 0 0 127.0.0.1 InLoop0
10.0.1.0/24 RIP 100 1 192.168.1.5 GE0/0
10.0.2.0/24 O_INTRA 10 2 192.168.2.6 GE0/1
10.1.0.0/24 RIP 100 3 192.168.1.5 GE0/0
127.0.0.0/8 Direct 0 0 127.0.0.1 InLoop0
127.0.0.0/32 Direct 0 0 127.0.0.1 InLoop0
127.0.0.1/32 Direct 0 0 127.0.0.1 InLoop0
127.255.255.255/32 Direct 0 0 127.0.0.1 InLoop0
192.168.1.0/30 RIP 100 1 192.168.1.5 GE0/0
192.168.1.4/30 Direct 0 0 192.168.1.6 GE0/0
192.168.1.4/32 Direct 0 0 192.168.1.6 GE0/0
192.168.1.6/32 Direct 0 0 127.0.0.1 InLoop0
192.168.1.7/32 Direct 0 0 192.168.1.6 GE0/0
192.168.2.0/30 O_INTRA 10 2 192.168.2.6 GE0/1
192.168.2.4/30 Direct 0 0 192.168.2.5 GE0/1
192.168.2.4/32 Direct 0 0 192.168.2.5 GE0/1
192.168.2.5/32 Direct 0 0 127.0.0.1 InLoop0
192.168.2.7/32 Direct 0 0 192.168.2.5 GE0/1
224.0.0.0/4 Direct 0 0 0.0.0.0 NULL0
224.0.0.0/24 Direct 0 0 0.0.0.0 NULL0
255.255.255.255/32 Direct 0 0 127.0.0.1 InLoop0
[RTD]display ip routing-table
Destinations : 23 Routes : 23
Destination/Mask Proto Pre Cost NextHop Interface
0.0.0.0/32 Direct 0 0 127.0.0.1 InLoop0
10.0.1.0/24 O_ASE2 150 1 192.168.2.5 GE0/2
10.0.2.0/24 Direct 0 0 10.0.2.1 GE0/1
10.0.2.0/32 Direct 0 0 10.0.2.1 GE0/1
10.0.2.1/32 Direct 0 0 127.0.0.1 InLoop0
10.0.2.255/32 Direct 0 0 10.0.2.1 GE0/1
10.1.0.0/24 O_ASE2 150 1 192.168.2.5 GE0/2
127.0.0.0/8 Direct 0 0 127.0.0.1 InLoop0
127.0.0.0/32 Direct 0 0 127.0.0.1 InLoop0
127.0.0.1/32 Direct 0 0 127.0.0.1 InLoop0
127.255.255.255/32 Direct 0 0 127.0.0.1 InLoop0
192.168.1.0/30 O_ASE2 150 1 192.168.2.5 GE0/2
192.168.2.0/30 Direct 0 0 192.168.2.2 GE0/0
192.168.2.0/32 Direct 0 0 192.168.2.2 GE0/0
192.168.2.2/32 Direct 0 0 127.0.0.1 InLoop0
192.168.2.3/32 Direct 0 0 192.168.2.2 GE0/0
192.168.2.4/30 Direct 0 0 192.168.2.6 GE0/2
192.168.2.4/32 Direct 0 0 192.168.2.6 GE0/2
192.168.2.6/32 Direct 0 0 127.0.0.1 InLoop0
192.168.2.7/32 Direct 0 0 192.168.2.6 GE0/2
224.0.0.0/4 Direct 0 0 0.0.0.0 NULL0
224.0.0.0/24 Direct 0 0 0.0.0.0 NULL0
255.255.255.255/32 Direct 0 0 127.0.0.1 InLoop0
产生环路的原因,双边界引入,RTB拥有rip路由和ospf路由表,RTD引入rip进入ospf表,外部路由优先级是150,设置RTB的rip优先级为200,优先选择ospf的路由,指向引入的路由器RTD,RTD路由器rip100,ospf150,选择rip路由表到达10.1.0.0/24的路由,指向RTA,在RTA设置静态路由优先级120大于rip路由,RTA选择rip路由指向RTB,为什么指向RTB?因为RTB引入rip到ospf路由,RTA引入静态路由到rip,RTD再次把这条路由从ospf引入会rip里面,rip以为,从ospf学到该条路由,下一跳指向RTB。
6.使用TAG选择性引入
[RTB-rip-1]import-route ospf tag 10
[RTC]route-policy abc deny node 10
[RTC-route-policy-abc-10]if-match tag 10
[RTC]route-policy abc deny node 20
[RTA]display ip routing-table
Destinations : 24 Routes : 24
Destination/Mask Proto Pre Cost NextHop Interface
0.0.0.0/32 Direct 0 0 127.0.0.1 InLoop0
10.0.1.0/24 Direct 0 0 10.0.1.1 GE0/1
10.0.1.0/32 Direct 0 0 10.0.1.1 GE0/1
10.0.1.1/32 Direct 0 0 127.0.0.1 InLoop0
10.0.1.255/32 Direct 0 0 10.0.1.1 GE0/1
10.0.2.0/24 RIP 100 1 192.168.1.2 GE0/2
10.1.0.0/24 Static 120 0 10.0.1.2 GE0/1
10.1.1.0/24 Static 60 0 10.0.1.2 GE0/1
127.0.0.0/8 Direct 0 0 127.0.0.1 InLoop0
127.0.0.0/32 Direct 0 0 127.0.0.1 InLoop0
127.0.0.1/32 Direct 0 0 127.0.0.1 InLoop0
127.255.255.255/32 Direct 0 0 127.0.0.1 InLoop0
192.168.1.0/30 Direct 0 0 192.168.1.1 GE0/2
192.168.1.0/32 Direct 0 0 192.168.1.1 GE0/2
192.168.1.1/32 Direct 0 0 127.0.0.1 InLoop0
192.168.1.3/32 Direct 0 0 192.168.1.1 GE0/2
192.168.1.4/30 Direct 0 0 192.168.1.5 GE0/0
192.168.1.4/32 Direct 0 0 192.168.1.5 GE0/0
192.168.1.5/32 Direct 0 0 127.0.0.1 InLoop0
192.168.1.7/32 Direct 0 0 192.168.1.5 GE0/0
192.168.2.4/30 RIP 100 1 192.168.1.2 GE0/2
224.0.0.0/4 Direct 0 0 0.0.0.0 NULL0
224.0.0.0/24 Direct 0 0 0.0.0.0 NULL0
255.255.255.255/32 Direct 0 0 127.0.0.1 InLoop0
//import-route引入外部路由,只把路由表有效的路由引入到协议,且引入的路由不在本地路由表中出现,只传递给其他路由器,要在RTA上查看引入后的路由。