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


[V200R003C00]
#
 sysname R1
#
 snmp-agent local-engineid 800007DB03000000000000
 snmp-agent 
#
 clock timezone China-Standard-Time minus 08:00:00
#
portal local-server load flash:/portalpage.zip
#
 drop illegal-mac alarm
#
 wlan ac-global carrier id other ac id 0
#
 set cpu-usage threshold 80 restore 75
#
aaa 
 authentication-scheme default
 authorization-scheme default
 accounting-scheme default
 domain default 
 domain default_admin 
 local-user admin password cipher %$%$K8m.Nt84DZ}e#<0`8bmE3Uw}%$%$
 local-user admin service-type http
#
firewall zone Local
 priority 15
#
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
 ip address 15.0.0.1 255.255.255.0 
#
interface NULL0
#
interface LoopBack0
 ip address 1.1.1.1 255.255.255.255 
#
interface LoopBack1
 ip address 192.168.100.1 255.255.255.0 
#
bgp 123
 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 15.0.0.5 as-number 500 
 #
 ipv4-family unicast
  undo synchronization
  network 192.168.20.0 
  network 192.168.30.0 
  network 192.168.100.0 
  maximum load-balancing 2
  peer 2.2.2.2 enable
  peer 2.2.2.2 route-policy aa import
  peer 2.2.2.2 next-hop-local 
  peer 3.3.3.3 enable
  peer 3.3.3.3 route-policy bb import
  peer 3.3.3.3 next-hop-local 
  peer 15.0.0.5 enable
  peer 15.0.0.5 route-policy com export
#
ospf 1 router-id 1.1.1.1 
 area 0.0.0.0 
  network 1.1.1.0 0.0.0.255 
  network 12.0.0.0 0.0.0.255 
  network 13.0.0.0 0.0.0.255 
  network 192.168.100.0 0.0.0.255 
#
route-policy aa permit node 10 
 if-match ip-prefix LP 
 apply local-preference 200 
#
route-policy aa permit node 20 
#
route-policy bb permit node 10 
 if-match ip-prefix LP2 
 apply local-preference 200 
#
route-policy bb permit node 20 
#
route-policy com deny node 10 
 if-match community-filter 1 
#
route-policy com permit node 20 
#
ip ip-prefix LP index 10 permit 192.168.1.0 24
ip ip-prefix LP2 index 10 permit 192.168.2.0 24
#
ip community-filter 1 permit 400:500
#
user-interface con 0
 authentication-mode password
user-interface vty 0 4
user-interface vty 16 20
#
wlan ac
#
return

R2


[V200R003C00]
#
 sysname R2
#
 snmp-agent local-engineid 800007DB03000000000000
 snmp-agent 
#
 clock timezone China-Standard-Time minus 08:00:00
#
portal local-server load flash:/portalpage.zip
#
 drop illegal-mac alarm
#
 wlan ac-global carrier id other ac id 0
#
 set cpu-usage threshold 80 restore 75
#
aaa 
 authentication-scheme default
 authorization-scheme default
 accounting-scheme default
 domain default 
 domain default_admin 
 local-user admin password cipher %$%$K8m.Nt84DZ}e#<0`8bmE3Uw}%$%$
 local-user admin service-type http
#
firewall zone Local
 priority 15
#
interface GigabitEthernet0/0/0
 ip address 24.0.0.2 255.255.255.0 
#
interface GigabitEthernet0/0/1
 ip address 12.0.0.2 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 
#
bgp 123
 router-id 2.2.2.2
 peer 1.1.1.1 as-number 123 
 peer 1.1.1.1 connect-interface LoopBack0
 peer 24.0.0.4 as-number 400 
 #
 ipv4-family unicast
  undo synchronization
  network 192.168.20.0 
  network 192.168.30.0 
  network 192.168.100.0 
  peer 1.1.1.1 enable
  peer 1.1.1.1 next-hop-local 
  peer 1.1.1.1 advertise-community
  peer 24.0.0.4 enable
#
ospf 1 router-id 2.2.2.2 
 area 0.0.0.0 
  network 2.2.2.2 0.0.0.0 
  network 12.0.0.0 0.0.0.255 
  network 192.168.20.0 0.0.0.255 
#
user-interface con 0
 authentication-mode password
user-interface vty 0 4
user-interface vty 16 20
#
wlan ac
#
return

R3


[V200R003C00]
#
 sysname R3
#
 snmp-agent local-engineid 800007DB03000000000000
 snmp-agent 
#
 clock timezone China-Standard-Time minus 08:00:00
#
portal local-server load flash:/portalpage.zip
#
 drop illegal-mac alarm
#
 wlan ac-global carrier id other ac id 0
#
 set cpu-usage threshold 80 restore 75
