1.过滤BGP路由的方法
2.用AS-path filter控制路由
3.用Community Filter控制路由

enable
conf t
no ip do lo
enable pass cisco
line con 0
logg sync
exec-t 0 0
exit
line vty 0 4
pass cisco
logg sync
exit
host

1.过滤BGP路由的方法
--------------------------------------------------------------------------
多种过滤BGP路由的方法:
直接调用前缀列表过滤路由,neighbor x.x.x.x prefix-list xx
用Distribute-list 加前缀或访问控制列表过滤
    针对某个邻居:nenighbor x.x.x.x distribute-list + 前缀/访问列表
    针对所有邻居:distribute-list + 前缀/访问列表
用route-map过滤,neighbor x.x.x.x route-map
每种过滤的方法都可以用于in和out两个方向。

R1:
int f0/0
ip add 12.1.1.1 255.255.255.0
no shut
exit
int f1/0
ip add 14.1.1.1 255.255.255.0
no shut
exit
int f2/0
ip add 13.1.1.1 255.255.255.0
no shut
exit

router bgp 100
bgp router-id 11.1.1.1
neighbor 12.1.1.2 remote-as 200
neighbor 13.1.1.3 remote-as 300
neighbor 14.1.1.4 remote-as 400
exit

R2:
int f0/0
ip add 12.1.1.2 255.255.255.0
no shut
exit

router bgp 200
bgp router-id 22.1.1.1
neighbor 12.1.1.1 remote-as 100
exit

R3:
int f0/0
ip add 13.1.1.3 255.255.255.0
no shut
exit

router bgp 300
bgp router-id 33.1.1.1
neighbor 13.1.1.1 remote-as 100
exit

R4:
int f0/0
ip add 14.1.1.4 255.255.255.0
no shut
exit

router bgp 400
bgp router-id 44.1.1.1
neighbor 14.1.1.1 remote-as 100
exit

R2:
int l0
ip add 100.1.0.1 255.255.255.0
exit
int l1
ip add 100.1.1.1 255.255.255.0
exit
int l2
ip add 100.1.2.1 255.255.255.0
exit
int l3
ip add 100.1.3.1 255.255.255.0
exit

router bgp 200
network 100.1.0.0 mask 255.255.255.0
network 100.1.1.0 mask 255.255.255.0
network 100.1.2.0 mask 255.255.255.0
network 100.1.3.0 mask 255.255.255.0
exit

R3:
int l0
ip add 100.1.0.1 255.255.255.128
exit
int l1
ip add 100.1.1.1 255.255.255.128
exit
int l2
ip add 100.1.2.1 255.255.255.128
exit
int l3
ip add 100.1.3.1 255.255.255.128
exit

router bgp 300
network 100.1.0.0 mask 255.255.255.128
network 100.1.1.0 mask 255.255.255.128
network 100.1.2.0 mask 255.255.255.128
network 100.1.3.0 mask 255.255.255.128
exit

R4:
int l0
ip add 100.1.0.1 255.255.255.192
exit
int l1
ip add 100.1.1.1 255.255.255.192
exit
int l2
ip add 100.1.2.1 255.255.255.192
exit
int l3
ip add 100.1.3.1 255.255.255.192
exit

router bgp 300
network 100.1.0.0 mask 255.255.255.192
network 100.1.1.0 mask 255.255.255.192
network 100.1.2.0 mask 255.255.255.192
network 100.1.3.0 mask 255.255.255.192
exit

R1:
show ip bgp

-------------------------------------------------------------------
R1:
ip prefix-list yeslab deny 100.1.0.0/22 ge 24 le 24

/22表示要匹配前缀100.1.0.0的前22位,而第23位和24位可以任意值。
当没有配置ge和le,表示掩码长度等于/length
当配置了ge,没有配置le,表示掩码长度大于等于ge-length,小于等于32
当没有配置ge,但配置了le,表示掩码长度大于等于network-length,小于等于le-length
当同时配置了ge和le,表示前缀长度大于等于ge-length,小于等于le-length

router bgp 100
neighbor 12.1.1.2 prefix-list yeslab in
exit

clear ip bgp * soft in
show ip bgp

------------------------------------------------------------------
R1:
router bgp 100
no neighbor 12.1.1.2 prefix-list yeslab in
distribute-list prefix yeslab in
exit

clear ip bgp * soft in
show ip bgp

------------------------------------------------------------------
R1:
access-list 100 deny ip 100.1.0.0 0.0.3.0 host 255.255.255.0
access-list permit ip any any

以上host前面部分匹配前缀,后面部分匹配掩码长度

router bgp 100
no distribute-list prefix yeslab in
distribute-list 100 in
exit

clear ip bgp * soft in
show ip bgp

---------------------------------------------------------------------
R1:
router bgp 100
no distribute-list 100 in
neighbor 12.1.1.2 distribute-list 100 in
exit

