配置GRE隧道
程序员文章站
2022-03-10 18:06:38
...
2.1 问题
- 如图配置IPv4和IPv6地址
- R1/R2/R3运行OSPF协议,实现互通
- R1和R3通过回环口建立GRE隧道
- 配置IPv6静态路由,实现PC-1/2互通
2.2 方案
使用eNSP搭建实验环境,如图-2所示。
图-2
2.3 步骤
实现此案例需要按照如下步骤进行。
1)配置IPv4地址和OSPF,实现 R1和R3的回环口互通
<Huawei>undo terminal monitor
<Huawei>system-view
[Huawei]sysname R1
[R1]interface GigabitEthernet 0/0/0
[R1-GigabitEthernet0/0/0]ip address 192.168.12.1 24
[R1-GigabitEthernet0/0/0]quit
[R1]interface LoopBack 0 //创建回环口,用于建立 GRE 隧道
[R1-LoopBack0]ip add 10.10.1.1 32
[R1-LoopBack0]quit
[R1]ospf 1 router-id 1.1.1.1 //启用 OSPF 协议,配置 router-id 为 1.1.1.1
[R1-ospf-1]area 0
[R1-ospf-1-area-0.0.0.0]network 10.10.1.1 0.0.0.0 //回环口必须宣告
[R1-ospf-1-area-0.0.0.0]network 192.168.12.0 0.0.0.255
[R1-ospf-1-area-0.0.0.0]quit
[R1-ospf-1]quit
<Huawei>undo terminal monitor
<Huawei>system-view
[Huawei]sysname R2
[R2]interface GigabitEthernet 0/0/1
[R2-GigabitEthernet0/0/1]ip address 192.168.12.2 24
[R2-GigabitEthernet0/0/1]quit
[R2]interface GigabitEthernet 0/0/0
[R2-GigabitEthernet0/0/0]ip address 192.168.23.2 24
[R2-GigabitEthernet0/0/0]quit
[R2]ospf 1 router-id 2.2.2.2 //启用 OSPF 协议,配置 router-id 为 2.2.2.2
[R2-ospf-1]area 0
[R2-ospf-1-area-0.0.0.0]network 192.168.23.0 0.0.0.255
[R2-ospf-1-area-0.0.0.0]network 192.168.12.0 0.0.0.255
[R2-ospf-1-area-0.0.0.0]quit
[R2-ospf-1]quit
<Huawei>undo terminal monitor
<Huawei>system-view
[Huawei]sysname R3
[R3]interface GigabitEthernet 0/0/1
[R3-GigabitEthernet0/0/1]ip address 192.168.23.3 24
[R3-GigabitEthernet0/0/1]quit
[R3]interface LoopBack 0 //创建回环口,用于建立 GRE 隧道
[R3-LoopBack0]ip address 10.10.3.3 32
[R3-LoopBack0]quit
[R3]ospf 1 router-id 3.3.3.3 //启用 OSPF 协议,配置 router-id 为 3.3.3.3
[R3-ospf-1]area 0
[R3-ospf-1-area-0.0.0.0]network 10.10.3.3 0.0.0.0 //回环口必须宣告
[R3-ospf-1-area-0.0.0.0]network 192.168.23.0 0.0.0.255
[R3-ospf-1-area-0.0.0.0]quit
[R3-ospf-1]quit
2)启用IPv6,创建 GRE隧道,配置IPv6地址
[R1]ipv6 //开启IPv6功能
[R1]interface Tunnel 0/0/13 //建立GRE隧道接口
[R1-Tunnel0/0/13]tunnel-protocol gre //指定隧道协议为GRE
[R1-Tunnel0/0/13]source 10.10.1.1 //指定隧道的源IP地址
[R1-Tunnel0/0/13]destination 10.10.3.3 //指定隧道的目标IP地址
[R1-Tunnel0/0/13]ipv6 enable //为隧道开启IPv6功能
[R1-Tunnel0/0/13]ipv6 address 2001:13::1 64 //为隧道配置IPv6地址
[R1-Tunnel0/0/13]quit
[R3]ipv6 //开启IPv6功能
[R3]interface Tunnel 0/0/13 //建立GRE隧道接口
[R3-Tunnel0/0/13]tunnel-protocol gre //指定隧道协议为GRE
[R3-Tunnel0/0/13]source 10.10.3.3 //指定隧道的源IP地址
[R3-Tunnel0/0/13]destination 10.10.1.1 //指定隧道的目标IP地址
[R3-Tunnel0/0/13]ipv6 enable //为隧道开启IPv6功能
[R3-Tunnel0/0/13]ipv6 address 2001:13::3 64 //为隧道配置IPv6地址
[R3-Tunnel0/0/13]quit
3)配置IPv6静态路由
[R1]interface GigabitEthernet 0/0/2 //连接 PC1 所用的接口
[R1-GigabitEthernet0/0/2]ipv6 enable
[R1-GigabitEthernet0/0/2]ipv6 address 2001:11::254 64
[R1-GigabitEthernet0/0/2]quit
[R1]ipv6 route-static 2001:22:: 64 2001:13::3 //配置去往PC2所在网段的路由
[R3]interface GigabitEthernet 0/0/2 //连接 PC1 所用的接口
[R3-GigabitEthernet0/0/2]ipv6 enable
[R3-GigabitEthernet0/0/2]ipv6 address 2001:22::254 64
[R3-GigabitEthernet0/0/2]quit
[R3]ipv6 route-static 2001:11:: 64 2001:13::1 //配置去往PC1所在网段的路由
4)配置IPv6终端IP地址,测试连通性
PC1:
2001:11::1/64
2001:11::254
PC2:
2001:22::1/64
2001:22::254
PC1>ping 2001:22::1 //PC1 访问 PC2,可以互通
Ping 2001:22::1: 32 data bytes, Press Ctrl_C to break
From 2001:22::1: bytes=32 seq=1 hop limit=253 time=32 ms
From 2001:22::1: bytes=32 seq=2 hop limit=253 time=31 ms
From 2001:22::1: bytes=32 seq=3 hop limit=253 time=31 ms
From 2001:22::1: bytes=32 seq=4 hop limit=253 time=31 ms
From 2001:22::1: bytes=32 seq=5 hop limit=253 time=32 ms
--- 2001:22::1 ping statistics ---
5 packet(s) transmitted
5 packet(s) received
0.00% packet loss
round-trip min/avg/max = 31/31/32 ms
上一篇: 2008十大用户网络应用
下一篇: 路由