拓扑图
思路:
先全网通(先IP后路由,),公网通完才能配置虚拟私网
配ip
配路由,(写下一跳是为了连接的电脑可以连,宣告是为了内部电脑连接外部,可以ping)都是直连,只要缺省
缺省指出,用nat地址转换
开启ospf,邻居关系--邻接关系(R1开启动态组播),但要改ospf的网络类型(tunnel默认的伪广播是P2P),变成boradcast,改了后看ospf peer breif,看DR,直接让R2,R3两个放弃选举
R1
[r1]interface LoopBack 0
[r1-LoopBack0]ip address 192.168.1.1 255.255.255.0
[r1]interface g0/0/0
[r1-GigabitEthernet0/0/0]ip address 16.1.1.1 255.255.255.0
[r1]interface g0/0/1
[r1-GigabitEthernet0/0/1]ip address 16.1.2.1 255.255.255.0
[r1]interface Tunnel 0/0/0 //星型MGRE环境
[r1-Tunnel0/0/0]ip address 192.168.6.1 255.255.255.0
[r1-Tunnel0/0/0]tunnel-protocol gre p2mp
[r1-Tunnel0/0/0]source 16.1.1.1
[r1-Tunnel0/0/0]ospf network-type broadcast //更改tunnel口的链路类型
[r1-Tunnel0/0/0]nhrp entry multicast dynamic
[r1-Tunnel0/0/0]nhrp network-id 100
[r1]interface Tunnel 0/0/1 //全连网状MGRE环境
[r1-Tunnel0/0/1]
[r1-Tunnel0/0/1]ip address 192.168.7.1 255.255.255.0
[r1-Tunnel0/0/1]tunnel-protocol gre p2mp
[r1-Tunnel0/0/1]source 16.1.2.1
[r1-Tunnel0/0/1]ospf network-type broadcast //更改tunnel口的链路类型
[r1-Tunnel0/0/1]ospf dr-priority 2 //更改DR/BDR选举
[r1-Tunnel0/0/1]nhrp entry multicast dynamic
[r1-Tunnel0/0/1]nhrp network-id 200
[r1-Tunnel0/0/1]nhrp entry 192.168.7.2 46.1.1.1 register
[r1-Tunnel0/0/1]nhrp entry 192.168.7.3 56.1.1.1 register
[r1]ospf //宣告两个tunnel口与环回
[r1-ospf-1]area 0
[r1-ospf-1-area-0.0.0.0]network 192.168.1.1 0.0.0.0
[r1-ospf-1-area-0.0.0.0]network 192.168.6.1 0.0.0.0
[r1-ospf-1-area-0.0.0.0]network 192.168.7.1 0.0.0.0
[r1]ip route-static 0.0.0.0 0.0.0.0 16.1.1.2 //缺省路由
[r1]ip route-static 0.0.0.0 0.0.0.0 16.1.2.2R2
[r2]interface LoopBack 0
[r2-LoopBack0]ip address 192.168.2.1 255.255.255.0
[r2]interface g0/0/0
[r2-GigabitEthernet0/0/0]ip address 26.1.1.1 255.255.255.0
[r2]interface Tunnel 0/0/0
[r2-Tunnel0/0/0]ip address 192.168.6.2 255.255.255.0
[r2-Tunnel0/0/0]tunnel-protocol gre p2mp
[r2-Tunnel0/0/0]source GigabitEthernet0/0/0
[r2-Tunnel0/0/0]ospf network-type broadcast
[r2-Tunnel0/0/0]ospf dr-priority 0 //取消OSPF的DR/BDR的选举
[r2-Tunnel0/0/0]nhrp network-id 100
[r2-Tunnel0/0/0]nhrp entry 192.168.6.1 16.1.1.1 register
[r2]ospf
[r2-ospf-1]area 0
[r2-ospf-1-area-0.0.0.0]network 192.168.2.1 0.0.0.0
[r2-ospf-1-area-0.0.0.0]network 192.168.6.2 0.0.0.0
[r2]ip route-static 0.0.0.0 0.0.0.0 26.1.1.2
R3
[r3]interface LoopBack 0
[r3-LoopBack0]ip address 192.168.3.1 255.255.255.0
[r3]interface g0/0/0
[r3-GigabitEthernet0/0/0]ip address 36.1.1.1 255.255.255.0
[r3]interface Tunnel 0/0/0
[r3-Tunnel0/0/0]ip address 192.168.6.3 255.255.255.0
[r3-Tunnel0/0/0]tunnel-protocol gre p2mp
[r3-Tunnel0/0/0]source GigabitEthernet0/0/0
[r3-Tunnel0/0/0]ospf network-type broadcast
[r3-Tunnel0/0/0]ospf dr-priority 0
[r3-Tunnel0/0/0]nhrp network-id 100
[r3-Tunnel0/0/0]nhrp entry 192.168.6.1 16.1.1.1 register
[r3]ospf
[r3-ospf-1]area 0
[r3-ospf-1-area-0.0.0.0] network 192.168.3.1 0.0.0.0
[r3-ospf-1-area-0.0.0.0] network 192.168.6.3 0.0.0.0
[r3]ip route-static 0.0.0.0 0.0.0.0 36.1.1.2
R4
[r4]interface LoopBack 0
[r4-LoopBack0]ip address 192.168.4.1 255.255.255.0
[r4]interface g0/0/0
[r4-GigabitEthernet0/0/0]ip address 46.1.1.1 255.255.255.0
[r4]interface Tunnel 0/0/0
[r4-Tunnel0/0/0]ip address 192.168.7.2 255.255.255.0
[r4-Tunnel0/0/0]tunnel-protocol gre p2mp
[r4-Tunnel0/0/0]source 46.1.1.1
[r4-Tunnel0/0/0]ospf network-type broadcast
[r4-Tunnel0/0/0]ospf dr-priority 2
[r4-Tunnel0/0/0]nhrp entry multicast dynamic
[r4-Tunnel0/0/0]nhrp network-id 200
[r4-Tunnel0/0/0]nhrp entry 192.168.7.1 16.1.2.1 register
[r4-Tunnel0/0/0]nhrp entry 192.168.7.3 56.1.1.1 register
[r4]ospf
[r4-ospf-1]area 0
[r4-ospf-1-area-0.0.0.0]network 192.168.4.1 0.0.0.0
[r4-ospf-1-area-0.0.0.0]network 192.168.7.2 0.0.0.0
[r4]ip route-static 0.0.0.0 0.0.0.0 46.1.1.2R5
[r5]interface LoopBack 0
[r5-LoopBack0]ip address 192.168.5.1 255.255.255.0
[r5]interface g0/0/0
[r5-GigabitEthernet0/0/0]ip address 56.1.1.1 255.255.255.0
[r5]interface Tunnel 0/0/0
[r5-Tunnel0/0/0]ip address 192.168.7.3 255.255.255.0
[r5-Tunnel0/0/0]tunnel-protocol gre p2mp
[r5-Tunnel0/0/0]source 56.1.1.1
[r5-Tunnel0/0/0]ospf network-type broadcast
[r5-Tunnel0/0/0]ospf dr-priority 0
[r5-Tunnel0/0/0]nhrp entry multicast dynamic
[r5]ospf
[r5-ospf-1]area 0
[r5-ospf-1-area-0.0.0.0]network 192.168.5.1 0.0.0.0
[r5-ospf-1-area-0.0.0.0]network 192.168.7.3 0.0.0.0
[r5]ip route-static 0.0.0.0 0.0.0.0 56.1.1.2ISP
[isp]interface LoopBack 0
[isp-LoopBack0]ip address 4.4.4.4 255.255.255.0
[isp]interface g0/0/0
[isp-GigabitEthernet0/0/0]ip address 16.1.1.2 255.255.255.0
[isp]interface g0/0/1
[isp-GigabitEthernet0/0/1]ip address 16.1.2.2 255.255.255.0
[isp]interface g0/0/2
[isp-GigabitEthernet0/0/2]ip address 26.1.1.2 255.255.255.0
[isp]interface g2/0/0
[isp-GigabitEthernet2/0/0]ip address 36.1.1.2 255.255.255.0
[isp]interface g3/0/0
[isp-GigabitEthernet3/0/0]ip address 46.1.1.2 255.255.255.0
[isp]interface g4/0/0
[isp-GigabitEthernet4/0/0]ip address 56.1.1.2 255.255.255.0
结果图