41. Using Route-Map to Filtering BGP Routing

1、掌握使用 Route-Map 过滤 BGP 的路由。

 

网络图:

image.png


由于在Filtering Routing Up dates with a Router Maps中已经介绍过如何使用Router Maps过滤路由,所以在这里只列出如何在BGP中使用route-map命令来过滤BGP的路由。

 

配置好各路由器的IP地址等基本信息,测试互连可达。

 

配置各路由器的BGP路由协议,并且关闭BGP的自动汇总。

 

查看R3路由表:

R3#show ip route

Gateway of last resort is not set

     172.16.0.0/16 is variably subnetted, 5 subnets, 2 masks

B       172.16.255.0/30 [20/0] via 10.1.255.1, 00:05:44

B       172.16.0.0/24 [20/0] via 10.1.255.1, 00:05:44

B       172.16.1.0/24 [20/0] via 10.1.255.1, 00:05:44

B       172.16.2.0/24 [20/0] via 10.1.255.1, 00:05:44

B       172.16.3.0/24 [20/0] via 10.1.255.1, 00:05:44

     10.0.0.0/30 is subnetted, 1 subnets

C       10.1.255.0 is directly connected, Serial0/0

 

在R2上配置Route-map过滤路由:

R2(config)#access-list 1 deny 172.16.0.0 0.0.0.255

R2(config)#access-list 1 deny 172.16.1.0 0.0.0.255

R2(config)#access-list 1 permit any        ----->划定范围

R2(config)#route-map bgp-filter permit 10  ----->如此如此。。。这般这般。。。

R2(config-route-map)#match ip address 1

R2(config-route-map)#exit

R2(config)#router bgp 64512

R2(config-router)#neighbor 10.1.255.2 route-map bgp-filter out   ---->OUT~出接口~

R2(config-router)#end

R2#clear ip bgp * soft out   ---->加速

 

查看R3的路由表,确认路由过滤:

R3#show ip route

Gateway of last resort is not set

     172.16.0.0/16 is variably subnetted, 3 subnets, 2 masks

B       172.16.255.0/30 [20/0] via 10.1.255.1, 00:00:35

B       172.16.2.0/24 [20/0] via 10.1.255.1, 00:00:35

B       172.16.3.0/24 [20/0] via 10.1.255.1, 00:00:35

     10.0.0.0/30 is subnetted, 1 subnets

C       10.1.255.0 is directly connected, Serial0/0

 

完成!



发表评论:

◎欢迎参与讨论,请在这里发表您的看法、交流您的观点。

桂ICP备19000498号-3