GRE:一种简单的VPN技术 点对点技术
配置过程:
R1:主站点
r1(config)#int s0/0
r1(config-if)#ip add 12.1.1.2 255.255.255.0
r1(config-if)#no shu
r1(config)#int lo 0 创建环回
r1(config-if)#ip add 192.168.1.1 255.255.255.0
r1(config)#int tunnel 0 创建tunnel口
r1(config-if)#ip add 10.1.1.1 255.255.255.0
r1(config-if)#tunnel source 12.1.1.2 tunnel源地址
r1(config-if)#tunnel destination 23.1.1.2 tunnel目的地址
r1(config-if)#router ospf 1 利用ospf宣告IP地址(除公有IP地址)
r1(config-router)#network 10.1.1.0 0.0.0.255 a 0
r1(config-router)#network 192.168.1.0 0.0.0.255 a 0
静态路由:
r1(config)#ip route 192.168.3.0 255.255.255.0 tu 0 静态指向tunnel口
r1(config)#ip route 0.0.0.0 0.0.0.0 12.1.1.1 tunnel的运行首先保证公网能到达
R3:分支站点
R1和R3配置基本一致
r3(config)#int tunnel 0
r3(config-if)#ip address 10.1.1.2 255.255.255.0
r3(config-if)#tunnel source 23.1.1.2
r3(config-if)#tunnel destination 12.1.1.2
MGRE:点对多点技术 和GRE差别不大
R1主站点:
interface Tunnel0
ip address 10.1.1.1 255.255.255.0
ip nhrp map multicast dynamic 定义为主站点,NHRP的server
ip nhrp network-id 100 定义network-id,所有站点必须在一个id里面
ip ospf network point-to-multipoint 将tunnel口的接口改为点到多点
tunnel source Serial0/0
tunnel mode gre multipoint
R3,R4为分支站点:
r4(config-if)#ip add 10.1.1.4 255.255.255.0
r4(config-if)#tunnel source s0/0
r4(config-if)#tunnel mode gre multipoint
r4(config-if)#ip nhrp nhs 10.1.1.1
r4(config-if)#ip nhrp map 10.1.1.1 12.1.1.2 映射出公网地址
r4(config-if)#ip nhrp network-id 100 network-id所有站点均在一个id内
r4(config-if)#ip nhrp map multicast 12.1.1.2 定义流量的目标
r4(config-if)#ip ospf network point-to-multipoint 将接口方式改为点到多点
运行结果:
r1#ping 192.168.5.1 source 192.168.1.1
Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 192.168.5.1, timeout is 2 seconds:
Packet sent with a source address of 192.168.1.1
!!!
Success rate is 100 percent (5/5), round-trip min/avg/max = 31/37/56 ms
r1#
MGRE的优点:分支站点的IP地址可以动态变化,分支站点与分支站点可以互相通讯