WOLF-LAB沃尔夫网络实验室中国网络精英的发源地!
24小时咨询热线:173-1636-2402

技术文档

Technical documentation

您当前位置: 首页 > 技术文档 > 详情

HCIP培训Datacom网络技术学习考试BGP综合实验(含需求)

发布日期:2023-07-13 浏览次数:801 来源:WOLFLAB

HCIP培训Datacom网络技术学习考试BGP综合实验(含需求)


图片1(146).png

华为认证HCIP Datacom培训咨询联系【WOLFLAB实验室】,课程循环开班,找在线客服可获取基础课免费资料!

一、 地址描述

1. R1-R5都有一个loopback0 IP ADD = 10.10.X.X/24,X=ROUTER NUMBER,比如R1 的LO0 =10.10.1.1/24。

2. R1-R3以太口地址为:1.1.123.X/27,X=ROUTER NUMBER。

3. R2-R4接口地址为:1.1.24.X/24,X=ROUTER NUMBER。

4. R3-R4接口地址为:1.1.34.X/24,X=ROUTER NUMBER。

5. R4-R5接口地址为:1.1.45.X/24,X=ROUTER NUMBER。

二、 BRIDGE与OSPF的基本配置

1. 如图所示, 配置R1-R3的以太口地址。

2. 如图所示, 配置R2-R4,R3-R4,R4-R5之间物理接口地址。 

3. 配置R1-R5的loopback0。

4. 配置完成后,测试各直连链路应能正常通讯。

5. 在R1-R5上,按拓扑标识的区域,运行OSPF,并将R1-R5的loopback0宣告进OSPF。测试各路由器的邻居关系。

6. 在R5上做配置,使R5可以看到除了10.10.4.4以外的其他所有路由。

[R5]ip ip-prefix 10.4 deny 10.10.4.4 32

[R5]ip ip-prefix 10.4 permit 0.0.0.0 0 greater-equal 0 less-equal 32

[R5-ospf-1]filter-policy ip-prefix 10.4 import


三、 BGP PEER的建立,路由传递,参数修改,路由选择

1. R2,R3,R5属于 AS 235,建立两条 IBGP PEER:R5与 R2,R5与 R3。要求建邻居的时候,建立尽可能长的 TCP连接 。

R2

bgp 235

 router-id 2.2.2.2

 peer 10.10.5.5 as-number 235 

 peer 10.10.5.5 connect-interface LoopBack0


[R3-bgp]dis th

[V200R003C00]

#

bgp 235

 router-id 3.3.3.3

 peer 10.10.5.5 as-number 235 

 peer 10.10.5.5 connect-interface LoopBack0


[R5-bgp]display th

[V200R003C00]

#

bgp 235

 router-id 5.5.5.5

 peer 10.10.2.2 as-number 235 

 peer 10.10.2.2 connect-interface LoopBack0

 peer 10.10.3.3 as-number 235 

 peer 10.10.3.3 connect-interface LoopBack0


[R5]display bgp peer


 BGP local router ID : 5.5.5.5

 Local AS number : 235

 Total number of peers : 2   Peers in established state : 2


  Peer            V          AS  MsgRcvd  MsgSent  OutQ  Up/Down       State Pre

fRcv


  10.10.2.2       4         235        6        6     0 00:04:25 Established    

   0

  10.10.3.3       4         235        6        6     0 00:04:29 Established    

   0

[R5]

2. R4属于 AS 64512,与 R5建立一条 EBGP PEER,要求 :

要求用两台路由器的loopback0建立

在R4上做配置,使它与R5建立PEER时,指向64513


[R4-bgp]display th

[V200R003C00]

#

bgp 64512

 router-id 4.4.4.4

 peer 10.10.5.5 as-number 64513 

 peer 10.10.5.5 ebgp-max-hop 255 

 peer 10.10.5.5 connect-interface LoopBack0

 #

 ipv4-family unicast

  undo synchronization

  peer 10.10.5.5 enable

#

return

[R4-bgp]


[R5-bgp]dis th

[V200R003C00]

#

