每日实验---BGP的综合选路

题目

要求


1.使用preVal策略,确保R4通过R2到达192.168.10.0/24;
2.使用As Path策略,确保R4通过R3到达192.168.11.0/24;
3.配置MED策略,确保R4通过R3到达192.168.12.0/24;
4.使用Local Preference策略,确保R1通过R2到达192.168.1.0/24;
5.使用Local Preference策略,确保R1通过R3到达192.168.2.0/24;
6.配置负载均衡,确保R1通过R2和R3到达192.168.3.0/24;
7.使用As策略,AS 500不接受任何始发于AS 123的路由;
8.使用自定义community策略,确保192.168.3.0/24路由不会被发布到AS 500;
9.IBGP使用环回接口建邻,EBGP使用物理接口建邻;
10.修改As 123中的用户网段为Broadcast,方便后续在BGP中宣告;
11.BGP宣告路由时,仅宣告24网段的用户路由。

配置

R1:
interface GigabitEthernet0/0/0
 ip address 12.0.0.1 255.255.255.0 
#
interface GigabitEthernet0/0/1
 ip address 13.0.0.1 255.255.255.0 
#
interface GigabitEthernet0/0/2
#
interface NULL0
#
interface LoopBack0
 ip address 192.168.1.1 255.255.255.0 
#
interface LoopBack1
 ip address 192.168.2.1 255.255.255.0 
#
interface LoopBack2
 ip address 192.168.3.1 255.255.255.0 
#
bgp 400
 router-id 1.1.1.1
 peer 12.0.0.2 as-number 123 
 peer 13.0.0.2 as-number 123 
 #
 ipv4-family unicast
  undo synchronization
  network 192.168.1.0 
  network 192.168.2.0 
  network 192.168.3.0 route-policy community 
  peer 12.0.0.2 enable
  peer 12.0.0.2 route-policy as import
  peer 12.0.0.2 advertise-community
  peer 13.0.0.2 enable
  peer 13.0.0.2 route-policy pv import
  peer 13.0.0.2 advertise-community
#
route-policy pv permit node 10 
 if-match ip-prefix pv 
 apply preferred-value 66
#
route-policy pv permit node 20 
#
route-policy as permit node 10 
 if-match ip-prefix as 
 apply as-path 33 additive
#
route-policy as permit node 20 
#
route-policy med permit node 10 
 if-match ip-prefix med 
 apply cost 10 
#
route-policy med permit node 20 
#
route-policy community permit node 10 
 apply community 400:333 
#
ip ip-prefix pv index 10 permit 192.168.10.0 24
ip ip-prefix as index 10 permit 192.168.11.0 24
ip ip-prefix med index 10 permit 192.168.12.0 24



R2:
interface GigabitEthernet0/0/0
 ip address 12.0.0.2 255.255.255.0 
#
interface GigabitEthernet0/0/1
 ip address 24.0.0.1 255.255.255.0 
#
interface GigabitEthernet0/0/2
#
interface NULL0
#
interface LoopBack0
 ip address 2.2.2.2 255.255.255.255 
#
interface LoopBack1
 ip address 192.168.20.1 255.255.255.0 
 ospf network-type broadcast
#
bgp 123
 router-id 2.2.2.2
 peer 4.4.4.4 as-number 123 
 peer 4.4.4.4 connect-interface LoopBack0
 peer 12.0.0.1 as-number 400 
 #
 ipv4-family unicast
  undo synchronization
  network 192.168.20.0 
  peer 4.4.4.4 enable
  peer 4.4.4.4 next-hop-local 
  peer 4.4.4.4 advertise-community
  peer 12.0.0.1 enable
  peer 12.0.0.1 route-policy med export
#
ospf 1 router-id 2.2.2.2 
 area 0.0.0.0 
  network 2.2.2.2 0.0.0.0 
  network 24.0.0.1 0.0.0.0 
  network 192.168.20.0 0.0.0.255 
#
route-policy med permit node 10 
 if-match ip-prefix med 
 apply cost 10 
#
route-policy med permit node 20 
#
ip ip-prefix med index 10 permit 192.168.12.0 24

R3:
interface GigabitEthernet0/0/0
 ip address 34.0.0.1 255.255.255.0 
