设为首页 收藏本站
查看: 4252|回复: 6

[经验分享] OSPF 前缀列表过滤路由

[复制链接]

尚未签到

发表于 2012-9-6 08:46:26 | 显示全部楼层 |阅读模式
Cisco OSPF结合前缀列表进行路由过滤实验
一、实验拓扑:
50699e3786d09b0ded06979f43f1d6b3.jpg
二、配置实验1:前缀列表过滤路由:
1、基本的配置:
R1:
interface Loopback0
ip address 1.1.1.1 255.255.255.255
interface FastEthernet0/0
ip address 192.168.1.1 255.255.255.0
duplex auto
speed auto
router ospf 10
router-id 1.1.1.1
log-adjacency-changes
network 1.1.1.1 0.0.0.0 area 1
network 192.168.1.0 0.0.0.255 area 0

R2:
interface Loopback0
ip address 2.2.2.2 255.255.255.255
interface Loopback1
ip address 3.3.3.3 255.255.255.255
interface Loopback2
ip address 4.4.4.4 255.255.255.255        
interface FastEthernet0/0
ip address 192.168.1.2 255.255.255.0
duplex auto
speed auto
router ospf 10
router-id 3.3.3.3
log-adjacency-changes
network 2.2.2.2 0.0.0.0 area 2
network 3.3.3.3 0.0.0.0 area 0
network 4.4.4.4 0.0.0.0 area 4
network 192.168.1.0 0.0.0.255 area 0

2、测试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
     1.0.0.0/32 is subnetted, 1 subnets
C       1.1.1.1 is directly connected, Loopback0
     2.0.0.0/32 is subnetted, 1 subnets
O IA    2.2.2.2 [110/2] via 192.168.1.2, 00:00:13, FastEthernet0/0
     3.0.0.0/32 is subnetted, 1 subnets
O       3.3.3.3 [110/2] via 192.168.1.2, 00:00:13, FastEthernet0/0
     4.0.0.0/32 is subnetted, 1 subnets
O IA    4.4.4.4 [110/2] via 192.168.1.2, 00:00:13, FastEthernet0/0
C    192.168.1.0/24 is directly connected, FastEthernet0/0

3、测试通过在R1上部署前缀列表,让R1只能学习到4.4.4.4的地址:
ip prefix-list filter-ospf seq 5 deny 2.2.2.2/32
ip prefix-list filter-ospf seq 10 deny 3.3.3.3/32
ip prefix-list filter-ospf seq 15 permit 0.0.0.0/0 le 32    //配置允许所有的路由匹配通过
router ospf 10
distribute-list prefix filter-ospf in

4、再次测试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
     1.0.0.0/32 is subnetted, 1 subnets
C       1.1.1.1 is directly connected, Loopback0
     4.0.0.0/32 is subnetted, 1 subnets
O IA    4.4.4.4 [110/2] via 192.168.1.2, 00:00:05, FastEthernet0/0
C    192.168.1.0/24 is directly connected, FastEthernet0/0

三、配置实验2:前缀列表链路分流:
1、在R1R2之间增加一条链路,采用前缀列表分流。
R1:
interface Loopback0
ip address 1.1.1.1 255.255.255.255
interface Ethernet0/0
ip address 192.168.1.1 255.255.255.252
interface Ethernet0/1
ip address 192.168.1.5 255.255.255.252
router ospf 10
router-id 1.1.1.1
log-adjacency-changes
network 1.1.1.1 0.0.0.0 area 1
network 192.168.1.0 0.0.0.3 area 0
network 192.168.1.4 0.0.0.3 area 0

R2:
interface Loopback0
ip address 2.2.2.2 255.255.255.255
interface Loopback1
ip address 3.3.3.3 255.255.255.255
interface Loopback2
ip address 4.4.4.4 255.255.255.255        
interface Ethernet0/0
ip address 192.168.1.2 255.255.255.252
interface Ethernet0/1
ip address 192.168.1.6 255.255.255.252
router ospf 10
router-id 3.3.3.3
log-adjacency-changes
network 2.2.2.2 0.0.0.0 area 2
network 3.3.3.3 0.0.0.0 area 0
network 4.4.4.4 0.0.0.0 area 4
network 192.168.1.0 0.0.0.3 area 0
network 192.168.1.4 0.0.0.3 area 0

2、查看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
     1.0.0.0/32 is subnetted, 1 subnets
C       1.1.1.1 is directly connected, Loopback0
     2.0.0.0/32 is subnetted, 1 subnets
O IA    2.2.2.2 [110/11] via 192.168.1.6, 00:00:07, Ethernet0/1
                [110/11] via 192.168.1.2, 00:00:07, Ethernet0/0
     3.0.0.0/32 is subnetted, 1 subnets
