1.7-BGP④

注意:默认路由ip route 0.0.0.0 0.0.0.0 12.1.1.1是不可以作为BGP邻居TCP始发连接的(但回包可以)
要配静态路由:ip route 13.1.1.3 255.255.255.0 12.1.1.1
第三方下一条:多路以太口访问网络会出现。
BGP属性控制(以下面图为例):
route-map commu permit 10
r2(config-route-map)#set community ?
local-AS:小AS范围内
no-advertise 本路由器,不传到别的路由器
no-export 本联邦内
route-map commu permit 20
r2:
router bgp 64512
neighbor 24.1.1.4 route-map commu in
r2:router bgp 64512
neighbor 1.1.1.1 send-community 把属性传递下去(默认不传递)
r1:router bgp 64512
neighbor 3.3.3.3 send-community(不管属性本身是否具有传递性质,如果要传,首先都要send-community)
route-map commu permit 10
no set community
set community (从400到100的路由)
<1-4294...> community number (32bit)(作用相当于tag)
aa:nn (16bit:16bit)
set community 400:100(这个默认会传递出去,不用额外命令)
sh route-map
community 26214500(前16位:后16位叠加--不是相加)
(config)#ip bgp-community new-format
community 400:100
r5(config-router)#aggregate-address 172.16.4.0 255.255.252.0 summary-only(只发汇总路由出去,明细路由被抑制) as-set(把所有明细属性记录下来,防止路又返回路由始发点--虽然还是会发回去,但是因为有as path防环机制,所以始发路由器不接收--EBGP的防环机制的一种)
suppress-map--调用route-map,可以抑制想要的路由条目
unsuppress-map--针对某邻居不抑制
r1(config-router)#neighbor 14.1.1.4 unsuppress-map route-map名称
advertise-map 只产生匹配路由的聚合,如果该匹配路由消失,那么对整个网段的aggregate都会消失
aggregate-address 172.16.4.0 255.255.252.0 as-set advertise-map AAA
这时4/5/6/7网段都会被聚合成4.0/22,如果这时5.0消失了,那么聚合不起作用,则4/6/7网段/24位路由发出去
选路:
1:weight
2:l-p
3:next hop
4:as-path
5:起源代码
增加AS-PATH:
r1:route-map as
set as-path prepend 600 700
router bgp 100
nei 13.1.1.3 route-map as in
as-path:r1上看
策略r1 in 600 700
600 700 300 500 i
策略r3 out 600 700
300 600 700 500 i
如果设了入接口的策略,那么在原来该有的as-path顺序不变的基础上网前加上属性。
如果设了出方向的策略,那么as-path属性先加上策略在把自己的AS号加上发出去。
修改起源代码:做了相同as-path数目后。
r1(config)#route-map ori
set origin incomplete(未知)
router bgp 100
nei 12.1.1.2 route-map ori in
peer group:
router bgp 200
neighbor aaa(peer-group name) peer-group
neighbor aaa update-source lo 0
neighbor aaa remote-as 200
neighbor aaa route-reflector-client
neighbor 2.2.2.2 peer-group aaa(调用)
neighbor 3.3.3.3 peer-group aaa
本地优先级:(只能本AS或者联邦内传递)
route-map local-p
set local-preference 200(默认100)
router bgp 200
nei 12.1.1.1 route-map local-p in(要影响所有本AS的路由器,所以在边界的IN方向做)
clear ip bgp * s
weight值,只对本路由器有效而且cisco only
MED主要影响别人选路(如果从ibgp学来默认不传出本AS;EBGP就一定会传):
down邻居:neighbor 12.1.1.2 shutdown
起用:no neighbor 12.1.1.2 shutdown
r2:ip prefex-list med permit 4.4.4.0/24
route-map med
match ip add prefix-list med
set metric 200
router bgp 200
nei 12.1.1.1 route-map med out
r3:ip prefex-list med permit 4.4.4.0/24
route-map med
match ip add prefix-list med
set metric 300
router bgp 200
nei 13.1.1.1 route-map med out
metric为空时cisco理由器默认值为0,为最佳选路,但对华为等不一定。
router bgp 100
bgp bestpath med missing-as-worst
这时认为空的MED为最坏选路
ping: icmp echo请求->icmp echo-reply回复,有去有回
traceroute tt1=1 ttl=2,然后记录美一跳回包的ip
LAB8:
Confederation(联邦)/(community)(减少IBGP连接的数量)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
AS65012内部运行的IGP是RIP.
Step1:子AS内的IGP是RIP
整个AS123都运行IGP
Step2:启动子系统的BGP
router bgp 65012
bgp router-id 120.0.0.X
router bgp 65003
Step3:
R1/R2/R3#指定自己是属于AS123这个联邦/Confederation
R1/2/3#bgp confederation identifier 123
Step4:在两个联邦子AS相邻的边缘路由器R1/R3上,互相指定对方的子AS号:
R1(config-router)#bgp confederation peers 65003
R3(config-router)#bgp confederation peers 65012
Step5:在联邦中,互指定BGP邻居 
R3-R5
R5#neighbor 35.0.0.3 remot-as 123
R3#neighbor 35.0.0.3 remot-as 150
构建R2-R4之间的EBGP:
R2(config-router)#neighbor 24.0.0.4 remote-as 140
R4(config-router)#neighbor 24.0.0.2 remote-as 123
提醒:
在联邦以外的EBGP邻居,他们能查看到的是联邦的大AS号,而不是子AS号。
r1-r3的联邦EBGP:(联邦子AS间有IGP)
R3#
R3#neighbor 1.1.1.1 remote-as 65012
R3#neighbor 1.1.1.1 update-source loopback 3
R3#neighbor 1.1.1.1 ebgp-multihop
R1#neighbor 3.3.3.3 remote-as 65003
R1#neighbor 3.3.3.3 update-source loopback 1
R1#neighbor 3.3.3.3 ebgp-multihop
R1-R2的联邦IBGP
R1#neighbor 2.2.2.2 remote-as 65012
R1#neighbor 2.2.2.2 update-source loopback 1
R1#neighbor 1.1.1.1 remote-as 65012
R1#neighbor 1.1.1.1 update-source loopback 2
Step6:宣告BGP路由:
R5# 105.0.0.5/16
R4# 104.0.0.4/24
Step7:联邦EBGP和普通EBGP的异同点(105.0.0.0/16)
下一跳:(不同点)
在联邦的子AS中,所有路由器看到的BGP的下一跳
都是相邻大AS的边缘节点,而不是本联邦内子AS的下一跳
这是区别于普通EBGP的。
联邦EBGP,不会改变BGP下一跳特性。
同步:(相同点)
联邦EBGP和普通EBGP一样,无需考察同步问题
Step8:联邦内的IBGP:(R1-R2)(104.0.0.0/24)
下一跳:同STEP7
同步:(相同点)
原因是R1从联邦IBGP R2 学到的路由,默认要检查同步
但现在R1不可能通过RIP学到此BGP的路由
解决办法:
R1#no synchronization
LAB9:community/团体
(相当于一种BGP路由的标识位,常用于标识这条BGP路由应该传播的范围)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
R4#
增加104.0.0.0/24 传到R2就不在往前传
    104.0.1.0/24 传到R1就不在往前传
    104.0.2.0/24 传到R3就不在往前传
    104.0.3.0/24 
