配置IPv4 over IPv6隧道示例
本举例介绍IPv4 over IPv6隧道的配置过程。
组网需求
如图4-3所示,两个IPv4网络分别通过DeviceA和DeviceB与IPv6网络连接,要求在DeviceA和DeviceB之间配置IPv4 over IPv6隧道,以便两个IPv4网络内的主机可以互通。
操作步骤
- 配置接口的IPv6地址
# 配置DeviceA。
<HUAWEI> system-view [~HUAWEI] sysname DeviceA [*HUAWEI] commit [~DeviceA] interface gigabitethernet 0/1/0 [~DeviceA-GigabitEthernet0/1/0] ipv6 enable [*DeviceA-GigabitEthernet0/1/0] ipv6 address 2001:db8:100::1 64 [*DeviceA-GigabitEthernet0/1/0] undo shutdown [*DeviceA-GigabitEthernet0/1/0] commit [~DeviceA-GigabitEthernet0/1/0] quit
# 配置DeviceB。
<HUAWEI> system-view [~HUAWEI] sysname DeviceB [*HUAWEI] commit [~DeviceB] interface gigabitethernet 0/1/0 [~DeviceB-GigabitEthernet0/1/0] ipv6 enable [*DeviceB-GigabitEthernet0/1/0] ipv6 address 2001:db8:100::2 64 [*DeviceB-GigabitEthernet0/1/0] undo shutdown [*DeviceB-GigabitEthernet0/1/0] commit [~DeviceB-GigabitEthernet0/1/0] quit
- 配置接口的IPv4地址
# 配置DeviceA。
[~DeviceA] interface gigabitethernet 0/1/1 [~DeviceA-GigabitEthernet0/1/1] ip address 10.1.1.2 255.255.255.0 [*DeviceA-GigabitEthernet0/1/1] undo shutdown [*DeviceA-GigabitEthernet0/1/1] commit [~DeviceA-GigabitEthernet0/1/1] quit
# 配置DeviceB。
[~DeviceB] interface gigabitethernet 0/1/1 [~DeviceB-GigabitEthernet0/1/1] ip address 176.16.1.2 255.255.255.0 [*DeviceB-GigabitEthernet0/1/1] undo shutdown [*DeviceB-GigabitEthernet0/1/1] commit [~DeviceB-GigabitEthernet0/1/1] quit
- 配置Loopback接口
# 配置DeviceA。
[~DeviceA] interface LoopBack 1 [~DeviceA-LoopBack1] ipv6 enable [*DeviceA-LoopBack1] ipv6 address 2001:db8:200::1 64 [*DeviceA-LoopBack1] binding tunnel ipv4-ipv6 [*DeviceA-LoopBack1] commit
# 配置DeviceB。
[~DeviceB] interface LoopBack 1 [~DeviceB-LoopBack1] ipv6 enable [*DeviceB-LoopBack1] ipv6 address 2001:db8:300::2 64 [*DeviceB-LoopBack1] binding tunnel ipv4-ipv6 [*DeviceB-LoopBack1] commit
- 配置隧道的接口IP地址、源接口、目的地址
# 配置DeviceA。
[~DeviceA] interface tunnel 1 [~DeviceA-Tunnel1] tunnel-protocol ipv4-ipv6 [~DeviceA-Tunnel1] ip address 192.168.1.1 255.255.255.0 [*DeviceA-Tunnel1] source LoopBack 1 [*DeviceA-Tunnel1] destination 2001:db8:300::2 [*DeviceA-Tunnel1] commit [~DeviceA-Tunnel1] quit
# 配置DeviceB。
[~DeviceB] interface tunnel 1 [~DeviceB-Tunnel1] tunnel-protocol ipv4-ipv6 [~DeviceB-Tunnel1] ip address 192.168.1.2 255.255.255.0 [*DeviceB-Tunnel1] source LoopBack 1 [*DeviceB-Tunnel1] destination 2001:db8:200::1 [*DeviceB-Tunnel1] commit [~DeviceB-Tunnel1] quit
- 配置经过该隧道接口转发的路由
# 配置DeviceA。
[~DeviceA] ipv6 route-static 2001:db8:300::2 64 gigabitethernet 0/1/0 2001:db8:100::2 [*DeviceA] commit [~DeviceA] ospf 1 [*DeviceA-ospf-1] area 0 [*DeviceA-ospf-1-area-0.0.0.0] network 192.168.1.0 0.0.0.255 [*DeviceA-ospf-1-area-0.0.0.0] network 10.1.1.0 0.0.0.255 [*DeviceA-ospf-1-area-0.0.0.0] commit
# 配置DeviceB。
[~DeviceB] ipv6 route-static 2001:db8:200::1 64 gigabitethernet 0/1/0 2001:db8:100::1 [*DeviceB] commit [~DeviceB] ospf 1 [*DeviceB-ospf-1] area 0 [*DeviceB-ospf-1-area-0.0.0.0] network 192.168.1.0 0.0.0.255 [*DeviceB-ospf-1-area-0.0.0.0] network 176.16.1.0 0.0.0.255 [*DeviceB-ospf-1-area-0.0.0.0] commit
- 配置PC地址
# 配置PC1。
配置PC1地址为10.1.1.1/24,与DeviceA的接口GE0/1/1同一网段。IP地址的配置方法与PC1的操作系统有关,配置方法略。
# 配置PC2。
配置PC2地址为176.16.1.1/24,与DeviceB的接口GE0/1/1同一网段。IP地址的配置方法与PC2的操作系统有关,配置方法略。
- 检查配置结果
# 在DeviceA上执行Ping命令,检查DeviceB的Tunnel1接口的IPv4地址是否可达。
[~DeviceA] ping 192.168.1.2 PING 192.168.1.2: 56 data bytes, press CTRL_C to break Reply from 192.168.1.2: bytes=56 Sequence=1 ttl=255 time=108 ms Reply from 192.168.1.2: bytes=56 Sequence=2 ttl=255 time=2 ms Reply from 192.168.1.2: bytes=56 Sequence=3 ttl=255 time=3 ms Reply from 192.168.1.2: bytes=56 Sequence=4 ttl=255 time=3 ms Reply from 192.168.1.2: bytes=56 Sequence=5 ttl=255 time=2 ms --- 192.168.1.2 ping statistics --- 5 packet(s) transmitted 5 packet(s) received 0.00% packet loss round-trip min/avg/max = 2/23/108 ms
# 在PC1上Ping向PC2的IP地址,可以互通。
C:\> ping 172.16.1.1 Pinging 172.16.1.1 with 32 bytes of data: Reply from 172.16.1.1: time<1ms Reply from 172.16.1.1: time<1ms Reply from 172.16.1.1: time<1ms Reply from 172.16.1.1: time<1ms Ping statistics for 172.16.1.1: Packets: Sent = 4, Received = 4, Lost = 0 (0% loss), Approximate round trip times in milli-seconds: Minimum = 0ms, Maximum = 0ms, Average = 0ms
配置文件
DeviceA的配置文件
# sysname DeviceA # interface GigabitEthernet0/1/0 undo shutdown ipv6 enable ipv6 address 2001:DB8:100::1/64 # interface GigabitEthernet0/1/1 undo shutdown ip address 10.1.1.2 255.255.255.0 # interface LoopBack1 ipv6 enable ipv6 address 2001:DB8:200::1/64 binding tunnel ipv4-ipv6 # interface Tunnel1 ip address 192.168.1.1 255.255.255.0 tunnel-protocol ipv4-ipv6 source LoopBack1 destination 2001:DB8:300::2 # ospf 1 area 0.0.0.0 network 192.168.1.0 0.0.0.255 network 10.1.1.0 0.0.0.255 # ipv6 route-static 2001:DB8:300:: 64 GigabitEthernet0/1/0 2001:DB8:100::2 # return
DeviceB的配置文件
# sysname DeviceB # interface GigabitEthernet0/1/0 undo shutdown ipv6 enable ipv6 address 2001:DB8:100::2/64 # interface GigabitEthernet0/1/1 undo shutdown ip address 172.16.1.2 255.255.255.0 # interface LoopBack1 ipv6 enable ipv6 address 2001:DB8:300::2/64 binding tunnel ipv4-ipv6 # interface Tunnel1 ip address 192.168.1.2 255.255.255.0 tunnel-protocol ipv4-ipv6 source LoopBack1 destination 2001:DB8:200::1 # ospf 1 area 0.0.0.0 network 192.168.1.0 0.0.0.255 network 172.16.1.0 0.0.0.255 # ipv6 route-static 2001:DB8:200:: 64 GigabitEthernet0/1/0 2001:DB8:100::1 # return