一、实验拓扑
二、实验目的
1、AS1中存在两个环回,一个地址为192.168.1.0/24,该地址不能在任何协议中宣告;
AS3中存在两个环回,一个地址为192.168.2.0/24,该地址不能在任何协议中宣告,最终要求这两个环回可以ping通;
2、整个AS2的IP地址为172.16.0.0/16,请合理划分;并且其内部配置OSPF协议
3、R1-R8的建邻环回用x.x.x.x/32表示;R2-R7上除了建邻环回,每个设备再划分一个业务网段;
4、AS间的骨干链路IP地址随意定制;
5、使用BGP协议让整个网络所有设备的环回可以互相访问;
三、实验思路
- IP地址划分
- 配置IP地址
- 在AS 2 内部配置OSPF,AS 2内部互通,为BGP协议提供TCP的前提
- 因为AS 1、AS 2、AS 3在不同AS区域内,所以他们之间进行EBGP协议配置,所以在R1和R2 、R7和R8 之间配置EBGP,采取端口配置。
- 在AS 2划分了两个AS,分别是AS 64512、AS 64513,所以要采用BGP联盟方法(联盟将一个自治系统划分为若干个子自治系统,每个
子自治系统内部的IBGP对等体建立全连接关系,子自治系统之间建立联盟内部EBGP连接关系。),所以R2和R5之间进行EBGP配置(注意:跨越子AS的EBGP邻居仍然需要更改下一跳为本机),AS 64512与AS 64513之间进行IBGP配置,由于R2和R7两端都分别进行IBGP连接和EBGP连接,所以要更改下一跳为本机。
6. 将AS 2内部的业务网段进行BGP宣告,注意:建邻的网段不能进行宣告。
7. BGP配置完成后,会发现R4和R5有的路由获取不到路由信息,原因是:不能把从IBGP邻居学习的路由反射给其他IBGP邻居,
解决方法:将R3和R6作为路由反射器。
8. R1和R8业务网段不宣告的情况下,让R1和R8的业务网段互通我们使用VPN的gre完成,刚好时端对端
四、实验过程
1.IP地址划分
对172.16.0.0/16进行区域划分
172.16.0000 0000.0000 0000/16
在AS 2区域划分9个网段,用于建邻(1个/24 ---> 8个/32)、骨干(1个/24 ---> 6个/30)和业务(7个/24)
R1~R8 建邻/32:
(1)172.16.00000000.0/24
172.16.00000000.000000000/32 --- 172.16.0.0/32(不可用)
172.16.00000000.000000001/32 --- 172.16.0.1/32
172.16.00000000.000000010/32 --- 172.16.0.2/32
172.16.00000000.000000011/32 --- 172.16.0.3/32
172.16.00000000.000000100/32 --- 172.16.0.4/32
172.16.00000000.000000101/32 --- 172.16.0.5/32
172.16.00000000.000000110/32 --- 172.16.0.6/32
172.16.00000000.000000111/32 --- 172.16.0.7/32
172.16.00000000.000001000/32 --- 172.16.0.8/32
AS 2骨干/30:
(2)172.16.00000001.0/24 --- 172.16.1.0/24
172.16.00000001.000000 00/30 --- 172.16.1.0/30
172.16.00000001.000001 00/30 --- 172.16.1.4/30
172.16.00000001.000010 00/30 --- 172.16.1.8/30
172.16.00000001.000011 00/30 --- 172.16.1.12/30
172.16.00000001.000100 00/30 --- 172.16.1.16/30
172.16.00000001.000101 00/30 --- 172.16.1.20/30
业务:
(4)172.16.00000010.0/24 --- 172.16.2.0/24
(5)172.16.00000011.0/24 --- 172.16.3.0/24
(6)172.16.00000100.0/24 --- 172.16.4.0/24
(7)172.16.00000101.0/24 --- 172.16.5.0/24
(8)172.16.00000110.0/24 --- 172.16.6.0/24
(9)172.16.00000111.0/24 --- 172.16.7.0/24
2.配置IP地址
[R1]int g 0/0/0
[R1-GigabitEthernet0/0/0]ip ad 12.1.1.1 24
[R1-GigabitEthernet0/0/0]int l0
[R1-LoopBack0]ip ad 172.16.0.1 32
[R1-LoopBack0]int l1
[R1-LoopBack1]ip ad 192.168.1.1 24
[R2]int g 0/0/0
[R2-GigabitEthernet0/0/0]ip ad 12.1.1.2 24
[R2-GigabitEthernet0/0/0]int g 0/0/1
[R2-GigabitEthernet0/0/1]ip ad 172.16.1.1 30
[R2-GigabitEthernet0/0/1]int g 0/0/2
[R2-GigabitEthernet0/0/2]ip ad 172.16.1.21 30
[R2-GigabitEthernet0/0/2]int l0
[R2-LoopBack0]ip ad 172.16.0.2 32
[R2-LoopBack0]int l1
[R2-LoopBack1]ip ad 172.16.2.2 24
[R3]int g 0/0/0
[R3-GigabitEthernet0/0/0]ip ad 172.16.1.2 30
[R3-GigabitEthernet0/0/0]int g 0/0/1
[R3-GigabitEthernet0/0/1]ip ad 172.16.1.5 30
[R3-GigabitEthernet0/0/1]int l0
[R3-LoopBack0]ip ad 172.16.0.3 32
[R3-LoopBack0]int l1
[R3-LoopBack1]ip ad 172.16.3.3 24
[R4]int g 0/0/0
[R4-GigabitEthernet0/0/0]ip ad 172.16.1.6 30
[R4-GigabitEthernet0/0/0]int g 0/0/1
[R4-GigabitEthernet0/0/1]ip ad 172.16.1.9 30
[R4-GigabitEthernet0/0/1]int l0
[R4-LoopBack0]ip ad 172.16.0.4 32
[R4-LoopBack0]int l1
[R4-LoopBack1]ip ad 172.16.4.4 24
[R5]int g 0/0/0
[R5-GigabitEthernet0/0/0]ip ad 172.16.1.22 30
[R5-GigabitEthernet0/0/0]int g 0/0/1
[R5-GigabitEthernet0/0/1]ip ad 172.16.1.17 30
[R5-GigabitEthernet0/0/1]int l0
[R5-LoopBack0]ip ad 172.16.0.5 32
[R5-LoopBack0]int l1
[R5-LoopBack1]ip ad 172.16.5.5 24
[R6]int g 0/0/0
[R6-GigabitEthernet0/0/0]ip ad 172.16.1.18 30
[R6-GigabitEthernet0/0/0]int g 0/0/1
[R6-GigabitEthernet0/0/1]ip ad 172.16.1.13 30
[R6-GigabitEthernet0/0/1]int l0
[R6-LoopBack0]ip ad 172.16.0.6 32
[R6-LoopBack0]int l1
[R6-LoopBack1]ip ad 172.16.6.6 24
[R7]int g 0/0/0
[R7-GigabitEthernet0/0/0]ip ad 172.16.1.14 30
[R7-GigabitEthernet0/0/0]int g 0/0/1
[R7-GigabitEthernet0/0/1]ip ad 172.16.1.10 30
[R7-GigabitEthernet0/0/1]int g 0/0/2
[R7-GigabitEthernet0/0/2]ip ad 34.1.1.7 24
[R7-GigabitEthernet0/0/2]int l0
[R7-LoopBack0]ip ad 172.16.0.7 32
[R7-LoopBack0]int l1
[R7-LoopBack1]ip ad 172.16.7.7 24
[R8]int g 0/0/0
[R8-GigabitEthernet0/0/0]ip ad 34.1.1.8 24
[R8-GigabitEthernet0/0/0]int l1
[R8-LoopBack1]int l0
[R8-LoopBack0]ip ad 172.16.0.8 32
[R8-LoopBack0]int l1
[R8-LoopBa
3. 整个AS2的IP地址为172.16.0.0/16,内部配置OSPF协议
[R2]ospf 1 router-id 2.2.2.2
[R2-ospf-1]area 0
[R2-ospf-1-area-0.0.0.0]net 172.16.0.0 0.0.255.255
[R3]ospf 1 router-id 3.3.3.3
[R3-ospf-1]area 0
[R3-ospf-1-area-0.0.0.0]net 172.16.0.0 0.0.255.255
[R4]ospf 1 router-id 4.4.4.4
[R4-ospf-1]a 0
[R4-ospf-1-area-0.0.0.0]net 172.16.0.0 0.0.255.255
[R5]ospf 1 router-id 5.5.5.5
[R5-ospf-1]a 0
[R5-ospf-1-area-0.0.0.0]net 172.16.0.0 0.0.255.255
[R6]ospf 1 router-id 6.6.6.6
[R6-ospf-1]a 0
[R6-ospf-1-area-0.0.0.0]net 172.16.0.0 0.0.255.255
[R7]ospf 1 router-id 7.7.7.7
[R7-ospf-1]a 0
[R7-ospf-1-area-0.0.0.0]net 172.16.0.0 0.0.255.255
检查R2的OSPF路由:
[R2]display ip routing-table protocol ospf
4. 建立BGP
[R1]bgp 1
[R1-bgp]peer 12.1.1.2 as 2
[R2]bgp 64512
[R2-bgp]confederation id 2
[R2-bgp]confederation peer-as 64513
[R2-bgp]peer 12.1.1.1 as 1
[R2-bgp]peer 172.16.0.3 as 64512
[R2-bgp]peer 172.16.0.3 connect-interface l0
[R2-bgp]peer 172.16.0.3 next-hop-local
[R2-bgp]peer 172.16.1.22 as 64513
[R2-bgp]peer 172.16.1.22 next-hop-local
[R2-bgp]peer 172.16.1.22 ebgp-max-hop
[R3]bgp 64512
[R3-bgp]confederation id 2
[R3-bgp]peer 172.16.0.2 as 64512
[R3-bgp]peer 172.16.0.2 connect-interface l0
[R3-bgp]peer 172.16.0.4 as 64512
[R3-bgp]peer 172.16.0.4 connect-interface l0
[R4]bgp 64512
[R4-bgp]confederation id 2
[R4-bgp]peer 172.16.0.3 as 64512
[R4-bgp]peer 172.16.0.3 connect-interface l0
[R5]bgp 64513
[R5-bgp]confederation id 2
[R5-bgp]confederation peer-as 64512
[R5-bgp]peer 172.16.1.21 as 64512
[R5-bgp]peer 172.16.1.21 next-hop-local
[R5-bgp]peer 172.16.1.21 ebgp-max-hop
[R5-bgp]peer 172.16.0.6 as 64513
[R5-bgp]peer 172.16.0.6 connect-interface l0
[R5-bgp]peer 172.16.0.6 next-hop-local
[R6]bgp 64513
[R6-bgp]confederation id 2
[R6-bgp]peer 172.16.0.5 as 64513
[R6-bgp]peer 172.16.0.5 connect-interface l0
[R6-bgp]peer 172.16.0.7 as 64513
[R6-bgp]peer 172.16.0.7 connect-interface l0
[R7]bgp 64513
[R7-bgp]confederation id 2
[R7-bgp]peer 172.16.0.6 as 64513
[R7-bgp]peer 172.16.0.6 connect-interface l0
[R7-bgp]peer 172.16.0.6 next-hop-local
[R7-bgp]peer 34.1.1.8 as 3
查看R2邻居表:
5. 将R1到R8的业务网段宣告到BGP中
[R2-bgp]net 172.16.2.0 24
[R3-bgp]net 172.16.3.0 24
[R4-bgp]net 172.16.4.0 24
[R5-bgp]net 172.16.5.0 24
[R6-bgp]net 172.16.6.0 24
[R7-bgp]net 172.16.7.0 24
查看R2bgp的路由表:
发现访问不到R4、R7的路由,原因是:不能把从IBGP邻居学习的路由反射给其他IBGP邻居。解决办法:配置反射器
6. 为R3和R6配置反射器
[R3-bgp]peer 172.16.0.2 reflect-client
[R3-bgp]peer 172.16.0.4 reflect-client
[R6-bgp]peer 172.16.0.5 reflect-client
[R6-bgp]peer 172.16.0.7 reflect-client
再对R2的路由表进行查看:
可以查询到所有路由。
7. R1和R8业务网段不宣告的情况下,让R1和R8的业务网段互通我们使用VPN的gre完成,刚好时端对端。
由于R1和R8物理口之间不能互通,但是配置gre的前提是全网通,所以不能使用物理口进行gre配置,可以用环回口进行gre配置,再在R1和R8进行静态路由配置,让R1与R8之间的业务网段可以互通。
在R1和R8对建邻网段进行bgp宣告
[R1-bgp]net 172.16.0.1 32
[R8-bgp]net 172.16.0.8 32
在R1进行查看:
配置成功。
[R1]ping -a 172.16.0.1 172.16.0.8
- 在R1和R8上分别配置gre
[R1]int Tunnel 0/0/0
[R1-Tunnel0/0/0]ip ad 10.0.0.1 24
[R1-Tunnel0/0/0]tunnel-protocol gre
[R1-Tunnel0/0/0]source 172.16.0.1
[R1-Tunnel0/0/0]destination 172.16.0.8
[R8]int Tunnel 0/0/0
[R8-Tunnel0/0/0]ip ad 10.0.0.8 24
[R8-Tunnel0/0/0]tunnel-protocol gre
[R8-Tunnel0/0/0]source 172.16.0.8
[R8-Tunnel0/0/0]destination 172.16.0.1
在R1和R8进行静态路由配置(私网路由传到隧道)
[R1]ip route-static 192.168.1.0 24 10.0.0.2
[R8]ip route-static 192.168.1.0 24 10.0.0.1
进行测试:
[R1]ping -a 192.168.1.1 192.168.2.8
R1与R8的业务网段可以互通,实验到此结束!!!