Advertisement

H3C GRE VPN基本配置实验

阅读量:

H3C GRE VPN基本配置实验

实验拓扑

image

实验需求

根据图示信息进行IP地址配置。
在R1和R3设备上设置默认路由以实现公网间的互通连接。
在R1和R3设备上部署GRE隧道协议,在此过程中允许两端私网之间的数据互通,并将Tunnel端口的IP地址信息参考附图。
在R1与R3设备间设置动态路由协议以实现本地网络之间的通信连接。

实验步骤

按照图示配置 IP 地址

复制代码
    [R1]display ip interface brief 
    *down: administratively down
    (s): spoofing  (l): loopback
    Interface           Physical Protocol IP address/Mask    VPN instance Description  
    GE0/0               up       up       100.1.1.1/24       --           --
    GE0/1               up       up       192.168.1.254/24   --           --
    
    [R2]display ip interface brief 
    *down: administratively down
    (s): spoofing  (l): loopback
    Interface           Physical Protocol IP address/Mask    VPN instance Description  
    GE0/0               up       up       100.1.1.2/24       --           --
    GE0/1               up       up       100.2.2.2/24       --           --
    
    [R3]display ip interface brief 
    *down: administratively down
    (s): spoofing  (l): loopback
    Interface           Physical Protocol IP address/Mask    VPN instance Description  
    GE0/0               up       up       100.2.2.3/24       --           --
    GE0/1               up       up       192.168.2.254/24   --           --
    
    
    AI生成项目shelll
![](https://ad.itadn.com/c/weblog/blog-img/images/2025-07-13/1GrzYsymU0kMAJbBnNZPTRlftpqv.png)

image

image

在 R1 和 R3 上配置默认路由使公网区域互通

复制代码
    [R1]ip route-static 0.0.0.0 0 100.1.1.2
    
    [R3]ip route-static 0.0.0.0 0 100.2.2.2
    
    
    AI生成项目shelll

在 R1 和 R3 上配置 GRE VPN,使两端私网能够互相访问

在R1设备上配置隧道接口,并设置其传输模式为GRE;源地址和目的地址分别设置为本端公网IP地址及对端公网IP地址。

复制代码
    [R1]interface Tunnel 0 mode gre 	//创建Tunnel口,模式为GRE
    [R1-Tunnel0]ip address 192.168.3.1 255.255.255.0	//配置Tunnel0口IP地址
    [R1-Tunnel0]source 100.1.1.1	//源地址为本端公网地址
    [R1-Tunnel0]destination 100.2.2.3	//目的地址为对端公网地址
    
    %Aug  1 09:46:31:195 2024 R1 IFNET/3/PHY_UPDOWN: Physical state on the interface Tunnel0 changed to up.
    %Aug  1 09:46:31:195 2024 R1 IFNET/5/LINK_UPDOWN: Line protocol state on the interface Tunnel0 changed to up.
    
    
    AI生成项目shelll

配置在R3上设置隧道接口,并将其连接模式设置为GRE;该接口的源端口与目的端口应分别连接到本地网络的公用地址与远端设备的公用地址

复制代码
    [R3]interface Tunnel 0 mode gre 	//创建Tunnel口,模式为GRE
    [R3-Tunnel0]ip address 192.168.3.3 255.255.255.0	//配置Tunnel0口IP地址
    [R3-Tunnel0]source 100.2.2.3	//源地址为本端公网地址
    [R3-Tunnel0]destination 100.1.1.1	//目的地址为对端公网地址
    
    %Aug  1 09:54:11:176 2024 R3 IFNET/3/PHY_UPDOWN: Physical state on the interface Tunnel0 changed to up.
    %Aug  1 09:54:11:176 2024 R3 IFNET/5/LINK_UPDOWN: Line protocol state on the interface Tunnel0 changed to up.
    
    
    AI生成项目shelll
在 R1 和 R3 上配置OSPF协议来传递两端私网路由

R1 和 R3 使用 RIP 方法来传递私有网络的路由信息。然而,在这种情况下(即当私网报文需通过 VPN 隧道传输时),必须将 Tunnel 接口加入到 RIP 的配置中,并依靠该接口来完成路由的传递。

在 R1 上配置OSPF,宣告业务网段和 Tunnel 口网段
复制代码
    [R1]ospf 1
    [R1-ospf-1]area 0.0.0.0
    [R1-ospf-1-area-0.0.0.0]network 192.168.3.0 0.0.0.255
    [R1-ospf-1-area-0.0.0.0]network 192.168.1.0 0.0.0.255
    
    
    AI生成项目
在 R3 上配置OSPF,宣告业务网段和 Tunnel 口网段
复制代码
    [R3]ospf 1
    [R3-ospf-1]area 0.0.0.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.2.0 0.0.0.255
    
    
    AI生成项目

实验验证

检查R1与R3之间的OSPF邻居连接状态,并确认其均为FULL状态;随后通过Tunnel0接口进行连接

复制代码
    [R1]display ospf peer 
    
    	 OSPF Process 1 with Router ID 192.168.3.1
               Neighbor Brief Information
    
     Area: 0.0.0.0    
     Router ID       Address         Pri Dead-Time  State             Interface
     192.168.3.3     192.168.3.3     1   38         Full/ -           Tun0
    
    [R3]display ospf peer 
    
    	 OSPF Process 1 with Router ID 192.168.3.3
               Neighbor Brief Information
    
     Area: 0.0.0.0    
     Router ID       Address         Pri Dead-Time  State             Interface
     192.168.3.1     192.168.3.1     1   39         Full/ -           Tun0
    
    
    AI生成项目shelll
![](https://ad.itadn.com/c/weblog/blog-img/images/2025-07-13/pZtuR9HGYKMPzBVlLjWeS70y2Cki.png)

查看R1和R3的IP路由表,双方的私网网段路由下一跳皆为Tunnel0接口

复制代码
    [R1]display ip routing-table
    Destinations : 18	Routes : 18
    Destination/Mask   Proto   Pre Cost        NextHop         Interface
    0.0.0.0/0          Static  60  0           100.1.1.2       GE0/0
    0.0.0.0/32         Direct  0   0           127.0.0.1       InLoop0
    100.1.1.0/24       Direct  0   0           100.1.1.1       GE0/0
    100.1.1.1/32       Direct  0   0           127.0.0.1       InLoop0
    100.1.1.255/32     Direct  0   0           100.1.1.1       GE0/0
    127.0.0.0/8        Direct  0   0           127.0.0.1       InLoop0
    127.0.0.1/32       Direct  0   0           127.0.0.1       InLoop0
    127.255.255.255/32 Direct  0   0           127.0.0.1       InLoop0
    192.168.1.0/24     Direct  0   0           192.168.1.254   GE0/1
    192.168.1.254/32   Direct  0   0           127.0.0.1       InLoop0
    192.168.1.255/32   Direct  0   0           192.168.1.254   GE0/1
    192.168.2.0/24     O\_INTRA 10  1563        192.168.3.3     Tun0
    192.168.3.0/24     Direct  0   0           192.168.3.1     Tun0
    192.168.3.1/32     Direct  0   0           127.0.0.1       InLoop0
    192.168.3.255/32   Direct  0   0           192.168.3.1     Tun0
    224.0.0.0/4        Direct  0   0           0.0.0.0         NULL0
    224.0.0.0/24       Direct  0   0           0.0.0.0         NULL0
    255.255.255.255/32 Direct  0   0           127.0.0.1       InLoop0
    
    
    [R3]display ip routing-table 
    
    Destinations : 18	Routes : 18
    
    Destination/Mask   Proto   Pre Cost        NextHop         Interface
    0.0.0.0/0          Static  60  0           100.2.2.2       GE0/0
    0.0.0.0/32         Direct  0   0           127.0.0.1       InLoop0
    100.2.2.0/24       Direct  0   0           100.2.2.3       GE0/0
    100.2.2.3/32       Direct  0   0           127.0.0.1       InLoop0
    100.2.2.255/32     Direct  0   0           100.2.2.3       GE0/0
    127.0.0.0/8        Direct  0   0           127.0.0.1       InLoop0
    127.0.0.1/32       Direct  0   0           127.0.0.1       InLoop0
    127.255.255.255/32 Direct  0   0           127.0.0.1       InLoop0
    192.168.1.0/24     O_INTRA 10  1563        192.168.3.1     Tun0
    192.168.2.0/24     Direct  0   0           192.168.2.254   GE0/1
    192.168.2.254/32   Direct  0   0           127.0.0.1       InLoop0
    192.168.2.255/32   Direct  0   0           192.168.2.254   GE0/1
    192.168.3.0/24     Direct  0   0           192.168.3.3     Tun0
    192.168.3.3/32     Direct  0   0           127.0.0.1       InLoop0
    192.168.3.255/32   Direct  0   0           192.168.3.3     Tun0
    224.0.0.0/4        Direct  0   0           0.0.0.0         NULL0
    224.0.0.0/24       Direct  0   0           0.0.0.0         NULL0
    255.255.255.255/32 Direct  0   0           127.0.0.1       InLoop0
    
    
    AI生成项目shelll
![](https://ad.itadn.com/c/weblog/blog-img/images/2025-07-13/LFr5KE0kNBoPVlSJtcmw6i2pg1Cs.png)

效果测试:在 PC1 上 Ping PC2,可以 Ping 通

复制代码
    <H3C>ping 192.168.2.1
    Ping 192.168.2.1 (192.168.2.1): 56 data bytes, press CTRL_C to break
    56 bytes from 192.168.2.1: icmp_seq=0 ttl=253 time=2.303 ms
    56 bytes from 192.168.2.1: icmp_seq=1 ttl=253 time=2.750 ms
    56 bytes from 192.168.2.1: icmp_seq=2 ttl=253 time=2.742 ms
    56 bytes from 192.168.2.1: icmp_seq=3 ttl=253 time=1.045 ms
    56 bytes from 192.168.2.1: icmp_seq=4 ttl=253 time=1.954 ms
    
    --- Ping statistics for 192.168.2.1 ---
    5 packet(s) transmitted, 5 packet(s) received, 0.0% packet loss
    round-trip min/avg/max/std-dev = 1.045/2.159/2.750/0.631 ms
    <H3C>%Aug  1 10:24:14:215 2024 H3C PING/6/PING_STATISTICS: Ping statistics for 192.168.2.1: 5 packet(s) transmitted, 5 packet(s) received, 0.0% packet loss, round-trip min/avg/max/std-dev = 1.045/2.159/2.750/0.631 ms.
    
    
    AI生成项目
![](https://ad.itadn.com/c/weblog/blog-img/images/2025-07-13/KiSFqGzkjpdRa28ocHVYBTZ79Wug.png)

实验附件

该文件由百度网盘分享提供:H3C GRE VPN基本配置实验.zip 获取链接:https://pan.baidu.com/s/1ro9FRmPqMO3_XfnlWOhvSg?pwd=8ee7

全部评论 (0)

还没有任何评论哟~