bgp 235

 router-id 5.5.5.5

 peer 10.10.2.2 as-number 235 

 peer 10.10.2.2 connect-interface LoopBack0

 peer 10.10.3.3 as-number 235 

 peer 10.10.3.3 connect-interface LoopBack0

 peer 10.10.4.4 as-number 64512 

 peer 10.10.4.4 ebgp-max-hop 255 

 peer 10.10.4.4 connect-interface LoopBack0

 #

 ipv4-family unicast

  undo synchronization

  peer 10.10.2.2 enable

  peer 10.10.3.3 enable

  peer 10.10.4.4 enable

#

return

[R5-bgp]


[R5-bgp]peer 10.10.4.4 fake-as 64513

[R5]ip route-static 10.10.4.0 255.255.255.0 1.1.45.4



3. R1属于 AS 1,需要与R2、 R3建立EBGP PEER,要求只要有一条 Active Path,BGP邻居 不能 Down。

[R1-bgp]display th

[V200R003C00]

#

bgp 1

 router-id 1.1.1.1

 peer 10.10.2.2 as-number 235 

 peer 10.10.2.2 ebgp-max-hop 255 

 peer 10.10.2.2 connect-interface LoopBack0

 peer 10.10.3.3 as-number 235 

 peer 10.10.3.3 ebgp-max-hop 255 

 peer 10.10.3.3 connect-interface LoopBack0


[R2-bgp]display this 

[V200R003C00]

#

bgp 235

 router-id 2.2.2.2

 peer 10.10.1.1 as-number 1 

 peer 10.10.1.1 ebgp-max-hop 255 

 peer 10.10.1.1 connect-interface LoopBack0


[R3-bgp]display th

[V200R003C00]

#

bgp 235

 router-id 3.3.3.3

 peer 10.10.1.1 as-number 1 

 peer 10.10.1.1 ebgp-max-hop 255 

 peer 10.10.1.1 connect-interface LoopBack0



4. 在R1上增加一个loopback101, 其IP ADD=101.1.1.1/24,通过network宣告进BGP,此时在R5的BGP表中会看到两条路由。希望在路由表里也可以看到两条等价路由。

[R1-LoopBack101]ip address 101.1.1.1 24

[R1-bgp]network 101.1.1.0 255.255.255.0


[R2]ip ip-prefix 101.1 permit 101.1.1.0 24

[R2-route-policy]dis th

[V200R003C00]

#

route-policy R2-R5-EX permit node 10 

 if-match ip-prefix 101.1 

 apply ip-address next-hop 10.10.2.2 

#

route-policy R2-R5-EX permit node 20 

#

return

[R2-route-policy]

[R2-bgp]peer 10.10.5.5 route-policy R2-R5-EX export 



R3

[R3]ip ip-prefix 101.1 permit 101.1.1.0 24

[R3]route-policy R3-R5-EX permit node 10

[R3-route-policy]if-match ip-prefix 101.1

[R3-route-policy]apply ip-address next-hop 10.10.3.3

[R3]route-policy R3-R5-EX permit node 20

[R3-bgp]peer 10.10.5.5 route-policy R3-R5-EX export 


[R5-bgp]maximum load-balancing ibgp 2




5. 在R4上增加一个loopback104,其地址如下:

interface Loopback104

  ip address 104.1.1.1 255.255.255.0

ip address 104.1.2.1 255.255.255.0 sub

ip address 104.1.16.1 255.255.255.0 sub

用最小的命令行,将这些路由引入BGP,并且使R5看到这些路由的Origin是:IGP。

R4

interface LoopBack104

 ip address 104.1.1.1 255.255.255.0 

 ip address 104.1.2.1 255.255.255.0 sub

 ip address 104.1.3.1 255.255.255.0 sub

 ip address 104.1.4.1 255.255.255.0 sub

 ip address 104.1.5.1 255.255.255.0 sub

 ip address 104.1.6.1 255.255.255.0 sub

 ip address 104.1.7.1 255.255.255.0 sub

 ip address 104.1.8.1 255.255.255.0 sub

 ip address 104.1.9.1 255.255.255.0 sub

 ip address 104.1.10.1 255.255.255.0 sub

 ip address 104.1.11.1 255.255.255.0 sub

 ip address 104.1.12.1 255.255.255.0 sub

 ip address 104.1.13.1 255.255.255.0 sub

 ip address 104.1.14.1 255.255.255.0 sub

 ip address 104.1.15.1 255.255.255.0 sub

 ip address 104.1.16.1 255.255.255.0 sub


