VMware实现一台电脑中的网络( 四 )


You can get a public key"s fingerprint by running
% ssh-keygen -F publickey.pub
on the keyfile.
Are you sure you want to continue connecting (yes/no)?

5) ipv6-in-ipv4 tunnel测试

由于ipv4在网络中已经实现了多年,而且Internet的发展更加促使ipv4的发展,目前ipv6在网络中的实际情况是ipv6象一个孤岛被ipv4的海洋包围,各个ipv6网络的连接还需要通过ipv4网络,实际中比较常见的有ipv6-in-ipv4隧道等 。这里利用本虚拟环境进行点对点的IPv6-in-IPv4 tunnel的实验(R1-R2) 。

在R1机器上面:

ip -6 addr add 3ffe:3200::1/24 dev eth0#给eth0设定一个本地ipv6地址,以CERNET的测试ipv6地址为例
ip tunnel add 6to4 mode sit remote 192.168.8.12 local 192.168.8.11 #加入一个6to4通道
ip link set dev 6to4 up#激活6to4通道
ip -6 addr add 3ffe:3200::1/24 dev 6to4#给通道加入本地ipv6地址
ip -6 r add 3ffe:3200::2/24 dev 6to4#加入使用通道设备的ipv6路由,由于使用的点对点的测试,目的网络是对端的ipv6地址

在R2机器上面:

ip -6 addr add 3ffe:3200::2/24 dev eth0
ip tunnel add 6to4 mode sit remote 192.168.8.11 local 192.168.8.12
ip link set dev 6to4 up
ip -6 addr add 3ffe:3200::2/24 dev 6to4
ip -6 r add 3ffe:3200::1/24 dev 6to4

也可以加入R3,R4,R5的ipv6 tunnel,以供更加复杂的测试 。


在R1和R2设备上面,使用ping6命令查看对端的ipv6地址可以到达;

在R1和R2设备上面,使用ssh -6 ipv6地址通过ipv6 tunnel登录点对点连接的其他ipv6设备;

R1:~# ssh -6 3ffe:3200::2
Host key not found from database.
Key fingerprint:
xobit-pihuz-gypek-lokad-leliz-hupim-pavek-pyvem-canam-nefaf-laxax
You can get a public key"s fingerprint by running
% ssh-keygen -F publickey.pub
on the keyfile.
Are you sure you want to continue connecting (yes/no)? yes
Host key saved to /root/.ssh2/hostkeys/key_22_3ffe:3200::1.pub
host key for 3ffe:3200::1, accepted by root Wed Mar 31 2004 19:12:510800
root"s password:
Authentication successful.
R2:~# w
08:16:21 up3:02,3 users,load average: 0.00, 0.01, 0.00
USERTTYFROMLOGIN@IDLEJCPUPCPUWHAT
rootpts/73ffe:3200::1108:160.00s0.13s0.04sw
R2:~#

Ok,我们已经通过ipv6-in-ipv4的tunnel看到我们使用ipv6地址登录到另外的设备上面了!

此过程在R2上面的tcpdump结果:

08:23:35.833428 3ffe:3200::2.1047 > 3ffe:3200::1.ssh: S 2462930696:2462930696(0) win 5760
08:23:35.835364 192.168.8.12 > 192.168.8.11: 3ffe:3200::1.ssh > 3ffe:3200::2.1047: S 1730732585:1730732585(0) ack 2462930697 win 5632 (encap)
08:23:35.860756 3ffe:3200::2.1047 > 3ffe:3200::1.ssh: . ack 1 win 5760
08:23:35.919035 192.168.8.12 > 192.168.8.11: 3ffe:3200::1.ssh > 3ffe:3200::2.1047: P 1:50(49) ack 1 win 5632 (encap)
08:23:35.925164 3ffe:3200::2.1047 > 3ffe:3200::1.ssh: . ack 50 win 5760
08:23:35.925193 3ffe:3200::2.1047 > 3ffe:3200::1.ssh: P 1:50(49) ack 50 win 5760
08:23:35.926647 192.168.8.12 > 192.168.8.11: 3ffe:3200::1.ssh > 3ffe:3200::2.1047: . ack 50 win 5632 (encap)
08:23:35.936087 192.168.8.12 > 192.168.8.11: 3ffe:3200::1.ssh > 3ffe:3200::2.1047: P 50:538(488) ack 50 win 5632 (encap)
08:23:35.954300 3ffe:3200::2.1047 > 3ffe:3200::1.ssh: P 50:546(496) ack 538 win 6432
08:23:35.994265 192.168.8.12 > 192.168.8.11: 3ffe:3200::1.ssh > 3ffe:3200::2.1047: . ack 546 win 6432 (encap)
08:23:35.995267 3ffe:3200::2.1047 > 3ffe:3200::1.ssh: P 546:706(160) ack 538 win 6432
08:23:35.995479 192.168.8.12 > 192.168.8.11: 3ffe:3200::1.ssh > 3ffe:3200::2.1047: . ack 706 win 6432 (encap)
08:23:36.117795 192.168.8.12 > 192.168.8.11: 3ffe:3200::1.ssh > 3ffe:3200::2.1047: P 538:1578(1040) ack 706 win 6432 (encap)
08:23:36.127435 3ffe:3200::2.1047 > 3ffe:3200::1.ssh: . ack 1578 win 8320
08:23:36.127761 192.168.8.12 > 192.168.8.11: 3ffe:3200::1.ssh > 3ffe:3200::2.1047: P 1578:1610(32) ack 706 win 6432 (encap)

推荐阅读