用ddclient实现顶级域名动态解析

OpenBSD的安装、升级、更新等日常问题。

版主: chenjun天地乾坤

回复
头像
leo
帖子: 2465
注册时间: 2010-01-21 3:27

用ddclient实现顶级域名动态解析

帖子 leo » 2011-05-13 14:01

用ddclient实现顶级域名动态解析
现在有一些域名供应商可以免费提供顶级域名的动态解析,这就给不想/能使用共享主机的用户提供了一个更多的选择,例如,那些每次拨号后公网IP地址都会发生变化的ADSL用户。

好了,不多说了,下面直奔主题:
我的平台,OpenBSD 4.8 i386,我们以在namecheap申请的域名gobsd.org以为例(这里是假设的例子)
1. 先安装ddclient:

代码: 全选

# export PKG_PATH=ftp://ftp.openbsd.org/pub/OpenBSD/4.8/packages/i386/
# pkg_add ddclient-3.8.0

2. 配置 ddclient:
ddclient的配置文件是 /etc/ddclient/ddclient.conf,用自己熟悉的编辑器打开配置文件并找到最后的namecheap的部分
修改为:

代码: 全选

##
## NameCheap (namecheap.com)
##
protocol=namecheap
server=dynamicdns.park-your-domain.com
login=gobsd.org
password=1b9aafgfgjh1865e024fabb629dbd1d9c462gobsdb629dbd1d9c462
www.gobsd.org
保存退出。

限制配置文件的权限:

代码: 全选

# chmod 600 /etc/ddclient/ddclient.conf

让ddclient随系统启动,编辑: /etc/rc.local 文件,加入如下内容:

代码: 全选

if [ -x /usr/local/sbin/ddclient ]; then
echo -n ' ddclient';       /usr/local/sbin/ddclient
fi

done!

hyaska
铜 Cu
帖子: 311
注册时间: 2010-12-10 16:11

回复: 用ddclient实现顶级域名动态解析

帖子 hyaska » 2011-06-01 13:03

想问一下,我用freedns.afraid.org提供的免费域名,ddclient好像不支持,官方提供一个http://perl.arix.com/ftp/afraid-dyndns-1.1.tar.gz

不会用,似乎是PERL写的

头像
leo
帖子: 2465
注册时间: 2010-01-21 3:27

回复: 用ddclient实现顶级域名动态解析

帖子 leo » 2011-06-01 13:12

没看明白你的意思,你的说afraid.org免费提供顶级域名的动态解析还是提供afraid.org的免费二级域名解析?
我没有用过你说的这个,对Perl一窍不通。如果你需要二级域名解析不如直接用国内的3322.org就行了,直接在crontab里面挂一个任务就行了。参这里http://www.gobsd.org/showthread.php?t=2538

头像
leo
帖子: 2465
注册时间: 2010-01-21 3:27

回复: 用ddclient实现顶级域名动态解析

帖子 leo » 2011-06-01 13:51

看了一下这个网站,确实提供顶级域名解析。
OpenBSD 自带修补过的perl, 所以如果只是一个perl脚本,操作应该不难,我这一阵子一直为解决论坛升级后的中文搜索绞尽脑汁,暂时还没有时间进行测试,兄弟们自己来吧,估计难度不大,如果实在搞不定,等我闲下来再测试一下。这个网站上挂靠的顶级域名很多,应该操作起来没有什么难度的;如果哪位测试成功了,请给出方案,多谢了。

说明如下:

代码: 全选

SYNOPSIS
    This utility implements a client for the afraid.org dynamic DNS service.
    A cron job is set up to check whether the external IP address has
    changed, and when it does, connects to afraid.org and updates the
    DNS entries of all the domains of the given account.
SUPPORTED OPERATING SYSTEMS
   * Fedora
   * CentOS
   * RHEL
   * OSX
INSTALL
    1. log in as root (needed to access config, cron and cache directories):
        # su -
    2. Download the tarball:
     # cd /tmp
     # wget ftp://arix.com/afraid-dyndns-x.x.tar.gz
     on OSX, you can use:
        # curl -O ftp://[email protected]/afraid-dyndns-x.x.tar.gz
    3. Untar:
     # tar xzvf afraid-dyndns-x.x.tgz
    4. Install:
     # cd afraid-dyndns-x.x
     # ./install
CONFIGURATION
   To configure, edit the /etc/afraid-dyndns.conf file.  The AccountHash
   field refers to the SHA value assigned to your afraid.org account.
   To get it, log into afraid.org and visit:
    http://freedns.afraid.org/api/
   then click on either of your "ChoOsE YoUr WeApOn" links and take
   the value of the "sha" parameter (it's a long string). The Notify
   address (if present) will be sent e-mail whenever the DNS is
   refreshed.  CacheFile is the file name where the external IP address
   will be cached.
   Additionally, the cron job checks the external IP address every 15
   minutes.  To modify this, edit /etc/cron.d/afraid-dyndns - on OSX you'll
   need to edit the file /Library/LaunchDaemons/org.afraid.dyndns.plist (and
   reboot)
   Unlink on Linux systems where all names on the account are refreshed with
   the IP of the host, on OSX the default configuration only names matching
   the host's name will be refreshed.  The assumption here is that Linux
   hosts are likely to be used as servers (which may require multiple names
   as in the case of a webserver hosting multiple domains), whereas OSX
   hosts are likely to be used as clients e.g. laptops which we want
   accessible via a domain name but which roam.
 To change this behaviour on OSX, edit the plist, take out the
    hostname parameter (after the --quiet) and reboot.
SYNTAX
   Call the script with --help
LIMITATIONS
   At present, only one account is supported.
AUTHOR/SUPPORT
   Erick Calder <[email protected]> - For bugs, suggestions, etc. please
   feel free to contact me.

hyaska
铜 Cu
帖子: 311
注册时间: 2010-12-10 16:11

回复: 用ddclient实现顶级域名动态解析

帖子 hyaska » 2011-06-01 16:09

我用freedns是因为动态免费,还有短域名可用,输入时偷点懒。

安装脚本我看了,估计是基于bsh的,跟OB的ksh不能完全兼容,所以安不了,试着分析每句的作用,大不了手动安一个试试。

头像
leo
帖子: 2465
注册时间: 2010-01-21 3:27

回复: 用ddclient实现顶级域名动态解析

帖子 leo » 2011-06-01 16:24

我没有用过bash,但是OpenBSD的ports里好像有,可以先安装一个试试,如果成功了就简单了,再想办法将bash的脚本转换为ksh的。Unix的shell多也是麻烦事,有时候选择时确实两难。

PS:还是namecheap的简单,直接在ddclient里可以设置参数,我刚看了一下自己的 /etc/ddclient/ddclient.conf文件,里面不能设置afraid.org的二级域,如果你的域名不是在namecheap注册的,恐怕无法使用我上面给出的方案。

hyaska
铜 Cu
帖子: 311
注册时间: 2010-12-10 16:11

回复: 用ddclient实现顶级域名动态解析

帖子 hyaska » 2011-06-09 16:17

刚才仔细研究了一下主站,没发现可以不用什么客户端软件,直接用一行命令就可以搞定
红圈部分就是取得只针对你申请帐号做DDNS的脚本,格式如下:

代码: 全选

rem xxx.yyy.zzz
wget -q --read-timeout=0.0 --waitretry=5 --tries=400 --background http://freedns.afraid.org/dynamic/update.php?ABCDE.....       #ABCDE....一串是根据你的帐号和密码生成的,一旦改密码后这串就会变的
真的很简单,差点就被主站的FAQ里的那些客户端给误导了:D
附件
QQ截图20110608160846.png

junfengfan
铜 Cu
帖子: 236
注册时间: 2010-02-03 18:37

回复: 用ddclient实现顶级域名动态解析

帖子 junfengfan » 2012-01-30 22:36

放在 openbsd 的运行提示  rem: not found

要不把 rem那行去掉?

回复

在线用户

正浏览此版面之用户: 没有注册用户 和 0 访客