[root@DNS ~]#vim /etc/sysconfig/network-scripts/ifcfg-eth0
DEVICE=eth0
TYPE=Ethernet
ONBOOT=yes
NM_CONTROLLED=no
BOOTPROTO=
static
IPADDR=192.168.10.100
PREFIX=24
[root@DNS ~]#yum install -y dhcp
3.2.生成一个key 在dns和dhcp都会用到,用来更新dns库[root@DNS ~]#dnssec-keygen -a HMAC-MD5 -b 128 -n USER ddnsuser
//以ddnsuser生成一个md5加密的128位密码,生成两个文件。
[root@DNS ~]# ls
anaconda-ks.cfg install.log.syslog Kddnsuser.+157+56925.private
install.log Kddnsuser.+157+56925.key
[root@DNS ~]# cat Kddnsuser.+157+56925.key
ddnsuser. IN KEY 0 3 157 oxRjfO3rB1b0pzY1WNpbNg== //后半段为密文,需要用到
[root@DNS ~]#grep -v "^#" /etc/dhcp/dhcpd.conf
ddns-update-style interim;
#ddns-updates on;
log-facility local7;
key ddnsuser {
algorithm hmac-md5;
secret oxRjfO3rB1b0pzY1WNpbNg==; //指定ddnsuser的key
}
zone ddns.com. {
primary 192.168.10.100;
key ddnsuser; //允许dhcp更新dns记录
}
zone 10.168.192.in-addr.arpa. {
primary 192.168.10.100;
key ddnsuser;
}
subnet 192.168.10.0 netmask 255.255.255.0 {
range 192.168.10.30 192.168.10.31;
option routers 192.168.10.1;
option domain-name "ddns.com";
option domain-name-servers 192.168.10.100;
default-lease-time 600;
max-lease-time 7200;
}
[root@DNS ~]# service dhcpd start
[root@DNS ~]# yum install -y bind bind-chroot bind-libs bind-utils
4.2 dns的配置如下:[root@DNS named]# cat /etc/named.conf
zone "." IN {
type hint;
file "named.ca";
};
key ddnsuser {
algorithm hmac-md5;
secret oxRjfO3rB1b0pzY1WNpbNg==; //指定ddnsuser的key
};
zone "ddns.com" IN {
type master;
file "/var/named/ddns.zone";
allow-update {key ddnsuser;}; //允许通过验证的key升级dns库
};
zone "10.168.192.in-addr.arpa" IN {
type master;
file "/var/named/ddns.zone.db";
allow-update {key ddnsuser;};
};
include "/etc/named.rfc1912.zones";
include "/etc/named.root.key";
[root@DNS ~]# cp -p /var/named/named.loopback /var/named/ddns.zone
[root@DNS ~]# cp -p /var/named/named.loopback /var/named/ddns.zone.db
$ORIGIN .
$TTL 86400 ; 1 day
ddns.com IN SOA dns.ddns.com. rname.invalid. (
3 ; serial
86400 ; refresh
3600 ; retry
604800 ; expire
10800 ; minimum
)
NS dns.ddns.com.
$ORIGIN ddns.com.
dns A 192.168.10.100
www A 192.168.10.15
[root@DNS ~]# vim /var/named/ddns.zone.db
$ORIGIN .
$TTL 86400 ; 1 day
10.168.192.in-addr.arpa IN SOA dns.ddns.com.10.168.192.in-addr.arpa. rname.invalid. (
2 ; serial
86400 ; refresh
3600 ; retry
604800 ; expire
10800 ; minimum
)
NS dns.ddns.com.
$ORIG IN 10.168.192.in-addr.arpa.
15 PTR www.ddns.com
19 PTR dns.ddns.com
[root@DNS ~]# chmod g+w /var/named/ //为了让dhcp可写
[root@DNS ~]# chown -R named.named /var/named/chroot/var/named/
//在centos6中,上述的目录默认是root.named ,导致最后的.jnl文件不能生成,注意修改权限。
[root@DNS ~]# service named start
[root@ntp ~]# vim /etc/dhcp/dhclient.conf
send fqdn.fqdn "ntp"; //ntp是客户端的hostname
send fqdn.encoded on;
send fqdn.server-update off;
BOOTPROTO=dhcp
[root@ntp ~]# dhclient -r
[root@ntp ~]# dhclient eth0
[root@ntp ~]# nslookup ntp.ddns.com
Server: 192.168.100.100
Address: 192.168.100.100#53
Name: ntp.ddns.com
Address: 192.168.100.30
[root@ntp ~]# host 192.168.100.30
30.100.168.192.in-addr.arpa domain name pointer ntp.ddns.com.
************
-rw-r--r-- 1 named named 432 1月 18 15:28 ddns.zone
-rw-r--r-- 1 named named 421 1月 18 15:27 ddns.zone.db
-rw-r--r-- 1 named named 1683 1月 18 15:15 ddns.zone.db.jnl
-rw-r--r-- 1 named named 1682 1月 18 15:15 ddns.zone.jnl
************
$ORIGIN .
$TTL 86400 ; 1 day
ddns.com IN SOA dns.ddns.com. rname.invalid. (
4 ; serial
86400 ;
3600 ;
604800 ;
10800 ;
)
NS dns.ddns.com.
$ORIGIN ddns.com.
dns A 192.168.10.100
$TTL 300 ; 5 minutes
ntp A 192.168.10.30
TXT "001c92d13d95f00b8d62503da8db6bfa35"
$TTL 86400 ; 1 day
www A 192.168.10.15
~
$ORIGIN .
$TTL 86400 ; 1 day
10.168.192.in-addr.arpa IN SOA dns.ddns.com.10.168.192.in-addr.arpa. rname.invalid. (
3 ; serial
86400 ;
3600 ;
604800 ;
10800 ;
)
NS dns.ddns.com.
$ORIGIN 10.168.192.in-addr.arpa.
15 PTR www.ddns.com
19 PTR dns.ddns.com
$TTL 300 ; 5 minutes
30 PTR ntp.ddns.com.