树莓派raspbian实现ddns搭建linux nginx mysql php adsl顶级域名动态解析服务器
作者:互联网观察 发布时间:Jan 29, 2014 分类:linux
树莓派raspbian实现ddns搭建linux nginx mysql php adsl服务器
以下是python脚本
#!/usr/bin/env python
#-*- coding:utf-8 -*-
import httplib, urllib
import socket
import time
params = dict(
login_email="i@qq.com", # replace with your email
login_password="password!", # replace with your password
format="json",
domain_id=111111, # replace with your domain_od, can get it by API Domain.List
record_id=1111111, # replace with your record_id, can get it by API Record.List
sub_domain="adsl", # replace with your sub_domain
record_line="默认",
)
current_ip = None
def 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.Ddns", urllib.urlencode(params), headers)
response = conn.getresponse()
print response.status, response.reason
data = response.read()
print data
conn.close()
return response.status == 200
def getip():
sock = socket.create_connection(('ns1.dnspod.net', 6666))
ip = sock.recv(16)
sock.close()
return ip
if __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(30)
保存以上代码为 ddns.py
在ssh执行:
nohup python ddns.py &
(注意后面的 & 前有个空格)
ok 这个python 程序就在后台运行了,
相关文章
- PVE8开启IOMMU硬件直通功能
- openvz 虚拟化服务器 小内存情况下服务器的面板选择
- onethink 定制开发
- raspberry pi raspbian安装 lnmp nginx php mysql
- 帝国cms 查看页面执行时间
- 架设在 mk802 rk3066处理器上的linux网站
- Android-Firmata 和 Amarino
- rk3066 linux PicUntu
- 过去的2012
- 基于开源平台机器人的方案构想:raspberry-pi,mk802 ,arduino
文档信息
- 版权声明:自由转载-非商用-非衍生-保持署名 | Creative Commons BY-NC-ND 3.0
- 原文网址:https://www.tianmeng.org/linux_396/树莓派raspbian实现ddns搭建linux-nginx-mysql-php-adsl服务器/
- 最后修改时间:2014年07月10日 11:22:34

当前暂无评论 »