O       3.3.3.3 [110/11] via 192.168.1.6, 00:00:07, Ethernet0/1
                [110/11] via 192.168.1.2, 00:00:07, Ethernet0/0
     4.0.0.0/32 is subnetted, 1 subnets
O IA    4.4.4.4 [110/11] via 192.168.1.6, 00:00:11, Ethernet0/1
                [110/11] via 192.168.1.2, 00:00:11, Ethernet0/0
     192.168.1.0/30 is subnetted, 2 subnets
C       192.168.1.0 is directly connected, Ethernet0/0
C       192.168.1.4 is directly connected, Ethernet0/1

3、在R1上配置前缀列表进行链路分流:
ip prefix-list filter1 seq 5 deny 3.3.3.3/32
ip prefix-list filter1 seq 10 deny 4.4.4.4/32
ip prefix-list filter1 seq 15 permit 0.0.0.0/0 le 32
ip prefix-list filter2 seq 5 deny 2.2.2.2/32
ip prefix-list filter2 seq 10 deny 3.3.3.3/32
ip prefix-list filter2 seq 15 permit 0.0.0.0/0 le 32
router ospf 10
distribute-list prefix filter1 in Ethernet0/0
distribute-list prefix filter2 in Ethernet0/1

4、查看配置了前缀列表后的路由表:
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
     1.0.0.0/32 is subnetted, 1 subnets
C       1.1.1.1 is directly connected, Loopback0
     2.0.0.0/32 is subnetted, 1 subnets
O IA    2.2.2.2 [110/11] via 192.168.1.2, 00:00:06, Ethernet0/0
     4.0.0.0/32 is subnetted, 1 subnets
O IA    4.4.4.4 [110/11] via 192.168.1.6, 00:00:06, Ethernet0/1
     192.168.1.0/30 is subnetted, 2 subnets
C       192.168.1.0 is directly connected, Ethernet0/0
C       192.168.1.4 is directly connected, Ethernet0/1      //实现分流

四、配置实验3:前缀列表过滤路由作用于路由重分发:
1OSPFEIGRP路由重分发使用前缀列表控制路由:
R1:
interface Serial0/0
ip address 172.16.1.1 255.255.255.252
serial restart-delay 0
router ospf 10
router-id 1.1.1.1
log-adjacency-changes
network 172.16.1.0 0.0.0.3 area 0

R2:
interface Loopback0
ip address 2.2.2.2 255.255.255.0
interface Serial0/0
ip address 172.16.1.2 255.255.255.252
serial restart-delay 0
interface Serial0/1
ip address 198.16.1.1 255.255.255.252
serial restart-delay 0
router eigrp 10
network 198.16.1.0 0.0.0.3
router ospf 10
router-id 2.2.2.2
log-adjacency-changes
redistribute eigrp 10 subnets
network 2.2.2.0 0.0.0.255 area 1
network 172.16.1.0 0.0.0.3 area 0

R3:
interface Loopback0
ip address 3.3.3.3 255.255.255.0
interface Loopback1
ip address 4.4.4.4 255.255.255.0
interface Serial0/1
ip address 198.16.1.2 255.255.255.252
serial restart-delay 0
router eigrp 10
network 3.3.3.0 0.0.0.255
network 4.4.4.0 0.0.0.255
network 198.16.1.0 0.0.0.3
no auto-summary

2、查看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
     2.0.0.0/32 is subnetted, 1 subnets
O IA    2.2.2.2 [110/65] via 172.16.1.2, 00:00:04, Serial0/0
     3.0.0.0/24 is subnetted, 1 subnets
O E2    3.3.3.0 [110/20] via 172.16.1.2, 00:00:04, Serial0/0
     4.0.0.0/24 is subnetted, 1 subnets
O E2    4.4.4.0 [110/20] via 172.16.1.2, 00:00:04, Serial0/0
//从外部网络学习到了3.3.3.0/244.4.4.0/24198.16.1.0/30
     172.16.0.0/30 is subnetted, 1 subnets         
C       172.16.1.0 is directly connected, Serial0/0
     198.16.1.0/30 is subnetted, 1 subnets
O E2    198.16.1.0 [110/20] via 172.16.1.2, 00:00:04, Serial0/0
//学到了全路由

3、在R2上布置前缀列表,让R1只能从外部网络学习到4.4.4.4/24
R2(config)#ip prefix-list filter seq 5 permit 4.4.4.0/24
R2(config)#router ospf 10
R2(config-router)#distribute-list prefix filter out eigrp 10   //允许EIGRP路由4.4.4.4被放入OSPF路由表

4、测试R1的网络路由表:发现只有4.4.4.0的路由被学习到。
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
     2.0.0.0/32 is subnetted, 1 subnets
O IA    2.2.2.2 [110/65] via 172.16.1.2, 00:02:56, Serial0/0
     4.0.0.0/24 is subnetted, 1 subnets