并NETWORK到BGP进程中去。
Step1:通过ACL/prefix-list,定义出/抓出特定的BGP路由:
ip prefix-list B-0 seq 5 permit 104.0.0.0/24(permit:表示匹配)
ip prefix-list B-1 seq 5 permit 104.1.0.0/24
ip prefix-list B-2 seq 5 permit 104.2.0.0/24
Step2:通过Route-map,设定每类路由的COMMUNITY种类:
route-map T-R2 permit 10
match ip address prefix-list B-0
set community no advertise(do not advertise to any BGP peer)
route-map T-R2 permit 20
match ip address prefix-list B-1
set community local-as (do not send outside local-AS 联邦的子AS/小AS)
route-map T-R2 permit 30
match ip address prefix-list B-2
set community no-export (do not export to next 大AS)
route-map T-R2 permit 40
(空的route-map:Match any,Set Nothing!)(Internet)
Step3:在R4上,对R2的BGP路由策略发生,“出方向”的改变:
R4(config-router)#neighor 24.0.0.2 route-map T-R2 out
step4:每个BGP路由器,将community发送给下一个BGP路由器
R4#neighbor 24.0.0.2 send-community
R2#neighbor 1.1.1.1 send-community
R1#neighbor 3.3.3.3 send-community
R2#show ip bgp community
R5#show ip bgp community
show ip bgp community no-advertise
show ip bgp community local-AS
show ip bgp community no-export
Step5:如果没有:“router-map T-R2 permit 40”
R4向R2通告的bgp路由只有3条:
R4#show ip bgp neighbor 24.0.0.2 advertisedp-routes
*> 104.0.0.0/16
*> 104.1.0.0/16
*> 104.2.0.0/16
BGP路由过滤的方法之一.
BGP Summarization
LAB1:非专业汇总(network命令,是不需要宣告明细路由的.)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Step1:手工生成一条需要汇总的,静态的,空接口路由:
R4(config)#ip route 104.0.0.0 255.255.252.0 null 0
Step2:将上述汇总的/22的路由,宣告到BGP进程中:
R4(config)#router bgp 140
R4(config-router)#network 104.0.0.0 mask 255.255.252.0
在R5上,可以查看到明细路由/汇总路由,
实际上,明细路由是不需要的:
Step3:删除原宣告到BGP的明细路由:
(使用network命令做BGP汇总,是不需要宣告明细路由的)
R4(config-router)#router bgp 140
R4(config-router)#no network 104.0.0.0 mask 255.255.0.0
R4(config-router)#no network 104.1.0.0 mask 255.255.0.0
R4(config-router)#no network 104.2.0.0 mask 255.255.0.0
R4(config-router)#no network 104.3.0.0 mask 255.255.0.0
Step4:实现BGP路由汇总:
R5#show ip bgp
*>104.0.0.0/22
Step5:如果
no ip route 104.0.0.0 255.255.252.0 null 0
∵BGP进程,在路由宣告前,
会检查路由表,如果能够查到汇总路由,
才会将此汇总路由宣告到BGP进程中.
R4(config)#ip route 104.0.0.0 255.255.252.0 null 0(空接口)
也可以由IGP,自动/手工的汇总生成,
LAB2:专业汇总(推荐方法)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Step0:删除原表态的,/22汇总路由
Step1:宣告准确的明细路由:
R4(config)#router bgp 140
R4(config-router)#network 104.0.0.0 mask 255.255.0.0
R4(config-router)#network 104.1.0.0 mask 255.255.0.0
R4(config-router)#network 104.2.0.0 mask 255.255.0.0
R4(config-router)#network 104.3.0.0 mask 255.255.0.0
不要使用network命令,宣告汇总路由:
R4(config-router)#no network 104.0.0.0 mask 255.255.252.0
Step2:使用aggregate-address命令,实现BGP路由的汇总:
是不需要事先配置汇总路由的.自动生成
R4(config-router)#aggregate-address 104.0.0.0 255.255.252.0
此时的所在的BGP路由器上,都接收到了明细和汇总的路由:
Step3:为了不让明细路由传播出去,调用"summary-only":
R4(config-router)#
aggregate-address 104.0.0.0 255.252.0.0 summary-only
此时的R4,抑制了所有的明细路由,只发送了汇总路由给R2,实现了BGP路由的汇总。
R4#show ip bgp
*> 104.0.0.0/22 (*:valid)
S> 104.0.0.0/24 (s:suppressed)
S> 104.0.1.0/24
S> 104.0.2.0/24
S> 104.0.3.0/24
Step4:R4的BGP进程,自动生成了一条用于汇总的空接口路由


来自为知笔记(Wiz)


posted on 2016-12-10 10:33  sanyuanyanjin  阅读(248)  评论(0编辑  收藏  举报