#
interface GigabitEthernet0/0/1
 ip address 13.0.0.2 255.255.255.0 
#
interface GigabitEthernet0/0/2
#
interface NULL0
#
interface LoopBack0
 ip address 3.3.3.3 255.255.255.255 
#
interface LoopBack1
 ip address 192.168.30.1 255.255.255.0 
 ospf network-type broadcast
#
bgp 123
 router-id 3.3.3.3
 peer 4.4.4.4 as-number 123 
 peer 4.4.4.4 connect-interface LoopBack0
 peer 13.0.0.1 as-number 400 
 #
 ipv4-family unicast
  undo synchronization
  network 192.168.30.0 
  peer 4.4.4.4 enable
  peer 4.4.4.4 next-hop-local 
  peer 4.4.4.4 advertise-community
  peer 13.0.0.1 enable
#
ospf 1 router-id 3.3.3.3 
 area 0.0.0.0 
  network 3.3.3.3 0.0.0.0 
  network 34.0.0.1 0.0.0.0 
  network 192.168.30.0 0.0.0.255 



R4:
interface GigabitEthernet0/0/0
 ip address 34.0.0.2 255.255.255.0 
#
interface GigabitEthernet0/0/1
 ip address 24.0.0.2 255.255.255.0 
#
interface GigabitEthernet0/0/2
 ip address 45.0.0.1 255.255.255.0 
#
interface NULL0
#
interface LoopBack0
 ip address 4.4.4.4 255.255.255.255 
#
interface LoopBack1
 ip address 192.168.100.1 255.255.255.0 
 ospf network-type broadcast
#
bgp 123
 router-id 4.4.4.4
 peer 2.2.2.2 as-number 123 
 peer 2.2.2.2 connect-interface LoopBack0
 peer 3.3.3.3 as-number 123 
 peer 3.3.3.3 connect-interface LoopBack0
 peer 45.0.0.2 as-number 500 
 #
 ipv4-family unicast
  undo synchronization
  network 192.168.100.0 
  maximum load-balancing 2
  peer 2.2.2.2 enable
  peer 2.2.2.2 route-policy lp1 import
  peer 2.2.2.2 next-hop-local 
  peer 3.3.3.3 enable
  peer 3.3.3.3 route-policy lp2 import
  peer 3.3.3.3 next-hop-local 
  peer 45.0.0.2 enable
  peer 45.0.0.2 advertise-community
#
ospf 1 router-id 4.4.4.4 
 area 0.0.0.0 
  network 4.4.4.4 0.0.0.0 
  network 24.0.0.2 0.0.0.0 
  network 34.0.0.2 0.0.0.0 
  network 192.168.100.0 0.0.0.255 
#
route-policy lp1 permit node 10 
 if-match ip-prefix lp1 
 apply local-preference 200 
#
route-policy lp1 permit node 20 
#
route-policy lp2 permit node 10 
 if-match ip-prefix lp2 
 apply local-preference 200 
#
route-policy lp2 permit node 20 
#
ip ip-prefix lp1 index 10 permit 192.168.1.0 24
ip ip-prefix lp2 index 10 permit 192.168.2.0 24


R5:
interface GigabitEthernet0/0/2
 ip address 45.0.0.2 255.255.255.0 
#
interface NULL0
#
interface LoopBack0
 ip address 192.168.10.1 255.255.255.0 
#
interface LoopBack1
 ip address 192.168.11.1 255.255.255.0 
#
interface LoopBack2
 ip address 192.168.12.1 255.255.255.0 
#
bgp 500
 router-id 5.5.5.5
 peer 45.0.0.1 as-number 123 
 #
 ipv4-family unicast
  undo synchronization
  network 192.168.10.0 
  network 192.168.11.0 
  network 192.168.12.0 
  peer 45.0.0.1 enable
  peer 45.0.0.1 as-path-filter 1 import 
  peer 45.0.0.1 route-policy com import
#
route-policy com deny node 10 
 if-match community-filter 1 
#
route-policy com permit node 20 
#
ip as-path-filter 1 deny _123$
ip as-path-filter 1 permit .*
#
ip community-filter 1 permit 400:333

结果

R1的BGP路由表

R4的BGP路由表

R5的BGP路由表

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值