团体属性过滤实验
团体属性实际你可以理解就是BGP的路由标记,在OSPF和ISIS里的路由都可以打Tag标记。BGP使用的不是Tag。而使用的是团体属性。
团体属性指的是具有相同性质的一类的路由,方便对大量相同的路由进行过滤。或者路由策略进行操控。
Community (团体)属性为可选过渡属性,是一种路由标记, 用于简化路由策略的执行。
[R1]ip ip-prefix comm permit 192.168.1.1 32
[R1]ip ip-prefix comm2 permit 192.168.2.1 32
[R1]route-policy lo1 permit node 10
[R1-route-policy]if-match ip-prefix comm
[R1-route-policy]apply community 100:11
[R1]route-policy lo1 permit node 20
[R1-route-policy]if-match ip-prefix comm2
[R1-route-policy]apply community 100:21
[R1-bgp]import-route direct route-policy lo1
[R1-bgp]peer 12.1.1.2 advertise-community //团体属性需要手动开启发送,默认不发送。
<R2>dis bgp routing-table 192.168.2.1 32 //查看具体某条路由里有了团体属性
BGP local router ID : 23.1.1.2
Local AS number : 200
Paths: 1 available, 1 best, 1 select
BGP routing table entry information of 192.168.2.1/32:
From: 12.1.1.1 (12.1.1.1)
Route Duration: 00h00m09s
Direct Out-interface: GigabitEthernet0/0/1
Original nexthop: 12.1.1.1
Qos information : 0x0
Community:<100:21>
AS-path 100, origin incomplete, MED 0, pref-val 0, valid, external, best, selec
t, active, pre 255
Advertised to such 2 peers:
23.1.1.3
12.1.1.1
<R2>dis bgp routing-table community 100:11 //可单独查看某个团体属性中有哪些该团体组的路由
BGP Local router ID is 23.1.1.2
Status codes: * - valid, > - best, d - damped,
h - history, i - internal, s - suppressed, S - Stale
Origin : i - IGP, e - EGP, ? - incomplete
Total Number of Routes: 1
Network NextHop MED LocPrf PrefVal Community
*> 192.168.1.1/32 12.1.1.1 0 0 <100:11>
可在途径路由上都添加给邻居团体属性,即可过渡该属性,否则不传递。
[R2-bgp]peer 23.1.1.3 advertise-community
[R2]ip community-filter 1 deny 100:11
[R2]ip community-filter 1 permit 100:21
[R2]dis ip community-filter //查看团体过滤器条目
Community filter Number: 1
deny 100:11
permit 100:21
[R2]route-policy name permit node 10
[R2-route-policy]if-match community-filter 1
[R2-bgp]peer 23.1.1.3 route-policy name export
//R3上可查看到,过滤掉了100:11,只有192.168.2.1的100:21的路由。但团体属性消失,要在R3上看到团体属性,需在bgp邻居上添加。
联邦实验
[R1]bgp 100
[R1-bgp]peer 12.1.1.2 as-number 200
[R2]bgp 64512
[R2-bgp]confederation id 200 //配置联邦id
[R2-bgp]peer 3.3.3.3 as-number 64512
[R2-bgp]peer 3.3.3.3 connect-interface LoopBack 0
[R2-bgp]peer 3.3.3.3 next-hop-local
[R3]bgp 64512
[R3-bgp]confederation id 200 //配置联邦id
[R3-bgp]confederation peer-as 64513 //配置联邦EBGP的AS号
[R3-bgp]peer 2.2.2.2 as-number 64512
[R3-bgp]peer 2.2.2.2 connect-interface LoopBack 0
[R3-bgp]peer 2.2.2.2 next-hop-local
[R3-bgp]peer 4.4.4.4 as-number 64513
[R3-bgp]peer 4.4.4.4 connect-interface LoopBack 0
[R3-bgp]peer 4.4.4.4 ebgp-max-hop
[R3-bgp]peer 4.4.4.4 next-hop-local
[R4]bgp 64513
[R4-bgp]confederation id 200 //配置联邦id
[R4-bgp]confederation peer-as 64512 //配置联邦EBGP的AS号
[R4-bgp]peer 3.3.3.3 as-number 64512
[R4-bgp]peer 3.3.3.3 connect-interface LoopBack 0
[R4-bgp]peer 3.3.3.3 ebgp-max-hop
[R4-bgp]peer 3.3.3.3 next-hop-local
[R4-bgp]peer 45.1.1.5 as-number 300
[R5]bgp 300
[R5-bgp]peer 45.1.1.4 as-number 200
内部AS静态互联
[R2]ip route-static 3.3.3.3 32 23.1.1.3
[R3]ip route-static 2.2.2.2 32 23.1.1.2
[R3]ip route-static 4.4.4.4 32 34.1.1.4
[R4]ip route-static 3.3.3.3 32 34.1.1.3
[R4]ip route-static 2.2.2.2 32 34.1.1.3
R1创建直连并引入BGP
[R1-LoopBack2]ip address 11.11.11.111 32
[R1-bgp]network 11.11.11.111 32
[R3]dis bgp peer //查看联盟BGP邻居,建立成功!!
BGP local router ID : 23.1.1.3
Local AS number : 64512
Total number of peers : 2 Peers in established state : 2
Peer V AS MsgRcvd MsgSent OutQ Up/Down State Pre
fRcv
2.2.2.2 4 64512 6 5 0 00:03:07 Established
1
4.4.4.4 4 64513 4 6 0 00:02:37 Established
0
[R4]dis bgp routing-table //在as-path上显示联盟路径
BGP Local router ID is 45.1.1.4
Status codes: * - valid, > - best, d - damped,
h - history, i - internal, s - suppressed, S - Stale
Origin : i - IGP, e - EGP, ? - incomplete
Total Number of Routes: 1
Network NextHop MED LocPrf PrefVal Path/Ogn
*>i 11.11.11.111/32 2.2.2.2 0 100 0 (64512) 10
0i
<R5>dis bgp routing-table //R5上查看到R1路由
BGP Local router ID is 45.1.1.5
Status codes: * - valid, > - best, d - damped,
h - history, i - internal, s - suppressed, S - Stale
Origin : i - IGP, e - EGP, ? - incomplete
Total Number of Routes: 1
Network NextHop MED LocPrf PrefVal Path/Ogn
*> 11.11.11.111/32 45.1.1.4 0 200 100i
姓名:
Q Q:
电话:
|