解释:DDNS=DHCP+DNS 【(Dynamic Domain Name Server)是动态域名服务的缩写!】
DDNS是将用户的动态IP地址映射到一个固定的域名解析服务上,
用户每次连接网络的时候客户端程序就会通过信息传递把该主机的动态IP地址传送给位于服务商主机上的服务器程序,
服务器程序负责提供DNS服务并实现动态域名解析
DHCP服务器:192.168.0.169 server69.exmaple.com
DNS服务器: 192.168.0.169 server69.example.com
测试主机:192。168.0.149 server49.example.com
在DNS服务器上:
配置远程加密更新
制作加密key
[root@server69 ~]#dnssec-keygen -a HMAC-MD5 -b 128 -nHOST ddns
[root@ server69 mnt]# cat Kddns.+157+30578.key
ddns. IN KEY 512 3 157 bC7Ml1YC8C8PZWi9RSg1kg==
[root@server69 ~]# cp -p /var/named/chroot/etc/rndc.key/var/named/chroot/etc/ddns.key
[root@ server69 ~]# vim /var/named/chroot/etc/ddns.key
key "ddns" {
algorithm hmac-md5;
secret"bC7Ml1YC8C8PZWi9RSg1kg==";
};
[root@ server69 ~]# vim/var/named/chroot/etc/named.conf
include"/etc/ddns.key";
[root@ server69~]# vim/var/named/chroot/etc/named.rfc1912.zones
zone "example.com" IN {
typemaster;
file"example.com.zone";
allow-update { key ddns; };
};
[root@ server69 ~]# cp -p /var/named/named.localhost/var/named/example.com.zone
[root@ server69 ~]# vim /var/named/example.com.zone
$TTL 1D
@ IN SOA server69.example.com. root.example.com. (
0 ; serial
1D ; refresh
1H ; retry
1W ; expire
3H) ; minimum
NS server69.example.com.
server69 A 192.168.0.169
server49 A 192.168.0.149
在DHCP服务器上:
[root@ server69 ~]# vim /etc/dhcp/dhcpd.conf
optiondomain-name "example.com";
optiondomain-name-servers 192.168.0.169;
default-lease-time600;
max-lease-time7200;
ddns-update-styleinterim; //指明实现动态DNS的方法为interim
update-conflict-detectionfalse;
log-facilitylocal7;
subnet192.168.0.0 netmask 255.255.255.0 {
range 192.168.0.150 192.168.0.180;
option routers 192.168.0.253;
filename "pxelinux.0";
next-server 192.168.0.169;
}
key ddns { //man 5 dhcpd.conf
algorithm hmac-md5; //指明生成密钥的算法
secret bC7Ml1YC8C8PZWi9RSg1kg==; //指明密钥
};
zone example.com. {
primary 127.0.0.1;
key ddns;
}
[root@ server69 ~]# /etc/init.d/dhcpd restart
[root@ server69 ~]# /etc/init.d/named restart
在测试主机上:
[root@ server49 ~]# rm -fr cd/etc/dhcp/dhclient-eth0.conf
[root@ server49 ~]# vim /etc/dhcp/dhclient.conf ###man 5 dhclient.conf
sendfqdn.fqdn " server49.example.com.";
sendfqdn.encoded on;
sendfqdn.server-update on;
[root@ server49 ~]# vim/etc/sysconfig/network-scripts/ifcfg-eth0
DEVICE="eth0"
BOOTPROTO="dhcp"
ONBOOT="yes"
[root@ server49 ~]# /etc/init.d/network restart
Shutting down interface eth0: [ OK ]
Shutting down loopback interface: [ OK ]
Bringing up loopback interface: [ OK ]
Bringing up interface eth0:
Determining IP information for eth0... done.
[ OK ]
[root@ server49 ~]# ifconfig
eth0 Linkencap:Ethernet HWaddr52:54:00:8E:D5:D1
inet addr:192.168.0.149 Bcast:192.168.0.255 Mask:255.255.255.0
[root@ server49 ~]# dig server49.example.com
; <<>> DiG9.8.2rc1-RedHat-9.8.2-0.17.rc1.el6 <<>> server49.example.com
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status:NOERROR, id: 35253
;; flags: qr aa rd ra; QUERY: 1, ANSWER: 1, AUTHORITY:1, ADDITIONAL: 1
;; QUESTION SECTION:
; server49.example.com. IN A
;; ANSWER SECTION:
Server49.example.com. 300 IN A 192.168.0.150
;; AUTHORITY SECTION:
example.com. 86400 IN NS server69.example.com.
;; ADDITIONAL SECTION:
Server69.example.com. 86400 IN A 192.168.0.169
;; Query time: 1 msec
;; SERVER: 192.168.0.169#53(192.168.0.169)
;; WHEN: Sat Mar 8 03:38:48 2014
;; MSG SIZE rcvd: 85