Linux中ADSL通过6to4自动穿隧连入IPv6
前两天捣鼓了一个USB ADSL在VMWare虚拟机中Linux系统中的安装配置和拨号方法。目前青岛网通这里,如果是在Windows环境下,拨号后能够自动获取6to4自动穿隧方式的2002开头的IPv6地址,Linux下的获取需要手动配置一下,并不是很复杂。
如果是Windows系统,那么通过ipconfig可以得到类似如下的信息。
C:\Documents and Settings\Administrator>ipconfig Windows IP Configuration PPP adapter AccessRunner DSL: Connection-specific DNS Suffix . : IP Address. . . . . . . . . . . . : 123.235.169.32 Subnet Mask . . . . . . . . . . . : 255.255.255.255 Default Gateway . . . . . . . . . : 123.235.169.32 Tunnel adapter 6to4 Tunneling Pseudo-Interface: Connection-specific DNS Suffix . : IP Address. . . . . . . . . . . . : 2002:7beb:a920::7beb:a920 Default Gateway . . . . . . . . . : 2002:c058:6301::c058:6301
其中IPv6地址中的7beb:a920正好对应动态IPv4的地址123.235.169.32,而IPv6网关地址中的c058:6301对应的是不变的192.88.99.1,这个192.88.99.1是一个特定的6to4中用于任意点传送的中继路由地址。需要做的就是记好这几个地址的规律。
然后换到Linux中,配置好ADSL,拨号后连入IPv4网,ifconfig查询到新获得的动态IPv4地址,然后按照上面的规律自行将其转换到6to4方式下2002开头的IPv6地址。例如现在得到的是124.135.17.179,对应的6to4地址为2002:7c87:11b3::7c87:11b3。下面将手动添加6to4隧道和中继路由。
[root@leon ~]# ip tunnel add 6to4 mode sit remote any local 124.135.17.179 [root@leon ~]# ip link set dev 6to4 up [root@leon ~]# ip addr add 2002:7c87:11b3::7c87:11b3/16 dev 6to4 [root@leon ~]# ip -6 route add ::/0 via ::192.88.99.1 dev 6to4 metric 1026
添加完后通过ifconfig可以看到新多出的网卡6to4,同时ping6一下ipv6.google.com已经可以正常的显示结果。
[root@leon ~]# ifconfig 6to4 Link encap:IPv6-in-IPv4 inet6 addr: 2002:7c87:11b3::7c87:11b3/16 Scope:Global inet6 addr: ::124.135.17.179/128 Scope:Compat UP RUNNING NOARP MTU:1480 Metric:1 RX packets:0 errors:0 dropped:0 overruns:0 frame:0 TX packets:0 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:0 RX bytes:0 (0.0 b) TX bytes:0 (0.0 b) lo Link encap:Local Loopback inet addr:127.0.0.1 Mask:255.0.0.0 inet6 addr: ::1/128 Scope:Host UP LOOPBACK RUNNING MTU:16436 Metric:1 RX packets:8 errors:0 dropped:0 overruns:0 frame:0 TX packets:8 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:0 RX bytes:560 (560.0 b) TX bytes:560 (560.0 b) nas0 Link encap:Ethernet HWaddr 00:08:5C:14:C0:FB inet6 addr: fe80::208:5cff:fe14:c0fb/64 Scope:Link UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1 RX packets:275 errors:0 dropped:0 overruns:0 frame:0 TX packets:281 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:1000 RX bytes:23972 (23.4 KiB) TX bytes:19561 (19.1 KiB) ppp0 Link encap:Point-to-Point Protocol inet addr:124.135.17.179 P-t-P:124.135.17.1 Mask:255.255.255.255 UP POINTOPOINT RUNNING NOARP MULTICAST MTU:1492 Metric:1 RX packets:236 errors:0 dropped:0 overruns:0 frame:0 TX packets:236 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:3 RX bytes:20202 (19.7 KiB) TX bytes:9883 (9.6 KiB)
[root@leon ~]# ping6 -c 4 ipv6.google.com PING ipv6.google.com(tx-in-x68.google.com) 56 data bytes 64 bytes from tx-in-x68.google.com: icmp_seq=1 ttl=58 time=384 ms 64 bytes from tx-in-x68.google.com: icmp_seq=2 ttl=58 time=385 ms 64 bytes from tx-in-x68.google.com: icmp_seq=3 ttl=58 time=387 ms 64 bytes from tx-in-x68.google.com: icmp_seq=4 ttl=58 time=390 ms --- ipv6.google.com ping statistics --- 4 packets transmitted, 4 received, 0% packet loss, time 3396ms rtt min/avg/max/mdev = 384.629/386.821/390.147/2.146 ms
总结配置过程,首先观察windows下6to4方式IPv4地址与IPv6地址的对应关系及其中继路由地址,然后在Linux中添加隧道,设置6to4网卡,添加IPv6地址和中继路由,最后测试成功。
延伸阅读:http://en.wikipedia.org/wiki/6to4,http://en.wikipedia.org/wiki/IPv6
包子研究生是什么方向啊
基本做不了底层了,大概是一些终端应用层的东西