一、实验拓扑图
二、配置过程
1、基本BGP功能
- 假如你是公司A网络管理员,公司A网络如下图所示。现公司A要求如下:
- 与R2、R3建立稳定的IBGP关系,R6与R7建立稳定的IBGP关系,AS100与AS400,可以配置适当的静态路由
- 宣告10.0.x.0/24进入BGP网络
- 所有的EBGP邻居都建立邻居关系
-------------R1的配置-------------
router id 1.1.1.1
#
ip route-static 2.2.2.2 255.255.255.255 192.168.12.2
ip route-static 3.3.3.3 255.255.255.255 192.168.13.3
#
bgp 100
peer 2.2.2.2 as-number 100
peer 2.2.2.2 connect-interface LoopBack0
peer 3.3.3.3 as-number 100
peer 3.3.3.3 connect-interface LoopBack0
#
ipv4-family unicast
undo synchronization
network 10.0.0.0 255.255.255.0
peer 2.2.2.2 enable
peer 3.3.3.3 enable
#
-------------R2的配置-------------
router id 2.2.2.2
#
ip route-static 1.1.1.1 255.255.255.255 192.168.12.1
#
bgp 100
peer 1.1.1.1 as-number 100
peer 1.1.1.1 connect-interface LoopBack0
peer 192.168.24.4 as-number 200
#
ipv4-family unicast
undo synchronization
peer 1.1.1.1 enable
peer 1.1.1.1 next-hop-local
peer 192.168.24.4 enable
#
-------------R3的配置-------------
router id 3.3.3.3
#
ip route-static 1.1.1.1 255.255.255.255 192.168.13.1
#
bgp 100
peer 1.1.1.1 as-number 100
peer 1.1.1.1 connect-interface LoopBack0
peer 192.168.34.4 as-number 200
#
ipv4-family unicast
undo synchronization
peer 1.1.1.1 enable
peer 1.1.1.1 next-hop-local
peer 192.168.34.4 enable
#
-------------R4的配置-------------
bgp 200
peer 192.168.24.2 as-number 100
peer 192.168.34.3 as-number 100
peer 192.168.45.5 as-number 300
peer 192.168.46.6 as-number 400
peer 192.168.47.7 as-number 400
#
ipv4-family unicast
undo synchronization
peer 192.168.24.2 enable
peer 192.168.34.3 enable
peer 192.168.45.5 enable
peer 192.168.46.6 enable
peer 192.168.47.7 enable
#
-------------R4的配置-------------
bgp 300
peer 192.168.45.4 as-number 200
#
ipv4-family unicast
undo synchronization
peer 192.168.45.4 enable
#
-------------R6的配置-------------
router id 6.6.6.6
#
ip route-static 7.7.7.7 255.255.255.255 192.168.67.7
#
bgp 400
peer 7.7.7.7 as-number 400
peer 7.7.7.7 connect-interface LoopBack0
peer 192.168.46.4 as-number 200
peer 192.168.68.8 as-number 500
#
ipv4-family unicast
undo synchronization
peer 7.7.7.7 enable
peer 192.168.46.4 enable
peer 192.168.68.8 enable
#
-------------R7的配置-------------
router id 7.7.7.7
#
ip route-static 6.6.6.6 255.255.255.255 192.168.67.6
#
bgp 400
peer 6.6.6.6 as-number 400
peer 6.6.6.6 connect-interface LoopBack0
peer 192.168.47.4 as-number 200
#
ipv4-family unicast
undo synchronization
network 10.0.1.0 255.255.255.0
peer 6.6.6.6 enable
peer 192.168.47.4 enable
#
-------------R8的配置-------------
bgp 500
peer 192.168.68.6 as-number 400
#
ipv4-family unicast
undo synchronization
network 10.0.2.0 255.255.255.0
peer 192.168.68.6 enable
2、配置BGP Local_Pref属性
- 公司A为了实现链路的充分应用,需要对网络进行调整,现公司A需求如下:
- R1通过R3到达网络10.0.2.0/24,在R2上进行配置
ip ip-prefix 2 index 10 permit 10.0.2.0 24 # route-policy 2 permit node 1 if-match ip-prefix 2 apply local-preference 50 route-policy 2 permit node 1000 # bgp 100 peer 1.1.1.1 route-policy 2 export
- R1通过R3到达网络10.0.2.0/24,在R2上进行配置
- 观察1:在R1上查看BGP路由表信息,去往10.0.2.0/24是否走R3,此时选路原则为Local_Pref越大越优先
3、配置BGP MED属性
- 网络10.0.0.0/24与网络10.0.1.0/24互通时往返路径不一致,且非最优:
- 要求在R6上进行配置,不允许修改AS_Path。
ip route-static 7.7.7.7 255.255.255.255 192.168.67.7 # route-policy R7toR4 permit node 1 if-match ip-prefix R7toR4 apply cost 100 route-policy R7toR4 permit node 1000 # bgp 400 peer 192.168.46.4 route-policy R7toR4 export
- 观察1:在R4上查看BGP路由表信息,查看去往10.0.1.0/24是否走R7,此时选路的原因是MED值,MED值越小越优先。
- 观察2:测试网络10.0.0.0/24与网络10.0.1.0/24互通往返路径是否一致
4、配置BGP团体属性
- 现公司A对AS500进行了调整,增加部分网段,且需要对网络10.0.3.0/24进行控制,需求如下:
- 网络10.0.3.0/24不能被AS100、AS200和AS300访问,需要在R8上配置。
- 网络10.0.3.0/24不能被AS100、AS200和AS300访问,需要在R8上配置。
-------------R8的配置-------------
ip ip-prefix 3 index 10 permit 10.0.3.0 24
#
route-policy 3 permit node 1
if-match ip-prefix 3
apply community no-export
route-policy 3 permit node 1000
#
bgp 500
peer 192.168.68.6 route-policy 3 export
peer 192.168.68.6 advertise-community
-------------R6的配置-------------
bgp 400
peer 7.7.7.7 advertise-community
- 观察1:分别在R1、R4、R5和R6上查看是BGP路由表中是否存在路由10.0.3.0/24,此时只有R6所在AS400能够被学习到,原因是因为R6收到携带团体属性no-export的路由10.0.3.0/24后不再向其他AS发送该路由
注意:做了团体属性策略需要向邻居通告,否则无法生效。通告命令:peer x.x.x.x advertise-community
5、配置BGP AS_Path属性
- 现公司A网络需要对AS300进行路径优化,需求如下:
- R5不再接受源自AS100和AS400的EBGP路由,不能使用ACL、前缀列表,请在R5上配置;
- 为了访问外部网络,R可以经由缺省BGP路由进行访问,请在R4上进行配置
-------------R5的配置-------------
ip as-path-filter AS_deny_100-400 index 110 deny _100|400$
ip as-path-filter AS_deny_100-400 index 1000 permit .*
#
route-policy AS_deny_100-400 permit node 1
if-match as-path-filter AS_deny_100-400
#
bgp 300
peer 192.168.45.4 route-policy AS_deny_100-400 import
-------------R4配置-------------
bgp 200
peer 192.168.45.5 default-route-advertise
- 观察1:在R5上查看BGP路由表信息,是否学习到了来自AS100和400的BGP路由,R4是下放默认路由给R5
6、配置BGP负载分担
- 现公司需要对路由器R1修改,需求如下:
- 在R1上实现负载分担,不能修改原配置
bgp 100 maximum load-balancing 2
- 在R1上实现负载分担,不能修改原配置
- 观察1:在R1的IP路由中观察通过BGP学习到的路由,此时去往网络10.0.1.0/24和网络10.0.4.0/24实现了负载分担。
7、优化BGP网络
- 现公司A需要加固自己的网络,需求如下:
- AS 100采用MD5认证,密码为:Huawei;
- R6月R8之间使能GTSM功能,配置合理跳数,且对其不合法报文进行丢弃,若有报文丢弃时,能记录log信息。
-------------R1配置-------------
bgp 100
peer 2.2.2.2 password cipher huawei
peer 3.3.3.3 password cipher huawei
-------------R2配置-------------
bgp 100
peer 1.1.1.1 password cipher huawei
-------------R3配置-------------
bgp 100
peer 1.1.1.1 password cipher huawei
-------------R8配置-------------
gtsm default-action drop
gtsm log drop-packet all
#
bgp 500
peer 192.168.68.6 valid-ttl-hops 1
- 观察1:分别在R1和R8上观察配置结果
评论区