1、实验:BGP 中路由策略的一些应用要求:192.168.20.1/24 COST 101 团体属性值 200:100 21.1/24 过滤22.1/24 COST100 R3 的收到的 20.1 附加一个 AS 号 1000 和团体属性 100:100AS100 过滤 AS200 的流量不传给 AS300 (r3 没有 2.2.2.2)发送 BGP 更新报文时,可以携带私有自治系统号不携带私有自治系统号(peer 192.168.1.2 public-as-only )配置如下:AR1#sysname r1#interface Ethernet0/0/0ip address 192.168.1
2、.1 255.255.255.252 #interface Ethernet0/0/1ip address 192.168.1.5 255.255.255.252 #interface LoopBack20ip address 192.168.20.1 255.255.255.0 #interface LoopBack21ip address 192.168.21.1 255.255.255.0 #interface LoopBack22ip address 192.168.22.1 255.255.255.0 #bgp 100peer 192.168.1.2 as-number 200 pe
3、er 192.168.1.6 as-number 300 #ipv4-family unicastundo synchronizationimport-route directpeer 192.168.1.2 enablepeer 192.168.1.6 enablepeer 192.168.1.6 route-policy a exportpeer 192.168.1.2 route-policy a exportpeer 192.168.1.6 advertise-communitypeer 192.168.1.2 advertise-community#route-policy a pe
4、rmit node 10 if-match ip-prefix a apply cost 101 apply community 200:100 #route-policy a deny node 20 if-match ip-prefix b #route-policy a permit node 30 if-match ip-prefix c apply cost 100 #route-policy a permit node 200 #ip ip-prefix a index 10 permit 192.168.20.0 24 greater-equal 24 less-equal 32
5、ip ip-prefix b index 10 permit 192.168.21.0 24 greater-equal 24 less-equal 32ip ip-prefix c index 10 permit 192.168.22.0 24 greater-equal 24 less-equal 32#return AR2#sysname r2#interface Ethernet0/0/0ip address 192.168.1.2 255.255.255.252 #interface Serial0/0/3link-protocol ppp#interface GigabitEthe
6、rnet0/0/0#interface GigabitEthernet0/0/1#interface GigabitEthernet0/0/2#interface GigabitEthernet0/0/3#interface NULL0#interface LoopBack0ip address 2.2.2.2 255.255.255.255 #bgp 200peer 192.168.1.1 as-number 100 #ipv4-family unicastundo synchronizationimport-route directpeer 192.168.1.1 enablepeer 1
7、92.168.1.1 route-policy a export#route-policy a permit node 10 if-match community-filter 1 #ip community-filter 1 permit no-export#return AR3sysname r3#interface Ethernet0/0/0#interface Ethernet0/0/1ip address 192.168.1.6 255.255.255.252 #bgp 300peer 192.168.1.5 as-number 100 #ipv4-family unicastundo synchronizationpeer 192.168.1.5 enablepeer 192.168.1.5 route-policy a import#route-policy a permit node 10 if-match community-filter a apply as-path 1000 additiveapply community 100:100 additive #route-policy a permit node 200 #ip community-filter 1 permit 200:100#return