在 pfSense 上安装 DDclient

接着昨天的来,现在我们需要给我们刚建的小组内部网络设个动态域名以便外面可以用 ssh 等访问到内部的服务器,首先需要到 DynDNS.com 注册一个免费二级域名,然后在防火墙上安装动态域名客户端,每隔一段时间自动读取 ADSL 路由器的动态 IP 地址然后更新到 DynDNS.com 的域名服务就可以了。

pfSense 有自带的动态域名客户端,打开 pfSense 管理界面后配置 pfSense 自带的 Dynamic DNS 服务(pfSense->Services->Dynamic DNS),发现这个客户端有问题,只能在 save 的时候更新一次 IP 地址,不能自己自动更新 IP 地址,而且第一次提交的 IP 地址是内部的网络地址而不是我们想要的 ADSL 路由器对外的 IP 地址,google 了一下发现 pfSense 自带的动态域名客户端确实有问题:

Only works if pfSense is the public IP assigned to one of its interfaces. If you have a modem that gets your public IP and pfSense is a private IP, private IP address is registered with the provider.

解决办法是 disable pfSense 自带的 Dynamic DNS,安装第三方动态域名客户端 ddclient:

# pkg_add -r http://files.pfsense.org/packages/dns/ddclient-3.7.0.tbz
# cp /usr/local/etc/ddclient.conf.sample /usr/local/etc/ddclient.conf

# chmod +w /usr/local/etc/ddclient.conf
# vi /usr/local/etc/ddclient.conf
use=web, web=checkip.dyndns.com/, web-skip='IP Address'
server=members.dyndns.org
protocol=dyndns2
login=vpsee
password=your-password
vpsee.dyndns.org

修改完上面的 ddclient 的配置文件后,运行 ddclient 测试一下是否能运行:

# /usr/local/sbin/ddclient -daemon=0 -debug -verbose -noquiet

...
Can't load '/usr/local/lib/perl5/site_perl/5.8.8/mach/auto/Net/SSLeay/SSLeay.so' for module Net::SSLeay: Shared object "libssl.so.4" not found, required by "SSLeay.so" at /usr/local/lib/perl5/5.8.8/mach/DynaLoader.pm line 230.
 at /usr/local/lib/perl5/site_perl/5.8.8/IO/Socket/SSL.pm line 17
Compilation failed in require at /usr/local/lib/perl5/site_perl/5.8.8/IO/Socket/SSL.pm line 17.
BEGIN failed--compilation aborted at /usr/local/lib/perl5/site_perl/5.8.8/IO/Socket/SSL.pm line 17.
Compilation failed in require at /usr/local/sbin/ddclient line 1652.

上面错误显示缺少 libssl 库,这个好办,安装一个就可以了:

# pkg_add -r http://files.pfsense.org/packages/devel/openssl-stable-0.9.7l.tbz
# cp /usr/local/openssl/openssl.cnf.sample /usr/local/openssl/openssl.cnf

再次运行 ddclient 后无错误提示,运行成功:

# /usr/local/sbin/ddclient -daemon=0 -debug -verbose -noquiet

最后允许 ddclient 在后台(daemon)运行:

# vi /etc/rc.conf
ddclient_enable="YES"

登陆后 DynDNS.com 就会发现刚注册的二级域名的 IP 地址自动更新了:

dyndns domain

发表评论