实验要求
网段设置如上图所示黄色为公网网段,绿色为各个路由器的私有环回网段
步骤一:给每个路由器配ip和环回ip
将接入ISP接口的ip地址都设置成?.?.?.2
[r1]interface g 0/0/0
[r1-GigabitEthernet0/0/0]ip address 15.0.0.1 24
[r1-GigabitEthernet0/0/0]interface g 0/0/1
[r1-GigabitEthernet0/0/1]ip address 5.0.0.1 24
[r1]int LoopBack 0
[r1-LoopBack0]ip address 192.168.1.1 24
[r2]interface g 0/0/0
[r2-GigabitEthernet0/0/0]ip address 25.0.0.1 24
[r2]interface LoopBack 0
[r2-LoopBack0]ip address 192.168.2.1 24
[r3]interface g 0/0/0
[r3-GigabitEthernet0/0/0]ip address 35.0.0.1 24
[r3]interface LoopBack 0
[r3-LoopBack0]ip address 192.168.3.1 24
[r4]interface g 0/0/0
[r4-GigabitEthernet0/0/0]ip address 45.0.0.1 24
[r4]interface LoopBack 0
[r4-LoopBack0]ip address 192.168.4.1 24
[r5]interface g 0/0/0
[r5-GigabitEthernet0/0/0]ip address 55.0.0.1 24
[r5]int LoopBack 0
[r5-LoopBack0]ip address 192.168.5.1 24
[ISP]interface g 0/0/1
[ISP-GigabitEthernet0/0/1]ip address 5.0.0.2 24
[ISP]interface g 0/0/0
[ISP-GigabitEthernet0/0/0]ip address 15.0.0.2 24
[ISP]interface g 2/0/0
[ISP-GigabitEthernet2/0/0]ip address 25.0.0.2 24
[ISP]interface g 3/0/0
[ISP-GigabitEthernet3/0/0]ip address 35.0.0.2 24
[ISP]interface g 4/0/0
[ISP-GigabitEthernet4/0/0]ip address 45.0.0.2 24
[ISP]interface g 0/0/2
[ISP-GigabitEthernet0/0/2]ip address 55.0.0.2 24
步骤二:配置各个路由器的缺省路由以实现公网通
[r1]ip route-static 0.0.0.0 0 5.0.0.2
[r1]ip route-static 0.0.0.0 0 15.0.0.2
[r2]ip route-static 0.0.0.0 0 25.0.0.2
[r3]ip route-static 0.0.0.0 0 35.0.0.2
[r4]ip route-static 0.0.0.0 0 45.0.0.2
[r5]ip route-static 0.0.0.0 0 55.0.0.2
验证一下查看是否通了
可以看出缺省成功了
步骤三:实现r1、4、5 的全连MGRE
[r1]int Tunnel 0/0/0 //创建隧道接口
[r1-Tunnel0/0/0]ip address 192.168.10.1 24 //配置隧道接口ip
[r1-Tunnel0/0/0]tunnel-protocol gre p2mp //定义封装方式
[r1-Tunnel0/0/0]source 15.0.0.1 //定义封装的源ip
[r1-Tunnel0/0/0]nhrp network-id 100 //创建NHRP域
[r1-Tunnel0/0/0]nhrp entry 192.168.10.2 45.0.0.1 register
[r1-Tunnel0/0/0]nhrp entry 192.168.10.3 55.0.0.1 register
//都既是中心也是分支,向其他两个中心发送映射信息
[r4]interface Tunnel 0/0/0
[r4-Tunnel0/0/0]ip address 192.168.10.2 24
[r4-Tunnel0/0/0]tunnel-protocol gre p2mp
[r4-Tunnel0/0/0]source 45.0.0.1
[r4-Tunnel0/0/0]nhrp network-id 100
[r4-Tunnel0/0/0]nhrp entry 192.168.10.1 15.0.0.1 register
[r4-Tunnel0/0/0]nhrp entry 192.168.10.3 55.0.0.1 register
[r5]interface Tunnel 0/0/0
[r5-Tunnel0/0/0]ip address 192.168.10.3 24
[r5-Tunnel0/0/0]tunnel-protocol gre p2mp
[r5-Tunnel0/0/0]source 55.0.0.1
[r5-Tunnel0/0/0]nhrp network-id 100
[r5-Tunnel0/0/0]nhrp entry 192.168.10.1 15.0.0.1 register
[r5-Tunnel0/0/0]nhrp entry 192.168.10.2 45.0.0.1 register
检查是否成功
可以看出已经成功、
步骤四:r1、2、3的星型拓扑结构,r1是中心站点
[r1]interface Tunnel 0/0/1 //创建隧道接口
[r1-Tunnel0/0/1]ip address 192.168.20.1 24 //配置隧道接口ip
[r1-Tunnel0/0/1]tunnel-protocol gre p2mp //定义封装方式
[r1-Tunnel0/0/1]source 5.0.0.1 //定义封装的源IP
[r1-Tunnel0/0/1]nhrp network-id 100 //创建NHRP域
[r1-Tunnel0/0/1]nhrp entry multicast dynamic
//MGRE是一种类似NBMA(单播)的环境,这条指令的作用是分支获取路由信息
[r2]interface Tunnel 0/0/1
[r2-Tunnel0/0/1]ip address 192.168.20.2 24
[r2-Tunnel0/0/1]tunnel-protocol gre p2mp
[r2-Tunnel0/0/1]nhrp network-id 100
[r2-Tunnel0/0/1]source GigabitEthernet 0/0/0 //也可以用接口的ip地址25.0.0.1
[r2-Tunnel0/0/1]nhrp entry 192.168.20.1 5.0.0.1 register //向中心发送映射信息
[r3]interface Tunnel 0/0/1
[r3-Tunnel0/0/1]ip address 192.168.20.3 24
[r3-Tunnel0/0/1]tunnel-protocol gre p2mp
[r3-Tunnel0/0/1]source GigabitEthernet 0/0/0
[r3-Tunnel0/0/1]nhrp network-id 100
[r3-Tunnel0/0/1]nhrp entry 192.168.20.1 5.0.0.1 register
验证:使用display nhrp peer all 命令查看隧道接口和物理接口映射关系表
可以发现中心有另外两个的表,分支只有中心的表
步骤五:使用OSPF使得私网通
[r1]ospf 1 router-id 1.1.1.1 //启动ospf进程
[r1-ospf-1]area 0 //创建区域
//宣告;目的:激活接口、发布路由
[r1-ospf-1-area-0.0.0.0]network 192.168.1.0 0.0.0.255
[r1-ospf-1-area-0.0.0.0]network 192.168.10.0 0.0.0.255
[r1-ospf-1-area-0.0.0.0]network 192.168.20.0 0.0.0.255
[r2]ospf 1 router-id 2.2.2.2
[r2-ospf-1]area 0
[r2-ospf-1-area-0.0.0.0]network 192.168.2.0 0.0.0.255
[r2-ospf-1-area-0.0.0.0]network 192.168.20.0 0.0.0.255
[r3]ospf 1 router-id 3.3.3.3
[r3-ospf-1]area 0
[r3-ospf-1-area-0.0.0.0]network 192.168.3.0 0.0.0.255
[r3-ospf-1-area-0.0.0.0]network 192.168.20.0 0.0.0.255
[r4]ospf 1 router-id 4.4.4.4
[r4-ospf-1]area 0
[r4-ospf-1-area-0.0.0.0]network 192.168.4.0 0.0.0.255
[r4-ospf-1-area-0.0.0.0]network 192.168.10.0 0.0.0.255
[r5]ospf 1 router-id 5.5.5.5
[r5-ospf-1]area 0
[r5-ospf-1-area-0.0.0.0]network 192.168.5.0 0.0.0.255
[r5-ospf-1-area-0.0.0.0]network 192.168.10.0 0.0.0.255
注意这个时候r1能ping通的ip很少,因为这是在MGRE环境下接口的工作方式是p2p(点到点)的没有DR/BDR的选举,我们要改变网络类型为breadcast(广播);同时要修改r2与r3的接口优先级设为0让其放弃dr的选举(也可以将r1的优先级设置的特别大)
//改变网络类型
[r1]intface Tunnel 0/0/0
[r1-Tunnel0/0/0]ospf network-type broadcast
[r1]intface Tunnel 0/0/1
[r1-Tunnel0/0/1]ospf network-type broadcast
[r2]intface Tunnel 0/0/1
[r2-Tunnel0/0/1]ospf network-type broadcast
[r3]intface Tunnel 0/0/1
[r3-Tunnel0/0/1]ospf network-type broadcast
[r4]intface Tunnel 0/0/0
[r4-Tunnel0/0/0]ospf network-type broadcast
[r5]intface Tunnel 0/0/0
[r5-Tunnel0/0/0]ospf network-type broadcast
//修改r2和r3的优先级
[r2-Tunnel0/0/1]ospf dr-priority 0
[r3-Tunnel0/0/1]ospf dr-priority 0
验证
至此实验结束