题目要求
1.使用PreVal策略,确保R1通过R3到达192.168.10.0/24
2.使用AS_Path策略,确保R1通过R3到达192.168.11.0/24
3.配置MED策略,确保R1通过R3到达192.168.12.0/24
4.使用Local Preference策略,确保R4通过R2到达192.168.1.0/24
5.使用Local Preference策略,确保R4通过R3到达192.168.2.0/24
6.配置负载均衡,确保R4通过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/0ip address 12.0.0.1 255.255.255.0
#
interface GigabitEthernet0/0/1ip address 13.0.0.1 255.255.255.0
#
interface LoopBack0ip address 192.168.1.1 255.255.255.0
#
interface LoopBack1ip address 192.168.2.1 255.255.255.0
#
interface LoopBack2ip address 192.168.3.1 255.255.255.0
#
bgp 400router-id 1.1.1.1peer 12.0.0.2 as-number 123 peer 13.0.0.2 as-number 123 #ipv4-family unicastundo synchronizationnetwork 192.168.1.0 network 192.168.2.0 network 192.168.3.0 route-policy community peer 12.0.0.2 enablepeer 12.0.0.2 route-policy as importpeer 12.0.0.2 advertise-communitypeer 13.0.0.2 enablepeer 13.0.0.2 route-policy pv importpeer 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 24R2:
interface GigabitEthernet0/0/0ip address 12.0.0.2 255.255.255.0
#
interface GigabitEthernet0/0/1ip address 24.0.0.1 255.255.255.0
#
interface LoopBack0ip address 2.2.2.2 255.255.255.255
#
interface LoopBack1ip address 192.168.20.1 255.255.255.0 ospf network-type broadcast
#
bgp 123router-id 2.2.2.2peer 4.4.4.4 as-number 123 peer 4.4.4.4 connect-interface LoopBack0peer 12.0.0.1 as-number 400 #ipv4-family unicastundo synchronizationnetwork 192.168.20.0 peer 4.4.4.4 enablepeer 4.4.4.4 next-hop-local peer 4.4.4.4 advertise-communitypeer 12.0.0.1 enablepeer 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 24R3:
interface GigabitEthernet0/0/0ip address 13.0.0.2 255.255.255.0
#
interface GigabitEthernet0/0/1ip address 34.0.0.1 255.255.255.0
#
interface LoopBack0ip address 3.3.3.3 255.255.255.255
#
interface LoopBack1ip address 192.168.30.1 255.255.255.0 ospf network-type broadcast
#
bgp 123router-id 3.3.3.3peer 4.4.4.4 as-number 123 peer 4.4.4.4 connect-interface LoopBack0peer 13.0.0.1 as-number 400 #ipv4-family unicastundo synchronizationnetwork 192.168.30.0 peer 4.4.4.4 enablepeer 4.4.4.4 next-hop-local peer 4.4.4.4 advertise-communitypeer 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/0ip address 24.0.0.2 255.255.255.0
#
interface GigabitEthernet0/0/1ip address 34.0.0.2 255.255.255.0
#
interface GigabitEthernet0/0/2ip address 45.0.0.1 255.255.255.0
#
interface LoopBack0ip address 4.4.4.4 255.255.255.255
#
interface LoopBack1ip address 192.168.100.1 255.255.255.0 ospf network-type broadcast
#
bgp 123router-id 4.4.4.4peer 2.2.2.2 as-number 123 peer 2.2.2.2 connect-interface LoopBack0peer 3.3.3.3 as-number 123 peer 3.3.3.3 connect-interface LoopBack0peer 45.0.0.2 as-number 500 #ipv4-family unicastundo synchronizationnetwork 192.168.100.0 maximum load-balancing 2peer 2.2.2.2 enablepeer 2.2.2.2 route-policy lp1 importpeer 2.2.2.2 next-hop-local peer 3.3.3.3 enablepeer 3.3.3.3 route-policy lp2 importpeer 3.3.3.3 next-hop-local peer 45.0.0.2 enablepeer 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 24R5:
interface GigabitEthernet0/0/0ip address 45.0.0.2 255.255.255.0
#
interface LoopBack0ip address 192.168.10.1 255.255.255.0
#
interface LoopBack1ip address 192.168.11.1 255.255.255.0
#
interface LoopBack2ip address 192.168.12.1 255.255.255.0
#
bgp 500router-id 5.5.5.5peer 45.0.0.1 as-number 123 #ipv4-family unicastundo synchronizationnetwork 192.168.10.0 network 192.168.11.0 network 192.168.12.0 peer 45.0.0.1 enablepeer 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协议的路由表
R4去往192.168.3.0/24的网段实现负载分担
R5基于BGP协议的路由表