[R4]route-policy LO104 permit node 10

[R4-route-policy]if-match interface LoopBack 104

[R4-route-policy]apply origin igp


[R4-bgp]import-route direct route-policy LO104



6. 在R4上做配置,使用最少的命令行,用ACL,使R4向R5传递路由时,只传递下列4条路由:

104.1.1.0/24

104.1.3.0/24

104.1.9.0/24

104.1.11.0/24


[R4-acl-basic-2000]rule 5 permit source 104.1.1.0 0.0.10.0

[R4-bgp]peer 10.10.5.5 filter-policy 2000 export 


7. 在R5上做配置, 使R5收到这四条路由时,BGP表里如下显示: 

ROUTE                    AS-PATH

104.1.1.0/24             64513 64514 64512

104.1.3.0/24             64513 64514 64512

104.1.9.0/24             64513 64514 64512

104.1.11.0/24            64513 64514 64512


R5

[R5-acl-basic-2000]rule 5 permit source 104.1.1.0 0.0.10.0

route-policy R4-R5-IM permit node 10 

 if-match acl 2000 

 apply as-path 64513 64514 additive

#

route-policy R4-R5-IM permit node 20 

[R5-bgp]peer 10.10.4.4 route-policy R4-R5-IM import


8. 在R2 R3上做配置,使R1接收这4条BGP路由时,路由的AS-PATH为:235。使用最小的配置步骤及命令行。

Bgp 1-64511是共有的,64512-65535是私有的

[R2-bgp]peer 10.10.1.1 public-as-only 

[R3-bgp]peer 10.10.1.1 public-as-only 



9. 在R5上增加四个loopback接口:

Loopback100  100.1.0.1/24 

Loopback101  100.1.1.1/24

Loopback102  100.1.2.1/24

Loopback103  100.1.3.1/24

将这些路由引入BGP,在R2与R3上聚合路由,使其在R1上看到100.1.0.0/22的路由。


[R5]route-policy A permit node 10

[R5-route-policy]if-match interface LoopBack 100 LoopBack 101 LoopBack 102 LoopBack 103

[R5-bgp]import-route direct route-policy A


[R2-bgp]aggregate 100.1.0.0 255.255.252.0 detail-suppressed as-set



10. 在R2与R3上做配置,使R1接收这条100.1.0.0/22的BGP路由时,路由的AS-PATH为:235 1 235。



[R2]ip ip-prefix 100.0 permit 100.1.0.0 22

[R2]route-policy R2-R1-EX permit node 10

[R2-route-policy]if-match ip-prefix 100.0

[R2-route-policy]apply as-path 1 235 additive 

[R2]route-policy R2-R1-EX permit node 20

[R2-bgp]peer 10.10.1.1 route-policy R2-R1-EX export 


[R3]ip ip-prefix 100.0 permit 100.1.0.0 22

[R3]route-policy R3-R1-EX permit node 10

[R3-route-policy]if-match ip-prefix 100.0

[R3-route-policy]apply as-path 1 235 additive 

[R3]route-policy R3-R1-EX permit node 20

[R3-bgp]peer 10.10.1.1 route-policy R3-R1-EX export 


R1 是as 1 所以不接受as-path有1的路由

[R1-bgp]peer 10.10.2.2 allow-as-loop 1

[R1-bgp]peer 10.10.3.3 allow-as-loop 1



11. 在R1上增加六个loopback接口:

Loopback1  200.1.1.1/24 

Loopback2  200.1.2.1/24

Loopback3  200.1.3.1/24

Loopback4  200.1.4.1/24

Loopback5  200.1.5.1/24

Loopback6  200.1.6.1/24

将这些路由引入BGP,使其在其他路由器上看到这六条路由的Origin是:IGP。



