1、注册He.net账号
2、创建1个“常规隧道”
3、从隧道详情扩展标签获取代码
eg:auto he-ipv6
iface he-ipv6 inet6 v4tunnel
address x:x:x:x:x:x:x:x
netmask 64
endpoint 0.0.0.0
local 0.0.0.0
ttl 255
gateway x:x:x:x:x:x:x:x
4、将获取到的代码上位
$ sudo vim /etc/network/interfaces
local 应该是出口网卡获得的IP地址,最好设置成静态IP或者在路由中指定IP。
5、配置防火墙
$ sudo -s
# ip6tables -t nat -A POSTROUTING -o he-ipv6 -s x:x:x::/64 -j MASQUERADE
上段中 x:x:x::/64 应替换为代码中address中的地址去除最后一位
# echo 1 > /proc/sys/net/ipv6/conf/eth1/forwarding
# echo 1 > /proc/sys/net/ipv6/conf/he-ipv6/forwarding
# echo 1 > /proc/sys/net/ipv6/conf/all/forwarding
使用下列命令查看防火墙规则
# ip6tables -t nat -L -n
# ip6tables-save
6、重启网络模块
# /etc/init.d/network restart
7、测试IPv6环境
# ping6 2001:4860:4860::8888
或者
# ping6 google-public-dns-a.google.com
如果是下边显示的话就可以用了
$ ping6 2001:4860:4860::8888
PING 2001:4860:4860::8888(2001:4860:4860::8888) 56 data bytes
64 bytes from 2001:4860:4860::8888: icmp_seq=1 ttl=61 time=259 ms
64 bytes from 2001:4860:4860::8888: icmp_seq=2 ttl=61 time=284 ms
64 bytes from 2001:4860:4860::8888: icmp_seq=3 ttl=61 time=259 ms
64 bytes from 2001:4860:4860::8888: icmp_seq=4 ttl=61 time=259 ms
64 bytes from 2001:4860:4860::8888: icmp_seq=5 ttl=61 time=259 ms
--- 2001:4860:4860::8888 ping statistics ---
5 packets transmitted, 5 received, 0% packet loss, time 4001ms
rtt min/avg/max/mdev = 259.187/264.504/284.424/9.973 ms
----------------------------------------------
以下为ASDL上网方式的设置
1、获取He.net更新URL
例如:
https://User:[email protected]/nic/update?hostname=000000
User是用户名;Key是URL更新密码,可以自行设置,但是不能带特殊符号。
2、为系统设置开机更新和定时更新
开机更新:
$ sudo -s
# vim /etc/rc.local
如下所示:
#!/bin/sh -e
#
# rc.local
#
# This script is executed at the end of each multiuser runlevel.
# Make sure that the script will "exit 0" on success or any other
# value on error.
#
# In order to enable or disable this script just change the execution
# bits.
#
# By default this script does nothing.
# Print the IP address
_IP=$(hostname -I) || true
if [ "$_IP" ]; then
printf "My IP address is %s\n" "$_IP"
fi
exit 0
~
~
~
~
在exit 0前添加之前获取的更新URL
curl https://User:[email protected]/nic/update?hostname=000000
定时更新:
编辑定时策略
# vim /etc/crontab
# /etc/crontab: system-wide crontab
# Unlike any other crontab you don't have to run the `crontab'
# command to install the new version when you edit this file
# and files in /etc/cron.d. These files also have username fields,
# that none of the other crontabs do.
SHELL=/bin/sh
PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
# m h dom mon dow user command
17 * * * * root cd / && run-parts --report /etc/cron.hourly
25 6 * * * root test -x /usr/sbin/anacron || ( cd / && run-parts --report /etc/cron.daily )
47 6 * * 7 root test -x /usr/sbin/anacron || ( cd / && run-parts --report /etc/cron.weekly )
52 6 1 * * root test -x /usr/sbin/anacron || ( cd / && run-parts --report /etc/cron.monthly )
~
~
~
在最后一行添加如下内容
*/30 0 * * * root curl https://User:[email protected]/nic/update?hostname=000000
此条内容代表每30分钟执行1次,如要更改请自行搜索crontab定时运行方法。