实验 4-1 路由引入与路由控制
学习目的
- 掌握OSPF与ISIS相互路由引入的配置方法
- 掌握通过地址前缀列表过滤路由信息的配置方法
- 掌握通过Route-policy过滤路由信息的配置方法
拓扑图
场景
你是你们公司的网络管理员。公司网络中有两部分路由区域,一部分运行OSPF,另外一部分运行ISIS。为了实现网络互通,你需要配置路由相互引入。在典型的双点双向路由引入中,会出现一些问题。为了解决这些问题,避免可能出现的路由环路和次优路径的产生,现在你需要使用到前缀列表和路由策略对路由进行控制。
配置
首先配置各个接口的IP地址
<R1>system-view
Enter system view, return user view with Ctrl+Z.
[R1]interface Serial 1/0/0
[R1-Serial1/0/0]ip address 10.0.12.1 255.255.255.0
[R1-Serial1/0/0]interface GigabitEthernet 0/0/0
[R1-GigabitEthernet0/0/0]ip address 10.0.15.1 255.255.255.0
[R1-GigabitEthernet0/0/0]interface Serial 3/0/0
[R1-Serial3/0/0]ip address 10.0.14.1 255.255.255.0
[R1-Serial3/0/0]interface LoopBack 0
[R1-LoopBack0]ip address 10.0.1.1 255.255.255.255
<R2>system-view
Enter system view, return user view with Ctrl+Z.
[R2]interface Serial 1/0/0
[R2-Serial1/0/0]ip address 10.0.12.2 255.255.255.0
[R2-Serial1/0/0]interface Serial 2/0/0
[R2-Serial2/0/0]ip address 10.0.23.2 255.255.255.0
[R2-Serial2/0/0]interface LoopBack 0
[R2-LoopBack0]ip add 10.0.2.2 255.255.255.255
<R3>system-view
Enter system view, return user view with Ctrl+Z.
[R3]interface Serial 2/0/0
[R3-Serial2/0/0]ip address 10.0.23.3 255.255.255.0
[R3-Serial2/0/0]interface Serial 3/0/0
[R3-Serial3/0/0]ip address 10.0.35.3 255.255.255.0
[R3-Serial3/0/0]interface LoopBack 0
[R3-LoopBack0]ip address 10.0.3.3 255.255.255.255
<R4>system-view
Enter system view, return user view with Ctrl+Z.
[R4]interface Serial 1/0/0
[R4-Serial1/0/0]ip address 10.0.14.4 255.255.255.0
[R4-Serial1/0/0]interface LoopBack 0
[R4-LoopBack0]ip address 10.0.4.4 255.255.255.255
<R5>system-view
Enter system view, return user view with Ctrl+Z.
[R5]interface Serial 1/0/0
[R5-Serial1/0/0]ip address 10.0.35.5 255.255.255.0
[R5-Serial1/0/0]interface GigabitEthernet 0/0/0
[R5-GigabitEthernet0/0/0]ip address 10.0.15.5 255.255.255.0
[R5-GigabitEthernet0/0/0]interface LoopBack 0
[R5-LoopBack0]ip address 10.0.5.5 255.255.255.255
在R1,R2,R4,R5上运行OSPF,所有设备属于区域0
[R1]ospf 1
[R1-ospf-1]area 0
[R1-ospf-1-area-0.0.0.0]network 10.0.12.1 0.0.0.0
[R1-ospf-1-area-0.0.0.0]network 10.0.15.1 0.0.0.0
[R1-ospf-1-area-0.0.0.0]network 10.0.14.1 0.0.0.0
[R1-ospf-1-area-0.0.0.0]network 10.0.1.1 0.0.0.0
[R2]ospf 1
[R2-ospf-1]area 0
[R2-ospf-1-area-0.0.0.0]network 10.0.12.2 0.0.0.0
[R4]ospf 1
[R4-ospf-1]area 0
[R4-ospf-1-area-0.0.0.0]network 10.0.14.4 0.0.0.0
[R4-ospf-1-area-0.0.0.0]network 10.0.4.4 0.0.0.0
[R5]ospf 1
[R5-ospf-1]area 0
[R5-ospf-1-area-0.0.0.0]network 10.0.15.5 0.0.0.0
在R2,R3,R5上配置ISIS
[R2]isis 1
[R2-isis-1]network-entity 49.0001.0000.0000.0002.00
[R2-isis-1]is-level level-2
[R2-isis-1]interface serial2/0/0
[R2-Serial2/0/0]isis enable 1
[R2]interface loopback0
[R2-LoopBack0]isis enable 1
[R3]isis 1
[R3-isis-1]network-entity 49.0001.0000.0000.0003.00
[R3-isis-1]is-level level-2
[R3-isis-1]interface serial2/0/0
[R3-Serial2/0/0]isis enable 1
[R3-Serial2/0/0]interface serial3/0/0
[R3-Serial3/0/0]isis enable 1
[R3-Serial3/0/0]interface loopback0
[R3-LoopBack0]isis enable 1
[R5]isis 1
[R5-isis-1]network-entity 49.0001.0000.0000.0005.00
[R5-isis-1]is-level level-2
[R5-isis-1]interface serial1/0/0
[R5-Serial1/0/0]isis enable 1
[R5-Serial1/0/0]interface loopback 0
[R5-LoopBack0]isis enable 1
在R1上创建静态路由1.1.1.1/32,1.1.1.0/24,1.1.1.0/25,1.1.0.0/16,1.0.0.0/8分别指向NULL 0接口。并使用import-route static命令将这些路由引入OSPF中。
[R1]ip route-static 1.1.1.1 255.255.255.255 NULL 0
[R1]ip route-static 1.1.1.0 255.255.255.0 NULL 0
[R1]ip route-static 1.1.1.0 255.255.255.128 NULL 0
[R1]ip route-static 1.1.0.0 255.255.0.0 NULL 0
[R1]ip route-static 1.0.0.0 255.0.0.0 NULL 0
[R1]ospf 1
[R1-ospf-1]import-route static
在R1上配置前缀列表pref_r1,匹配路由1.1.1.0/24,
创建路由策略policy_r1,调用前缀列表pref_r1,控制R1上引入的静态路由信息。
[R1]ip ip-prefix pref_r1 index 10 permit 1.1.1.0 24 greater-equal 24 less-equal 24
[R1]route-policy policy_r1 permit node 10
[R1-route-policy]if-match ip-prefix pref_r1
[R1-route-policy]quit
[R1]ospf
[R1-ospf-1]import-route static route-policy policy_r1
[R1-ospf-1]quit
在R4上创建Loopback1,地址为10.1.4.4/24,使用import-route direct命令引入OSPF中。
[R4]interface LoopBack 1
[R4-LoopBack1]ip address 10.1.4.4 255.255.255.0
[R4-LoopBack1]quit
[R4]ospf 1
[R4-ospf-1]import-route direct
[R4-ospf-1]quit
在R2上将OSPF引入到ISIS 中,在R5上将ISIS引入到OSPF中。
[R2]isis 1
[R2-isis-1]import-route ospf
[R5]ospf 1
[R5-ospf-1]import-route isis
此时发现环路。
原因是配置了路由引入后,R5既可以在ISIS域中学习到10.1.4.0/24,也可以在OSPF域中学习到这条路由。
由于ISIS的路由优先级比OSPF外部路由的优先级高,从而导致R5使用了从ISIS域中学习到的路由。
在R5上使用路由策略policy_r5,给路由10.1.4.0/24打上标记100。
[R5]acl number 2001
[R5-acl-basic-2001]rule 0 permit source 10.1.4.0 0.0.0.255
[R5-acl-basic-2001]quit
[R5]route-policy add_tag permit node 10
[R5-route-policy]if-match acl 2001
[R5-route-policy]apply tag 100
[R5-route-policy]quit
[R5]route-policy add_tag permit node 20
[R5-route-policy]quit
[R5]ospf 1
[R5-ospf-1]import-route isis route-policy add_tag
[R5-ospf-1]quit
在R5上配置路由策略route_delete,控制向OSPF引入的RIP路由。
[R5]route-policy route_delete deny node 10
[R5-route-policy]if-match acl 2001
[R5-route-policy]quit
[R5]route-policy route_delete permit node 20
[R5-route-policy]quit
[R5]ospf 1
[R5-ospf-1]import-route rip route-policy route_delete
[R5-ospf-1]quit
删除R5上的策略route_delete。
[R5]ospf 1
[R5-ospf-1]undo import-route isis
[R5-ospf-1]quit
[R5]undo route-policy route_delete
[R5]ospf 1
[R5-ospf-1]import-route isis
[R5-ospf-1]quit
在R5上配置策略route_pref,将10.1.4.0/24的路由优先级修改为180,使其小于OSPF外部路由的路由优先级。
[R5]route-policy route_pref permit node 10
[R5-route-policy]if-match acl 2001
[R5-route-policy]apply preference 180
[R5-route-policy]quit
[R5]isis 1
[R5-isis-1]preference route-policy route_pref