举例:配置OSPF路由过滤功能(采用export关键字对引入的外部路由进行过滤,该参数只能在ASBR上生效。)
举例:配置OSPF路由过滤功能(采用export关键字对引入的外部路由进行过滤,该参数只能在ASBR上生效。)
举例:配置OSPF路由过滤功能
组网需求
如图5-57所示,DeviceA、DeviceB、DeviceC、DeviceD、DeviceE运行OSPF协议实现互通,DeviceE、DeviceF运行RIP协议实现互通。在DeviceE上部署OSPF和RIP协议互引,实现所有Device设备互通。PC1通过DeviceC连接网络,PC2、PC3通过DeviceD连接网络,PC4、PC5通过DeviceF连接网络。现要求:
在DeviceE上对引入的路由进行过滤,使得PC4所在网段无法访问PC1、PC2、PC3。
在DeviceC上使用路由过滤功能,使得PC1所在网段无法访问PC2。
在DeviceD上使用路由过滤功能,使得PC2、PC3所在网段无法访问PC5。
图5-57 配置OSPF路由过滤功能组网图
本例中interface1,interface2,interface3分别代表Vlanif10,Vlanif20,Vlanif30。

配置注意事项
在配置过程中,需注意以下事项:
路由过滤功能中采用export关键字对引入的外部路由进行过滤,该参数只能在ASBR上生效。
路由过滤功能只是对路由表中相关路由信息过滤,并不是过滤掉OSPF中通告的LSA。
由于路由通信是双向的,使用路由过滤功能将某一目的网段过滤后,该设备下联的其它网段无法访问这个目的网段的设备,这个目的网段的设备也不能访问源地址网段的设备。
路由过滤功能配合ACL使用时,必须将最后一条规则设置为允许所有源地址通过才能避免将所有网段路由全部过滤掉。
配置思路
采用如下的思路配置OSPF路由过滤功能:
按照组网在各设备上使能OSPF或RIP协议。
配置OSPF和RIP协议互引。
配置ACL规则及路由过滤功能。
操作步骤
配置各接口的IP地址,详细配置过程请参见配置脚本。
配置OSPF基本功能。
# 配置DeviceA。
[DeviceA] router id 1.1.1.1
[DeviceA] ospf 1
[DeviceA-ospf-1] area 0
[DeviceA-ospf-1-area-0.0.0.0] network 10.1.1.0 0.0.0.255
[DeviceA-ospf-1-area-0.0.0.0] quit
[DeviceA-ospf-1] area 1
[DeviceA-ospf-1-area-0.0.0.1] network 10.4.1.0 0.0.0.255
[DeviceA-ospf-1-area-0.0.0.1] quit
[DeviceA-ospf-1] area 2
[DeviceA-ospf-1-area-0.0.0.2] network 10.2.1.0 0.0.0.255
[DeviceA-ospf-1-area-0.0.0.2] quit
[DeviceA-ospf-1] quit
# 配置DeviceB。
[DeviceB] router id 2.2.2.2
[DeviceB] ospf 1
[DeviceB-ospf-1] area 0
[DeviceB-ospf-1-area-0.0.0.0] network 10.1.1.0 0.0.0.255
[DeviceB-ospf-1-area-0.0.0.0] quit
[DeviceB-ospf-1] area 3
[DeviceB-ospf-1-area-0.0.0.3] network 10.3.1.0 0.0.0.255
[DeviceB-ospf-1-area-0.0.0.3] quit
[DeviceB-ospf-1] quit
# 配置DeviceC。
[DeviceC] router id 3.3.3.3
[DeviceC] ospf 1
[DeviceC-ospf-1] area 2
[DeviceC-ospf-1-area-0.0.0.2] network 10.2.1.0 0.0.0.255
[DeviceC-ospf-1-area-0.0.0.2] network 10.10.3.0 0.0.0.255
[DeviceC-ospf-1-area-0.0.0.2] quit
[DeviceC-ospf-1] quit
# 配置DeviceD。
[DeviceD] router id 4.4.4.4
[DeviceD] ospf 1
[DeviceD-ospf-1] area 3
[DeviceD-ospf-1-area-0.0.0.3] network 10.3.1.0 0.0.0.255
[DeviceD-ospf-1-area-0.0.0.3] network 10.10.1.0 0.0.0.255
[DeviceD-ospf-1-area-0.0.0.3] network 10.10.2.0 0.0.0.255
[DeviceD-ospf-1-area-0.0.0.3] quit
[DeviceD-ospf-1] quit
# 配置DeviceE。
[DeviceE] router id 5.5.5.5
[DeviceE] ospf 1
[DeviceE-ospf-1] area 1
[DeviceE-ospf-1-area-0.0.0.1] network 10.4.1.0 0.0.0.255
[DeviceE-ospf-1-area-0.0.0.1] quit
[DeviceE-ospf-1] quit
[DeviceE] rip 1
[DeviceE-rip-1] network 10.0.0.0
[DeviceE-rip-1] version 2
[DeviceE-rip-1] quit
# 配置DeviceF。
[DeviceF] rip 1
[DeviceF-rip-1] network 10.0.0.0
[DeviceF-rip-1] network 172.16.0.0
[DeviceF-rip-1] network 192.168.1.0
[DeviceF-rip-1] version 2
[DeviceF-rip-1] quit
配置OSPF和RIP协议互引。
[DeviceE] ospf 1
[DeviceE-ospf-1] import-route direct
[DeviceE-ospf-1] import-route rip 1
[DeviceE-ospf-1] quit
[DeviceE] rip 1
[DeviceE-rip-1] import-route direct
[DeviceE-rip-1] import-route ospf 1
[DeviceE-rip-1] quit
配置ACL规则及路由过滤功能。
# 在DeviceE上对引入的路由进行过滤,使得PC4所在网段无法访问PC1、PC2、PC3。
[DeviceE] acl number 2000
[DeviceE-acl4-basic-2000] rule 0 deny source 172.16.1.0 0.0.0.255
[DeviceE-acl4-basic-2000] rule 5 permit
[DeviceE-acl4-basic-2000] quit
[DeviceE] ospf 1
[DeviceE-ospf-1] filter-policy 2000 export rip 1
[DeviceE-ospf-1] quit
# 在DeviceC上使用路由过滤功能,使得PC1所在网段无法访问PC2。
[DeviceC] acl number 2000
[DeviceC-acl4-basic-2000] rule 0 deny source 10.10.2.0 0.0.0.255
[DeviceC-acl4-basic-2000] rule 5 permit
[DeviceC-acl4-basic-2000] quit
[DeviceC] ospf 1
[DeviceC-ospf-1] filter-policy 2000 import
[DeviceC-ospf-1] quit
# 在DeviceD上使用路由过滤功能,使得PC2、PC3所在网段无法访问PC5。
[DeviceD] acl number 2000
[DeviceD-acl4-basic-2000] rule 0 deny source 192.168.1.0 0.0.0.255
[DeviceD-acl4-basic-2000] rule 5 permit
[DeviceD-acl4-basic-2000] quit
[DeviceD] ospf 1
[DeviceD-ospf-1] filter-policy 2000 import
[DeviceD-ospf-1] quit
检查配置结果
# 在DeviceF上使用源地址172.16.1.1分别Ping目标地址10.10.3.1、10.10.2.1、10.10.1.1均不通,说明PC4所在网段无法访问PC1、PC2、PC3所在网段。
[DeviceF] ping -a 172.16.1.1 10.10.3.1 PING 10.10.3.1: 56 data bytes, press CTRL_C to break Request time out Request time out Request time out Request time out Request time out --- 10.10.3.1 ping statistics --- 5 packet(s) transmitted 0 packet(s) received 100.00% packet loss
[DeviceF] ping -a 172.16.1.1 10.10.2.1 PING 10.10.2.1: 56 data bytes, press CTRL_C to break Request time out Request time out Request time out Request time out Request time out --- 10.10.2.1 ping statistics --- 5 packet(s) transmitted 0 packet(s) received 100.00% packet loss
[DeviceF] ping -a 172.16.1.1 10.10.1.1 PING 10.10.1.1: 56 data bytes, press CTRL_C to break Request time out Request time out Request time out Request time out Request time out --- 10.10.1.1 ping statistics --- 5 packet(s) transmitted 0 packet(s) received 100.00% packet loss
# 在DeviceC上使用源地址10.10.3.1 Ping目标地址10.10.2.1不通,说明PC1所在网段无法访问PC2所在网段。
[DeviceC] ping -a 10.10.3.1 10.10.2.1 PING 10.10.2.1: 56 data bytes, press CTRL_C to break Request time out Request time out Request time out Request time out Request time out --- 10.10.2.1 ping statistics --- 5 packet(s) transmitted 0 packet(s) received 100.00% packet loss
# 在DeviceD上使用源地址10.10.1.1和10.10.2.1分别Ping目标地址192.168.1.1均不通,说明PC2和PC3所在网段无法访问PC5。
[DeviceD] ping -a 10.10.1.1 192.168.1.1 PING 192.168.1.1: 56 data bytes, press CTRL_C to break Request time out Request time out Request time out Request time out Request time out --- 192.168.1.1 ping statistics --- 5 packet(s) transmitted 0 packet(s) received 100.00% packet loss
[DeviceD] ping -a 10.10.2.1 192.168.1.1 PING 192.168.1.1: 56 data bytes, press CTRL_C to break Request time out Request time out Request time out Request time out Request time out --- 192.168.1.1 ping statistics --- 5 packet(s) transmitted 0 packet(s) received 100.00% packet loss
配置脚本
DeviceA
# sysname DeviceA # vlan batch 10 20 30 # router id 1.1.1.1 # interface Vlanif10 ip address 10.1.1.1 255.255.255.0 # interface Vlanif20 ip address 10.2.1.1 255.255.255.0 # interface Vlanif30 ip address 10.4.1.1 255.255.255.0 # interface 10GE1/0/1 port link-type trunk port trunk allow-pass vlan 10 # interface 10GE1/0/2 port link-type trunk port trunk allow-pass vlan 20 # interface 10GE1/0/3 port link-type trunk port trunk allow-pass vlan 30 # ospf 1 area 0.0.0.0 network 10.1.1.0 0.0.0.255 area 0.0.0.1 network 10.4.1.0 0.0.0.255 area 0.0.0.2 network 10.2.1.0 0.0.0.255 # return
DeviceB
# sysname DeviceB # vlan batch 10 20 # router id 2.2.2.2 # interface Vlanif10 ip address 10.1.1.2 255.255.255.0 # interface Vlanif20 ip address 10.3.1.1 255.255.255.0 # interface 10GE1/0/1 port link-type trunk port trunk allow-pass vlan 10 # interface 10GE1/0/2 port link-type trunk port trunk allow-pass vlan 20 # ospf 1 area 0.0.0.0 network 10.1.1.0 0.0.0.255 area 0.0.0.3 network 10.3.1.0 0.0.0.255 # return
DeviceC
# sysname DeviceC # acl number 2000 rule 0 deny source 10.10.2.0 0.0.0.255 rule 5 permit # vlan batch 10 20 # router id 3.3.3.3 # interface Vlanif10 ip address 10.2.1.2 255.255.255.0 # interface Vlanif20 ip address 10.10.3.1 255.255.255.0 # interface 10GE1/0/1 port link-type trunk port trunk allow-pass vlan 10 # interface 10GE1/0/2 port link-type trunk port trunk allow-pass vlan 20 # ospf 1 filter-policy 2000 import area 0.0.0.2 network 10.2.1.0 0.0.0.255 network 10.10.3.0 0.0.0.255 # return
DeviceD
# sysname DeviceD # acl number 2000 rule 0 deny source 192.168.1.0 0.0.0.255 rule 5 permit # vlan batch 10 20 30 # router id 4.4.4.4 # interface Vlanif10 ip address 10.3.1.2 255.255.255.0 # interface Vlanif20 ip address 10.10.1.1 255.255.255.0 # interface Vlanif30 ip address 10.10.2.1 255.255.255.0 # interface 10GE1/0/1 port link-type trunk port trunk allow-pass vlan 10 # interface 10GE1/0/2 port link-type trunk port trunk allow-pass vlan 20 # interface 10GE1/0/3 port link-type trunk port trunk allow-pass vlan 30 # ospf 1 filter-policy 2000 import area 0.0.0.3 network 10.3.1.0 0.0.0.255 network 10.10.1.0 0.0.0.255 network 10.10.2.0 0.0.0.255 # return
DeviceE
# sysname DeviceE # router id 5.5.5.5 # acl number 2000 rule 0 deny source 172.16.1.0 0.0.0.255 rule 5 permit # vlan batch 10 20 # interface Vlanif10 ip address 10.4.1.2 255.255.255.0 # interface Vlanif20 ip address 10.5.1.1 255.255.255.0 # interface 10GE1/0/1 port link-type trunk port trunk allow-pass vlan 10 # interface 10GE1/0/2 port link-type trunk port trunk allow-pass vlan 20 # ospf 1 import-route direct import-route rip 1 filter-policy 2000 export rip 1 area 0.0.0.1 network 10.4.1.0 0.0.0.255 # rip 1 version 2 network 10.0.0.0 import-route direct import-route ospf 1 # return
DeviceF
# sysname DeviceF # vlan batch 10 20 30 # interface Vlanif10 ip address 10.5.1.2 255.255.255.0 # interface Vlanif20 ip address 172.16.1.1 255.255.255.0 # interface Vlanif30 ip address 192.168.1.1 255.255.255.0 # interface 10GE1/0/1 port link-type trunk port trunk allow-pass vlan 10 # interface 10GE1/0/2 port link-type trunk port trunk allow-pass vlan 20 # interface 10GE1/0/3 port link-type trunk port trunk allow-pass vlan 30 # rip 1 version 2 network 10.0.0.0 network 172.16.0.0 network 192.168.1.0 # return
2、本资源基本为原创,部分来源其他付费资源平台或互联网收集,如有侵权请联系及时处理。
3、本站大部分文章的截图来源实验测试环境,请不要在生产环境中随意模仿,以免带来灾难性后果。
转载请保留出处: www.zh-cjh.com珠海陈坚浩博客 » 举例:配置OSPF路由过滤功能(采用export关键字对引入的外部路由进行过滤,该参数只能在ASBR上生效。)
作者: 小编
| 手机扫一扫,手机上查看此文章: |
一切源于价值!
其他 模板文件不存在: ./template/plugins/comment/pc/index.htm