[R1]route-policy 200 permit node 10

[R1-route-policy]if-match interface LoopBack 1 lo 2 lo 3 lo 4 lo5 lo 6

[R1-route-policy]apply origin igp

[R1-bgp]import-route direct route-policy 200



12. 在R5上做配置,针对200.1.1.0/24这条路由,要求R5看到的最优路由是从R3学到的。它们是通过协议首选值来决定胜负的。


[R5]ip ip-prefix 200.1 permit 200.1.1.0 24

[R5]route-policy R3-R5-IM permit node 10

[R5-route-policy]if-match ip-prefix 200.1

[R5-route-policy]apply preferred-value 5

[R5]route-policy R3-R5-IM permit node 20

[R5-bgp]peer 10.10.3.3 route-policy R3-R5-IM import 




13. 在R5上做配置,针对200.1.2.0/24这条路由,要求R5看到的最优路由是从R3学到的。它们是通过Local Preference来决定胜负的。


[R5-route-policy]display this 

[V200R003C00]

#

route-policy R3-R5-IM permit node 10 

 if-match ip-prefix 200.1 

 apply preferred-value 5

#

route-policy R3-R5-IM permit node 20 

 if-match ip-prefix 200.2 

 apply local-preference 105 

#

route-policy R3-R5-IM permit node 30 



14. 在R1上做配置,将200.1.3.0/24通过OSPF传递过来, 并修改其OSPF网络类型为broadcast。在R5上将这条OSPF路由用network宣告进BGP,并且通过配置,确保这条路由在BGP里是最优路由。需要确保他们之间的比较是通过BGP选路原则的第三项来决定胜负的。

interface LoopBack3

 ip address 200.1.3.1 255.255.255.0 

 ospf network-type broadcast



[R1-ospf-1-area-0.0.0.2]network 200.1.3.0 0.0.0.255

[R5-bgp]network 200.1.3.0 24


[R2-bgp]bestroute as-path-ignore 跳过as_path比较

[R3-bgp]bestroute as-path-ignore 


15. 在R1上做配置,只针对R2的BGP邻居,针对200.1.4.0/24这条路由,要求R5看到的最优路由是从R3学到的, 它们是通过AS-Path来决定胜负的。

[R1]ip ip-prefix 200.4 permit 200.1.4.0 24

[R1]route-policy R1-R2-EX permit node 10

[R1-route-policy]if-match ip-prefix 200.4

[R1-route-policy]apply as-path 1 1 1 additive 

[R1]route-policy R1-R2-EX permit node 20

[R1-bgp]peer 10.10.2.2 route-policy R1-R2-EX export 



16. 在R1上做配置,只针对R2的BGP邻居,针对200.1.5.0/24这条路由,要求R5看到的最优路由是从R3学到的, 它们是通过Origin Type来决定胜负的。

[R1-route-policy]display th

[V200R003C00]

#

route-policy R1-R2-EX permit node 10 

 if-match ip-prefix 200.4 

 apply as-path 1 1 1 additive

#

route-policy R1-R2-EX permit node 20 

 if-match ip-prefix 200.5 

 apply origin incomplete



17. 在R1上做配置,只针对R2的BGP邻居,针对200.1.6.0/24这条路由,要求R5看到的最优路由是从R3学到的, 它们是通过Med来决定胜负的。


[R1-route-policy]display th

[V200R003C00]

#

route-policy R1-R2-EX permit node 10 

 if-match ip-prefix 200.4 

 apply as-path 1 1 1 additive

#

route-policy R1-R2-EX permit node 20 

 if-match ip-prefix 200.5 

 apply origin incomplete

#

route-policy R1-R2-EX permit node 30 

 if-match ip-prefix 200.6 

 apply cost 500 

#

route-policy R1-R2-EX permit node 40 

#

return

[R1-route-policy]

图片1(147).png

https://www.wolf-lab.com/

WOLFLAB官方微信:17316362402

WOLFLAB官方QQ:2569790740

华为认证HCIP Datacom培训课程咨询联系WOLF-LAB实验室

返回目录
在线咨询