O E2    4.4.4.0 [110/20] via 172.16.1.2, 00:02:56, Serial0/0
     172.16.0.0/30 is subnetted, 1 subnets
C       172.16.1.0 is directly connected, Serial0/0

运维网声明 1、欢迎大家加入本站运维交流群:群②:261659950 群⑤:202807635 群⑦870801961 群⑧679858003
2、本站所有主题由该帖子作者发表,该帖子作者与运维网享有帖子相关版权
3、所有作品的著作权均归原作者享有,请您和我们一样尊重他人的著作权等合法权益。如果您对作品感到满意,请购买正版
4、禁止制作、复制、发布和传播具有反动、淫秽、色情、暴力、凶杀等内容的信息,一经发现立即删除。若您因此触犯法律,一切后果自负,我们对此不承担任何责任
5、所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其内容的准确性、可靠性、正当性、安全性、合法性等负责,亦不承担任何法律责任
6、所有作品仅供您个人学习、研究或欣赏,不得用于商业或者其他用途,否则,一切后果均由您自己承担,我们对此不承担任何法律责任
7、如涉及侵犯版权等问题,请您及时通知我们,我们将立即采取措施予以解决
8、联系人Email:admin@iyunv.com 网址:www.yunweiku.com

所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其承担任何法律责任,如涉及侵犯版权等问题,请您及时通知我们,我们将立即处理,联系人Email:kefu@iyunv.com,QQ:1061981298 本贴地址:https://www.yunweiku.com/thread-1081-1-1.html 上篇帖子: ospf v3 及WIN XP ipv6 下篇帖子: 利用acs实现aaa服务器的搭建 路由
发表于 2013-3-17 17:28:26 | 显示全部楼层
生,容易。活,容易。生活,不容易。

运维网声明 1、欢迎大家加入本站运维交流群:群②:261659950 群⑤:202807635 群⑦870801961 群⑧679858003
2、本站所有主题由该帖子作者发表,该帖子作者与运维网享有帖子相关版权
3、所有作品的著作权均归原作者享有,请您和我们一样尊重他人的著作权等合法权益。如果您对作品感到满意,请购买正版
4、禁止制作、复制、发布和传播具有反动、淫秽、色情、暴力、凶杀等内容的信息,一经发现立即删除。若您因此触犯法律,一切后果自负,我们对此不承担任何责任
5、所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其内容的准确性、可靠性、正当性、安全性、合法性等负责,亦不承担任何法律责任
6、所有作品仅供您个人学习、研究或欣赏,不得用于商业或者其他用途,否则,一切后果均由您自己承担,我们对此不承担任何法律责任
7、如涉及侵犯版权等问题,请您及时通知我们,我们将立即采取措施予以解决
8、联系人Email:admin@iyunv.com 网址:www.yunweiku.com

尚未签到

发表于 2013-5-16 12:14:38 | 显示全部楼层
走,MM,咱们化蝶去……

运维网声明 1、欢迎大家加入本站运维交流群:群②:261659950 群⑤:202807635 群⑦870801961 群⑧679858003
2、本站所有主题由该帖子作者发表,该帖子作者与运维网享有帖子相关版权
3、所有作品的著作权均归原作者享有,请您和我们一样尊重他人的著作权等合法权益。如果您对作品感到满意,请购买正版
4、禁止制作、复制、发布和传播具有反动、淫秽、色情、暴力、凶杀等内容的信息,一经发现立即删除。若您因此触犯法律,一切后果自负,我们对此不承担任何责任
5、所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其内容的准确性、可靠性、正当性、安全性、合法性等负责,亦不承担任何法律责任
6、所有作品仅供您个人学习、研究或欣赏,不得用于商业或者其他用途,否则,一切后果均由您自己承担,我们对此不承担任何法律责任
7、如涉及侵犯版权等问题,请您及时通知我们,我们将立即采取措施予以解决
8、联系人Email:admin@iyunv.com 网址:www.yunweiku.com

尚未签到

发表于 2013-5-18 23:57:50 | 显示全部楼层
打破老婆终身制,实行小姨股份制。引入小姐竞争制,推广情人合同制。

运维网声明 1、欢迎大家加入本站运维交流群:群②:261659950 群⑤:202807635 群⑦870801961 群⑧679858003
2、本站所有主题由该帖子作者发表,该帖子作者与运维网享有帖子相关版权
3、所有作品的著作权均归原作者享有,请您和我们一样尊重他人的著作权等合法权益。如果您对作品感到满意,请购买正版
4、禁止制作、复制、发布和传播具有反动、淫秽、色情、暴力、凶杀等内容的信息,一经发现立即删除。若您因此触犯法律,一切后果自负,我们对此不承担任何责任
5、所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其内容的准确性、可靠性、正当性、安全性、合法性等负责,亦不承担任何法律责任
6、所有作品仅供您个人学习、研究或欣赏,不得用于商业或者其他用途,否则,一切后果均由您自己承担,我们对此不承担任何法律责任
7、如涉及侵犯版权等问题,请您及时通知我们,我们将立即采取措施予以解决
8、联系人Email:admin@iyunv.com 网址:www.yunweiku.com

