一.实验拓扑![](https://img-blog.csdnimg.cn/direct/94875605a93d40229a8c1b74d1b071ff.png)
二.实验需求
1.AS1(R1)和AS3(R8)路由器还回固定,所有AS2区域的IP地址均使用172.16.0.0/16进行地址规划.
2.AS1中存在两个环回,一个地址为192.168.1.0/24,该地址不能在任何协议中宣告;AS3中存在两个环回,一个地址为192.168.2.0/24,该地址不能在任何协议中宣告,最终要求这两个环回可以ping通.
3.利用BGP协议全网可达,减少路由条目,避免环路出现.
三.实验步骤
1.IP地址的规划
AS1(AR1):用来建立隧道的环回地址-LookBack0-192.168.1.1 24;用来模拟访问的地址-LookBack1-10.0.0.1 24
AS2:用172.16.0.0/16进行划分:
骨干:172.16.0.0/18
R2-R3:172.16.0.0/30
R3-R4:172.16.0.4/30
R4-R7:172.16.0.8/30
R6-R7:172.16.0.12/30
R5-R6:172.16.0.16/30
R2-R5:172.16.0.20/30
建立对等体环回L0:172.16.64.0/18
R2:172.16.64.1/32
R3:172.16.64.2/32
R4:172.16.64.3/32
R5:172.16.64.4/32
R6:172.16.64.5/32
R7:172.16.64.6/32
模拟用户网段L1:172.16.128.0/18
R2:172.16.128.0/24
R3:172.16.129.0/24
R4:172.16.130.0/24
R5:172.16.131.0/24
R6:172.16.132.0/24
R7:172.16.133.0/24
AS3(AR8)的IP地址:用来建立隧道的环回地址-LookBack0-192.168.2.1 24;用来模拟访问的地址-LookBack1-11.0.0.1 24
2.R1-R8的IP配置
R1:![](https://img-blog.csdnimg.cn/direct/86d0433fe2e04bdaa7dcc7db5572346c.png)
R2:
R3:![](https://img-blog.csdnimg.cn/direct/956a4407062540baa5966d7a08d3faba.png)
R4:
R5:![](https://img-blog.csdnimg.cn/direct/f50b9c12bea745aa9fb7f7be8b5948f7.png)
R6:
R7:![](https://img-blog.csdnimg.cn/direct/7daf12a7a5fb46239d9ecbb729256ef0.png)
R8:
3.AS2(R2-R7)启动OSPF
R2:
[R2]ospf 1 router-id 2.2.2.2
[R2-ospf-1]area 0
[R2-ospf-1-area-0.0.0.0]network 172.16.0.0 0.0.255.255
R3:
[R3]ospf 1 router-id 3.3.3.3
[R3-ospf-1]area 0
[R3-ospf-1-area-0.0.0.0]network 172.16.0.0 0.0.255.255
R4:
[R4]OSPF 1 ROUT 4.4.4.4
[R4-ospf-1]AREA 0
[R4-ospf-1-area-0.0.0.0]NETW 172.16.0.0 0.0.255.255
R5:
[R5]OSPF 1 ROU 5.5.5.5
[R5-ospf-1]ARE 0
[R5-ospf-1-area-0.0.0.0]NETW 172.16.0.0 0.0.255.255
R6:
[R6]OS 1 ROU 6.6.6.6
[R6-ospf-1]AR 0
[R6-ospf-1-area-0.0.0.0]NET 172.16.0.0 0.0.255.255
R7:
[R7]OS 1 RO 7.7.7.7
[R7-ospf-1]AR 0
[R7-ospf-1-area-0.0.0.0]NET 172.16.0.0 0.0.255.255
4.配置BGP
R1:
[R1]BGP 1
[R1-bgp]ROUTER-ID 1.1.1.1
[R1-bgp]PEER 12.0.0.2 AS-NUMBER 2
R2:
[R2]BGP 64512
[R2-bgp]ROUT 2.2.2.2
[R2-bgp]CONFEDERATION ID 2
[R2-bgp]CONFE PEER-AS 64513
[R2-bgp]PEER 12.0.0.1 AS-NEMBER 1
^
Error: Unrecognized command found at '^' position.
[R2-bgp]PEER 12.0.0.1 AS
[R2-bgp]PEER 12.0.0.1 as-number 1
[R2-bgp]peer 172.16.64.2 as-
[R2-bgp]peer 172.16.64.2 as-path-filter
[R2-bgp]peer 172.16.64.2 as-number 64512
[R2-bgp]pe
Dec 4 2023 23:13:21-08:00 R2 %%01BGP/3/STATE_CHG_UPDOWN(l)[0]:The status of the
peer 12.0.0.1 changed from OPENCONFIRM to ESTABLISHED. (InstanceName=Public, St
ateChangeReason=Up)
[R2-bgp]peer 172.16.64.2 connect-interface looback 0
^
Error: Wrong parameter found at '^' position.
[R2-bgp]peer 172.16.64.2 connect-interface lookback 0
^
Error: Wrong parameter found at '^' position.
[R2-bgp]peer 172.16.64.2 connect-interface
[R2-bgp]peer 172.16.64.2 connect-interface l
[R2-bgp]peer 172.16.64.2 connect-interface LoopBack 0
[R2-bgp]peer 172.16.64.4 as-
[R2-bgp]peer 172.16.64.4 as-number 64513
^
Error: Wrong parameter found at '^' position.
[R2-bgp]peer 172.16.64.4 as-numbe r64513
^
Error: Wrong parameter found at '^' position.
[R2-bgp]peer 172.16.64.4 as-numbe 64513
[R2-bgp]peer 172.16.64.4 cone
[R2-bgp]peer 172.16.64.4 conn
[R2-bgp]peer 172.16.64.4 connect-interface lo
[R2-bgp]peer 172.16.64.4 connect-interface LoopBack 0
[R2-bgp]peer 172.16.64.4 ebgp-
[R2-bgp]peer 172.16.64.4 ebgp-max-hop
[R2-bgp]peer 172.16.64.2 next-
[R2-bgp]peer 172.16.64.2 next-hop-invariable
[R2-bgp]peer 172.16.64.2 next-hop-local
[R2-bgp]peer 172.16.64.4 next-hop-l
[R2-bgp]peer 172.16.64.4 next-hop-local
R3:
[R3]bgp 64512
[R3-bgp]router-id 3.3.3.3
[R3-bgp]confederation id 2
[R3-bgp]peer 172.16.64.1 as-number 64512
[R3-bgp]peer 172.16.64.3 as-number 64512
[R3-bgp]peer 172.16.64.1 connect-interface LoopBack 0
[R3-bgp]peer 172.16.64.3 connect-interface LoopBack 0
R4:
[R4]BGP 64512
[R4-bgp]ROUT 4.4.4.4
[R4-bgp]CONFE ID 2
[R4-bgp]CONFED PEER-AS 64513
[R4-bgp]PEER 172.16.64.2 AS-NUMBER 64512
[R4-bgp]PEER 172.16.64.2 CON L 0
[R4-bgp]PEER 172.16.64.6 AS-NUM 64513
[R4-bgp]PEER 172.16.64.6 CON L
Dec 4 2023 23:22:25-08:00 R4 %%01BGP/3/STATE_CHG_UPDOWN(l)[0]:The status of the
peer 172.16.64.2 changed from OPENCONFIRM to ESTABLISHED. (InstanceName=Public,
StateChangeReason=Up)
[R4-bgp]PEER 172.16.64.6 CON L 0
[R4-bgp]PEER 172.16.64.6 EBGP-
[R4-bgp]PEER 172.16.64.6 ebgp-max-hop
R5:
[R5]bgp 64513
[R5-bgp]rou 5.5.5.5
[R5-bgp]confe id 2
[R5-bgp]confe peer-as 64512
[R5-bgp]peer 172.16.64.1 as-num 64512
[R5-bgp]peer 172.16.64.1 con l 0
[R5-bgp]peer 172.16.64.5 as-n 64513
[R5-bgp]peer 172.16.64.5 con l 0
[R5-bgp]peer 172.16.64.1 ebg
[R5-bgp]peer 172.16.64.1 ebgp-max-hop
R6:
[R6]bgp 64513
[R6-bgp]rout 6.6.6.6
[R6-bgp]confe id 2
[R6-bgp]peer 172.16.64.4 as-n 64513
[R6-bgp]peer 172.16.64.6 as-n 64513
[R6-bgp]peer 172.16.64.4 con l 0
[R6-bgp]peer 172.16.64.6 con l 0
R7:
[R7]bgp 64513
[R7-bgp]rou 7.7.7.7
[R7-bgp]conf id 2
[R7-bgp]conf peer-as 64512
[R7-bgp]peer 78.0.0.2 as-n 3
[R7-bgp]peer 172.16.64.3 as-n 64512
[R7-bgp]peer 172.16.64.3 con l 0
[R7-bgp]peer 172.16.64.5 as-n 64513
[R7-bgp]peer 172.16.64.5 con l 0
[R7-bgp]peer 172.16.64.3 ebgp
[R7-bgp]peer 172.16.64.3 ebgp-max-hop
[R7-bgp]peer 172.16.64.3
Dec 4 2023 23:29:41-08:00 R7 %%01BGP/3/STATE_CHG_UPDOWN(l)[0]:The status of the
peer 172.16.64.5 changed from OPENCONFIRM to ESTABLISHED. (InstanceName=Public,
StateChangeReason=Up)
[R7-bgp]peer 172.16.64.3 next-hop-local
Dec 4 2023 23:29:57-08:00 R7 %%01BGP/3/STATE_CHG_UPDOWN(l)[1]:The status of the
peer 172.16.64.3 changed from OPENCONFIRM to ESTABLISHED. (InstanceName=Public,
StateChangeReason=Up)
[R7-bgp]peer 172.16.64.5 next-hop-local
R8:
[R8]BGP 3
[R8-bgp]ROU 8.8.8.8
[R8-bgp]PEER 78.0.0.1 AS-N 2
5.R1、R8发布路由信息
[R1]bgp 1
[R1-bgp]netw 10.0.0.0 24
[R8]bgp 3
[R8-bgp]netw 11.0.0.0 24
6.R3、R6破除水平分割,配置反射
[R3]bgp 64512
[R3-bgp]peer 172.16.64.1 reflect-client
[R6]bgp 64513
[R6-bgp]peer 172.16.64.4 reflect-client
7.R2、R7配置防环和宣告
[R2]ip rou 172.16.0.0 16 null 0
[R2]bgp 64512
[R2-bgp]netw 172.16.0.0 16
[R7]ip route-static 172.16.0.0 16 null 0
[R7]bgp 64513
[R7-bgp]netw 172.16.0.0 16
8.R1、R8建立GRE隧道
![](https://img-blog.csdnimg.cn/direct/4faa906f034f4e9dada0b4f9bd36ac92.png)
ping测试: