先配置他们的IP地址然后配置他们的环回:
R1:
[R1]interface GigabitEthernet 0/0/0
[R1-GigabitEthernet0/0/0]ip address 12.0.0.1 24
[R1]interface LoopBack 0
[R1-LoopBack0]ip address 192.168.1.1 24
R2:
[R2]interface GigabitEthernet 0/0/0
[R2-GigabitEthernet0/0/0]ip address 192.168.1.2 24
[R2]interface GigabitEthernet 0/0/1
[R2-GigabitEthernet0/0/1]ip address 23.0.0.1 24
R3:
[R3]interface GigabitEthernet 0/0/0
[R3-GigabitEthernet0/0/0]ip address 23.0.0.2 24
[R3]interface LoopBack 0
[R3-LoopBack0]ip address 192.168.2.1 24
我们希望数据从源IP,192.168.1.1发送到目的IP,192.168.2.1。但是路由器的真实走向却是从源IP,12.0.0.1发送数据到目的IP23.0.0.3。然后要想改变这样子的传输方式,可以通过利用GRE技术,构建隧道,然后进行在公网上建立一条数据通道然后传输。
通过GRE构建一条虚拟链路:
R1:
[R1]interface Tunnel 0/0/0
[R1-Tunnel0/0/0]ip address 192.168.3.1 24
[R1-Tunnel0/0/0]tunnel-protocol gre
[R1-Tunnel0/0/0]source 12.0.0.1
[R1-Tunnel0/0/0]description 23.0.0.3
[R1]ip route-static 192.168.2.0 24 192.168.3.2
R3:
[R3]interface Tunnel 0/0/0
[R3-Tunnel0/0/0]ip address 192.168.3.2 24
[R3-Tunnel0/0/0]tunnel-protocol gre
[R3-Tunnel0/0/0]source 23.0.0.2
[R3-Tunnel0/0/0]description 12.0.0.1
[R3]ip route-static 192.168.1.0 24 192.168.3.1
配置:
GRE两端配置完成后,必须存在指向隧道的路由信息,否则数据无法被GRE进行封装,也就无法正常 通讯。