#
aaa 
 authentication-scheme default
 authorization-scheme default
 accounting-scheme default
 domain default 
 domain default_admin 
 local-user admin password cipher %$%$K8m.Nt84DZ}e#<0`8bmE3Uw}%$%$
 local-user admin service-type http
#
firewall zone Local
 priority 15
#
interface GigabitEthernet0/0/0
 ip address 34.0.0.3 255.255.255.0 
#
interface GigabitEthernet0/0/1
 ip address 13.0.0.3 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 
#
bgp 123
 router-id 3.3.3.3
 peer 1.1.1.1 as-number 123 
 peer 1.1.1.1 connect-interface LoopBack0
 peer 34.0.0.4 as-number 400 
 #
 ipv4-family unicast
  undo synchronization
  network 192.168.20.0 
  network 192.168.30.0 
  network 192.168.100.0 
  peer 1.1.1.1 enable
  peer 1.1.1.1 next-hop-local 
  peer 1.1.1.1 advertise-community
  peer 34.0.0.4 enable
#
ospf 1 router-id 3.3.3.3 
 area 0.0.0.0 
  network 3.3.3.3 0.0.0.0 
  network 13.0.0.0 0.0.0.255 
  network 192.168.30.0 0.0.0.255 
#
user-interface con 0
 authentication-mode password
user-interface vty 0 4
user-interface vty 16 20
#
wlan ac
#
return

R4


[V200R003C00]
#
 sysname R4
#
 snmp-agent local-engineid 800007DB03000000000000
 snmp-agent 
#
 clock timezone China-Standard-Time minus 08:00:00
#
portal local-server load flash:/portalpage.zip
#
 drop illegal-mac alarm
#
 wlan ac-global carrier id other ac id 0
#
 set cpu-usage threshold 80 restore 75
#
aaa 
 authentication-scheme default
 authorization-scheme default
 accounting-scheme default
 domain default 
 domain default_admin 
 local-user admin password cipher %$%$K8m.Nt84DZ}e#<0`8bmE3Uw}%$%$
 local-user admin service-type http
#
firewall zone Local
 priority 15
#
interface GigabitEthernet0/0/0
 ip address 24.0.0.4 255.255.255.0 
#
interface GigabitEthernet0/0/1
 ip address 34.0.0.4 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 4.4.4.4
 peer 24.0.0.2 as-number 123 
 peer 34.0.0.3 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 com 
  peer 24.0.0.2 enable
  peer 24.0.0.2 route-policy aa import
  peer 24.0.0.2 advertise-community
  peer 34.0.0.3 enable
  peer 34.0.0.3 route-policy bb import
  peer 34.0.0.3 advertise-community
#
route-policy aa permit node 10 
 if-match ip-prefix aa 
 apply preferred-value 1000
#
route-policy aa permit node 15 
 if-match ip-prefix bb 
 apply as-path 123 123 500 500 overwrite
#
route-policy aa permit node 16 
 if-match ip-prefix MED 
 apply cost 500 
#
route-policy aa permit node 20 
#
route-policy bb permit node 10 
 if-match ip-prefix MED 
 apply cost 200 
#
route-policy bb permit node 20 
#
route-policy com permit node 10 
 apply community 400:500 
#
ip ip-prefix aa index 10 permit 192.168.10.0 24
ip ip-prefix bb index 10 permit 192.168.11.0 24
ip ip-prefix MED index 10 permit 192.168.12.0 24
#
user-interface con 0
 authentication-mode password
user-interface vty 0 4
user-interface vty 16 20
#
wlan ac
#
return

R5


[V200R003C00]
#
 sysname R5
#
 snmp-agent local-engineid 800007DB03000000000000
 snmp-agent 
#
 clock timezone China-Standard-Time minus 08:00:00
#
portal local-server load flash:/portalpage.zip
#
 drop illegal-mac alarm
#
 wlan ac-global carrier id other ac id 0
#
 set cpu-usage threshold 80 restore 75
#
aaa 
 authentication-scheme default
 authorization-scheme default
 accounting-scheme default
 domain default 
 domain default_admin 
 local-user admin password cipher %$%$K8m.Nt84DZ}e#<0`8bmE3Uw}%$%$
 local-user admin service-type http
#
firewall zone Local
 priority 15
#
interface GigabitEthernet0/0/0
 ip address 15.0.0.5 255.255.255.0 
#
interface GigabitEthernet0/0/1
#
interface GigabitEthernet0/0/2
#
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
 peer 15.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 15.0.0.1 enable
  peer 15.0.0.1 as-path-filter 1 import 
#
ip as-path-filter 1 deny ^123$
ip as-path-filter 1 permit .*
#
user-interface con 0
 authentication-mode password
user-interface vty 0 4
user-interface vty 16 20
#
wlan ac
#
return
  • 9
    点赞
  • 8
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

CyberSecure

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值