clear ip bgp * soft in
show ip bgp

CCIE路由实验(4) -- BGP路由控制的更多相关文章

  1. CCNP路由实验之七 动态路由之BGP

     CCNP路由实验之七 动态路由之BGP 动态路由协议能够自己主动的发现远程网络,仅仅要网络拓扑结构发生了变化,路由器就会相互交换路由信息,不仅能够自己主动获知新添加的网络,还能够在当前网络连接失 ...

  2. CCNP路由实验之九 路由策略

     CCNP路由实验之九 路由策略 路由器在公布与接收路由信息时,可能须要实施一些策略.以便对路由信息进行过滤,比如仅仅接收或公布满足一定条件的路由信息. 一种路由协议可能须要引入其它的路由协议发现 ...

  3. CCIE路由实验(3) -- BGP高级部分

    当一个AS包含多个IBGP对等体时,路由反射器非常有用.因为IBGP客户只需要和路由反射器建立邻居关系,从而降低了IBGP的连接数量.路由反射器和它的客户合称为一个簇.路由反射是克服IBGP水平分割的 ...

  4. CCIE路由实验(2) -- BGP选路原则

    BGP路径属性分为4类: 公认必遵(Well-Known Mandatory):BGP更新报文中必须包含的,且必须被所有BGP厂商实现所能识别的,包括ORIGIN,AS-PATH和Next_Hop 1 ...

  5. CCNP路由实验(4) -- BGP

    基本配置:enableconf tno ip do loenable pass ciscoline con 0logg syncexec-t 0 0line vty 0 4pass ciscologg ...

  6. CCIE路由实验(5) -- BGP负载均衡

    enableconf tno ip do loenable pass ciscoline con 0logg syncexec-t 0 0exitline vty 0 4pass ciscologg ...

  7. 在ensp上利用单臂路由实验VLAN间路由

    我们为什么要设置单臂路由? 因为我们要解决不同vlan,不同网络的PC机间的通信问题~ 那它为啥叫单臂路由嘞? 单臂路由的原理时通过一台路由器,使vlan间互通数据通过路由器进行三层转发,如果在路由器 ...

  8. CCIE路由实验(7) -- MPLS VPN

    1.LDP协议的各种情况2.LDP和BGP交互3.LDP高级部分4.MPLS VPN (RIP和静态)5.MPLS VPN (EIGRP)6.MPLS VPN (OSPF)7.MPLS VPN (EB ...

  9. HCNP Routing&Switching之BGP路由控制

    前文我们了解了BGP的路由属性和优选规则相关话题,回顾请参考https://www.cnblogs.com/qiuhom-1874/p/15489497.html:今天我们来聊一聊BGP路由控制相关话 ...

随机推荐

  1. hdoj 2544 最短路(最短路+Dijkstrea算法)

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=2544 思路分析:该问题给定一个无向图,要求求从起始点到终点的最短路径长度:可以使用dijkstra算法 ...

  2. HDU 4716 A Computer Graphics Problem

    A Computer Graphics Problem Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (J ...

  3. poj1144 Network【tarjan求割点】

    转载请注明出处,谢谢:http://www.cnblogs.com/KirisameMarisa/p/4319585.html   ---by 墨染之樱花 [题目链接]http://poj.org/p ...

  4. SQL Server 中 RAISERROR 的用法(转)

    在存储过程中进程会处理一些逻辑性的错误,如:将RMB转换为USD时,没有查询到想要的汇率 这个时候最好在存储过程中抛个异常,方便自己查找错误信息... 其语法如下: RAISERROR ( { msg ...

  5. Linux新手笔记 svn ntfs

    centos 6.4 64 笔记一.安装Apache1.使用yum命令安装Apacheyum -y install httpd2.设置开机启动Apachechkconfig --levels 235 ...

  6. C# Best Practices - Accessing and Using Classes

    References and Using Do: Take care when defining references References must be one way (or circular ...

  7. Java学习之位运算和逻辑运算符

    今天看了一下HashMap类的源码,在HashMap的源码中定义了初始空间的大小 static final int DEFAULT_INITIAL_CAPACITY = 1 << 4; 当 ...

  8. filter, sort

    def is_odd(n): return n % 2 == 1 t = list(filter(is_odd, [1, 2, 3, 4, 5, 6, 7, 8, 9, 0])) print(t) # ...

  9. HDU 2023题解分析

    我想说这道题我还没弄明白我错哪了,交了20多遍一直都是Runtime Error,改了N次还是不对,后来搜了一下,说是数组开小了,又把数组开大,还不对,又改发现一个平均值求错,再改,还不对,洗洗睡吧. ...

  10. [C#]窗体切换--避免开启多个线程

    先说说这个多窗体的界面的解决的办法: 用到的方法很简单,就是程序运行就建立一个MainForm,在这个MainForm中设立一个Panel,同时设立几个按钮,按下每个按钮都在这个Panel中载入不同的 ...