IPv6 DDNS(DNSPod.Python)

期末了,想在OpenWrt上搭个DDNS,好回家了登录上来拿个文档什么的,且正好在用DNSPod,API丰富。但在校园网的环境下,路由WAN口是教育网的IP,电信IPv4出口没有网关的权限,只有IPv6是公网的IP。找来找去,说可以用ssh反向隧道,可是没外网的主机。于是想开放个ssh的22端口,用IPv6来访问。

——————2014.7.24 update——————

如果两边的权限都不够,还可以试试N2N VPN或这个。

————————————————————

——————2015.1.24 update——————

发现用了6relayd以后LuCI里Wifi配置改不了…

校园网升级后MentoHUST需要加个版本号参数:mentohust -uxxx -pxxx -neth0.2 -d3 -b1 -v3.95

————————————————————

But……搜来搜去只找到IPv4的DDNS。囧,好在之前学了点Python。分析了一下源代码,看一看API说明,挽起袖子,束起头发,撸了起来。

以下是成果(python & python-openssl needed):

#!/usr/bin/env python#-*- coding:utf-8 -*-import httplib, urllib, urllib2import timeparams = dict(??? login_email=”xxx”, # replace with your email??? login_password=”xxx”, # replace with your password??? format=”json”,??? domain_id=100, # replace with your domain_od, can get it by API Domain.List??? record_id=100, # replace with your record_id, can get it by API Record.List??? sub_domain=”www”, # replace with your sub_domain??? record_type=”AAAA”,??? record_line=”默认”,)current_ip = Nonedef ddns(ip):??? params.update(dict(value=ip))??? headers = {“Content-type”: “application/x-www-form-urlencoded”, “Accept”: “text/json”}??? conn = httplib.HTTPSConnection(“dnsapi.cn”)??? conn.request(“POST”, “/Record.Modify”, urllib.urlencode(params), headers)?? ???? response = conn.getresponse()??? print response.status, response.reason??? data = response.read()??? print data??? conn.close()??? return response.status == 200def getip():??? ret = urllib2.urlopen(‘http://www.org.ht/ip.php’)??? ipv6 = ret.read()??? ret.close()??? return ipv6if __name__ == ‘__main__’:??? while True:??????? try:??????????? ip = getip()??????????? print ip??????????? if current_ip != ip:??????????????? if ddns(ip):??????????????????? current_ip = ip??????? except Exception, e:??????????? print e??????????? pass??????? time.sleep(300)

——————2014.7.12 update——————

成功登录。使用6in4隧道,按照wiki来的。

# opkg install 6in4 luci-proto-6×4 ip6tables kmod-ip6tables radvd

需要注意的是家里的环境也是内网。所幸的是有权限,能登录上路由。本地IP填内网的IP,再把IP加到DMZ就好了。

————————————————————

——————2014.7.18 update——————

使用动态6in4隧道需要注意官网的公告(账号密码不是登录时的账号密码):

Authentication updates[January 31, 2014] In order to improve account security, some changes have been made to how tunnel endpoint updates are authenticated.Tunnels made after this post now are configured with an “Update Key” (under the “Advanced” tab on the tunnel information page), which is used instead of the general account password when performing automated updates via either the https://ipv4.tunnelbroker.net/ipv4_end.php or the /nic/update (Dyn-alike) mechanisms. ?Do not MD5() this value before use.When an “Update Key” exists, the account password will not work for updates on that tunnel. ?Existing tunnels can set an “Update Key” to take advantage of this new mechanism.

————————————————————

一些其它关于IPv6参考资料:

http://zh.wikipedia.org/wiki/IPv6

http://wiki.openwrt.org/doc/howto/ipv6

http://wayjam.me/post/internal-netwrok-allocate-ipv6-addresses.md

http://ekszz.com/?p=115

http://geektu.com/post/2013-09-02-openwrt-pei-zhi-ipv6-chuan-tou

在Openwrt上搭建ipv6的OpenVPN服务器

https://www.sixxs.net/tools/gateway

IPv6 DDNS(DNSPod.Python)

相关文章:

你感兴趣的文章:

标签云: