在DD-WRT上使用 花生壳 动态DNS(DDns)

折腾了DD-WRT的动态DNS一翻,记录一下。

首先,由DD-WRT 的状态输出入可以得知,DD使用的是INADYN,如下。

[important]

DDNS 状态

Thu Jan 1 00:33:16 1970: INADYN: Started ‘INADYN Advanced version 1.96-ADV’ – dynamic DNS updater.

[/important]

知道之后就好办了,在网上可以查到INADYN的相关信息。INADYN是一款基于HTTP的DDNS更新器,通过发送HTTP请求来实现DDNS的更新。

官网:http://www.inatech.eu/inadyn/readme.html 说明如下。

[important]

Command line options

They are automatically printed if inadyn gets wrong parameters or if –help option is used.

Parameters:

‘–help’: help
‘-h’: help

‘–username’: your membername/ hash
‘-u’: your membername / hash

‘–password’: your password. Optional.
‘-p’: your password

‘–alias’:alias host name. this option can appear multiple times. (for each domain that has the same IP)
‘-a’: alias host name. this option can appear multiple times.

‘–input_file’: input file name that contains inadyn command options (adds to those already present in the cmd line). The default configuration file name is ‘/etc/inadyn.conf’. It is only used if inadyn is called without any command line options. This allows inadyn to be called without any arguments. The format is as expected for a **NIX config  file. See below for details.

‘–ip_server_name[:port]url’: The client IP is detected by calling ‘url’ from this ‘ip_server_name:port’. Defaults to checkip.dyndns.org:80 /.

‘–dyndns_server_name’: [[:port]] The server that receives the update DNS request. If no proxy is wanted, then it is enough to set the dyndns system. The default servers will be taken.

‘–dyndns_server_url’ full URL relative to DynDNS server root.

‘–dyndns_system’: [NAME] – optional DYNDNS service type. SHOULD be one of the following:

-For dyndns.org DNS system: [email protected] OR [email protected] OR [email protected].

-For freedns.afraid.org DNS system: [email protected] .

-For the servcie ofered by zoneedit.com: [email protected].

-For no-ip.com : [email protected]

-For generic DNS system: custom@http_svr_basic_auth

DEFAULT value is intended for default service at dyndns.org: [email protected]

–proxy_server‘: [NAME[:port]] – the http proxy server name and port. Default is none.

–update_period‘: how often the IP is checked. The period is in [ms]. Default is about 1 min. Max is 10 days

–update_period_sec‘: how often the IP is checked. The period is in [sec]. Default is about 1 min. Max is 10 days

–forced_update_period‘: how often the IP is updated even if it is not changed. [in sec]

–log_file‘: log file path abd name

–background‘: runs in background.  Output to syslog or to log file [if specified].

–verbose’: set dbg level. 0 to 5

–iterations‘: set the number of DNS updates. Default is 0, which means infinity.

–syslog‘: explicit set output to syslog. (e.g. /var/log/messages). Works on **NIX systems only.

–change_persona uid[:gid]’: After init changes user ID and group ID to the provided ones. This allows dropping unneeded [root] privileges after startup. Works for **NIX only.

[/important]

 

说说常用的几个参数:

–dyndns_system  :使用INADYN内的预设配置,会自动根据其内部配置在HTTP 请求上添加相关参数。

–verbose  :详尽地查看INADYN的运行状态,可以看见发送的HTTP请求,用于Debug。

–ip_server_name  :设置INADYN的IP检查器,当你的DD-WRT在内网或者DDNS的供应商自动获取的IP不正确,这个参数就有用了。

 

首先,要得知花生壳的HTTP协议,可以在 这里 找到,如下。

[important]

http://username:[email protected]/ph/update?hostname=yourhostname&myip=ipaddress

[/important]

 

通过上面的资料配置DD提供的参数即可。因为花生壳的参数配置与INYDYN默认的配置基本适配,所以直接按DD-WRT要求填写即可。

[important]

DDNS服务:自定义

DYNDNS 服务器:ddns.oray.com

用户名:username

密码:password

主机名:YourDDnsDomain

URL:/ph/update?hostname=

DDNS 附加选项:–verbose 5

[/important]

 

如果你看见DDNS状态的最后打印“good YourIP” 就说明你的DDNS已经成功更新了

如果你遇到特殊情况请按下面的处理。

成功更新后返回的IP和你的路由上的不一致,如果是类似长城宽带这些网络供应商可能会出现这样的问题,他们的HTTP可能经过其他服务器加速导致发送HTTP请求的IP与你的IP不一致。

这时就需要使用–ip_server_name 参数,比如使用ip138.com提供的本机IP可以这样写。

[important]

–ip_server_name 20140507.ip138.com /ic.asp

这个地址可以通过在ip138.com的主页查看页面源码找到。

需要注意的是.com后面的空格

[/important]

 

加上这个参数后你会发现,INADYN发送的请求没有加上myip= 这个参数,这时你可以调用其他默认配置的参数。

[important]

–dyndns_system [email protected]

[/important]

 

OK,应该可以看见正确地返回你的IP了。

 

至于 花生壳 服务器返回 “badauth” 是你的用户名或(和)密码错误,请核对。

如果确实正确,那么就是花生壳的服务器有问题了。

 

如果你想DDNS更新更为频繁可以使用–update_period_sec参数。

[important]

–update_period_sec 1200

上面的设置是每20分钟发送一次请求

[/important]

 

 

 

发表回复

您的电子邮箱地址不会被公开。 必填项已用 * 标注