尚未签到

发表于 2013-5-21 21:13:31 | 显示全部楼层
读书读到抽筋处,文思方能如尿崩!

运维网声明 1、欢迎大家加入本站运维交流群:群②:261659950 群⑤:202807635 群⑦870801961 群⑧679858003
2、本站所有主题由该帖子作者发表,该帖子作者与运维网享有帖子相关版权
3、所有作品的著作权均归原作者享有,请您和我们一样尊重他人的著作权等合法权益。如果您对作品感到满意,请购买正版
4、禁止制作、复制、发布和传播具有反动、淫秽、色情、暴力、凶杀等内容的信息,一经发现立即删除。若您因此触犯法律,一切后果自负,我们对此不承担任何责任
5、所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其内容的准确性、可靠性、正当性、安全性、合法性等负责,亦不承担任何法律责任
6、所有作品仅供您个人学习、研究或欣赏,不得用于商业或者其他用途,否则,一切后果均由您自己承担,我们对此不承担任何法律责任
7、如涉及侵犯版权等问题,请您及时通知我们,我们将立即采取措施予以解决
8、联系人Email:admin@iyunv.com 网址:www.yunweiku.com

尚未签到

发表于 2013-5-25 13:01:41 | 显示全部楼层
生活***好玩,因为生活老***玩我!

运维网声明 1、欢迎大家加入本站运维交流群:群②:261659950 群⑤:202807635 群⑦870801961 群⑧679858003
2、本站所有主题由该帖子作者发表,该帖子作者与运维网享有帖子相关版权
3、所有作品的著作权均归原作者享有,请您和我们一样尊重他人的著作权等合法权益。如果您对作品感到满意,请购买正版
4、禁止制作、复制、发布和传播具有反动、淫秽、色情、暴力、凶杀等内容的信息,一经发现立即删除。若您因此触犯法律,一切后果自负,我们对此不承担任何责任
5、所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其内容的准确性、可靠性、正当性、安全性、合法性等负责,亦不承担任何法律责任
6、所有作品仅供您个人学习、研究或欣赏,不得用于商业或者其他用途,否则,一切后果均由您自己承担,我们对此不承担任何法律责任
7、如涉及侵犯版权等问题,请您及时通知我们,我们将立即采取措施予以解决
8、联系人Email:admin@iyunv.com 网址:www.yunweiku.com

尚未签到

发表于 2013-5-30 04:47:07 | 显示全部楼层
找到好贴不容易,我顶你了,谢了

运维网声明 1、欢迎大家加入本站运维交流群:群②:261659950 群⑤:202807635 群⑦870801961 群⑧679858003
2、本站所有主题由该帖子作者发表,该帖子作者与运维网享有帖子相关版权
3、所有作品的著作权均归原作者享有,请您和我们一样尊重他人的著作权等合法权益。如果您对作品感到满意,请购买正版
4、禁止制作、复制、发布和传播具有反动、淫秽、色情、暴力、凶杀等内容的信息,一经发现立即删除。若您因此触犯法律,一切后果自负,我们对此不承担任何责任
5、所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其内容的准确性、可靠性、正当性、安全性、合法性等负责,亦不承担任何法律责任
6、所有作品仅供您个人学习、研究或欣赏,不得用于商业或者其他用途,否则,一切后果均由您自己承担,我们对此不承担任何法律责任
7、如涉及侵犯版权等问题,请您及时通知我们,我们将立即采取措施予以解决
8、联系人Email:admin@iyunv.com 网址:www.yunweiku.com

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

扫码加入运维网微信交流群X

扫码加入运维网微信交流群

扫描二维码加入运维网微信交流群,最新一手资源尽在官方微信交流群!快快加入我们吧...

扫描微信二维码查看详情

客服E-mail:kefu@iyunv.com 客服QQ:1061981298


QQ群⑦:运维网交流群⑦ QQ群⑧:运维网交流群⑧ k8s群:运维网kubernetes交流群


提醒:禁止发布任何违反国家法律、法规的言论与图片等内容;本站内容均来自个人观点与网络等信息,非本站认同之观点.


本站大部分资源是网友从网上搜集分享而来,其版权均归原作者及其网站所有,我们尊重他人的合法权益,如有内容侵犯您的合法权益,请及时与我们联系进行核实删除!



合作伙伴: 青云cloud

快速回复 返回顶部 返回列表