bind + dhcpd 동적 ddns 구현

7513 단어 bindDHCPddns

대상:


고객이 DHCP IP 주소를 획득한 후 현재 사용 중인 호스트 이름을 BIND 서버에 자동 등록하여 자동 도메인 이름 확인 기능을 실현
 

원리:


bind는 도메인 이름 해석에 사용되며 모든 사용자가 dns 서버를 업데이트하는 데 사용되지 않도록 키를 이용하여 데이터 업데이트 검증을 합니다
dhcpd는 IP 주소를 분배하는 동시에 DNS 업데이트 키를 고객에게 발송하고 고객은 자동으로 BIND 서버에 등록합니다
 
nns 서버 사이드 소프트웨어 설치
[root@station149 /]# yum install -y bind*

Installed:
  bind.x86_64 32:9.8.2-0.17.rc1.el6_4.6                         bind-chroot.x86_64 32:9.8.2-0.17.rc1.el6_4.6
  bind-devel.x86_64 32:9.8.2-0.17.rc1.el6_4.6                   bind-dyndb-ldap.x86_64 0:2.3-5.el6
  bind-sdb.x86_64 32:9.8.2-0.17.rc1.el6_4.6

Complete!

키 만들기
[root@station149 /]# rndc-confgen -r /dev/urandom -a
wrote key file "/etc/rndc.key"
[root@station149 /]# chown named:named /etc/rndc.key
[root@station149 /]# chown 644 /etc/rndc.key

 
현재 키 파일 내용
key "rndckey" {
        algorithm hmac-md5;
        secret "qUGWW02EZVKUNMK/iorkgg==";
};

키 내용을bind로 복사하고dhcp 설정이나include를 사용하여 파일 가져오기 방법으로 키를 불러올 수 있습니다
bind 프로필 정의
vi/var/named/chroot/etc/named.conf
options {
        directory "/var/named";
        forwarders { 8.8.8.8; };
};

key "rndckey" {
        algorithm hmac-md5;
        secret "qUGWW02EZVKUNMK/iorkgg==";
};
#    DHCP   DNS  
controls {
        inet 127.0.0.1 allow { 127.0.0.1; } keys { rndckey; };
};

zone "cloud.com." IN {
        type master;
        file "cloud.com.master.zone";
        allow-update { key rndckey; };
};

zone "48.168.192.in-addr.arpa." IN {
        type master;
        file "48.168.192.in-addr.arpa.master.zone";
        allow-update { key rndckey; };
};

정방향zone 프로필vi/var/named/chroot/var/named/cloud.com.master.zone
$TTL 86400
@ IN SOA station149.cloud.com. root.station149.cloud.com. (
        2014011510
        1400
        2300
        25000
        86400 )

@       IN              NS      station149.cloud.com.

station149              IN      A       192.168.48.149

 
zone 구성 파일 대칭 이동
vi /var/named/chroot/var/named/48.168.192.in-addr.arpa.master.zone
$TTL 86400
@ IN SOA station149.cloud.com. root.station149.cloud.com. (
        2014010810
        1400
        2300
        25000
        86400 )

@       IN              NS      station149.cloud.com.

149             IN      PTR     station149.cloud.com.

 
참고: 현재 양방향, 반방향 구성 파일만 구성하고 다른 호스트는 DDNS 방법을 이용하여 자동으로 등록합니다.
 
bind 시작 및 검증
[root@station149 /]# chown named:named /var/named/chroot/var/named/*.zone
[root@station149 /]# service named restart
  named:                                               [ ]
  named:                                               [ ]

nns 클라이언트 설정
[root@station149 ~]# vi /etc/resolv.conf
search clound.com
nameserver 192.168.48.149

테스트
[root@station149 ~]# host station149.cloud.com
station149.cloud.com has address 192.168.48.149
[root@station149 ~]# host 192.168.48.149
149.48.168.192.in-addr.arpa domain name pointer station149.cloud.com.
[root@station149 ~]# host www.google.com.hk
www.google.com.hk is an alias for www-wide.l.google.com.
www-wide.l.google.com has address 74.125.128.199
www-wide.l.google.com has IPv6 address 2404:6800:4005:c00::c7

DHCP 서버 구성
소프트웨어 설치
[root@station149 ~]# yum install -y dhcp

Installed:
  dhcp.x86_64 12:4.1.1-38.P1.el6.centos

Complete!

vi/etc/dhcp/dhcpd.conf
key "rndckey" {
        algorithm hmac-md5;
        secret "qUGWW02EZVKUNMK/iorkgg==";
};

ddns-domainname "cloud.com.";
ddns-update-style interim;
ddns-rev-domainname "in-addr.arpa.";
ddns-updates on;

authoritative;
#master server for this domain

# Allow only the DHCP server to update DNS
ignore client-updates;
allow unknown-clients;

host pdc {
   hardware ethernet 00:0B:2B:17:2F:00;
   fixed-address 192.168.48.2;
}

zone  48.168.192.in-addr.arpa {
        primary 127.0.0.1;
        key rndckey;
}

zone cloud.com {
        primary 127.0.0.1;
        key rndckey;
}

subnet 192.168.48.0 netmask 255.255.255.0 {
        range                        192.168.48.20 192.168.48.126;
        default-lease-time              86400;
        max-lease-time                172800;
        option subnet-mask             255.255.255.0;
        option broadcast-address        192.168.48.255;
        option routers                 192.168.48.1;
        option domain-name            "cloud.com.";
        option domain-name-servers     192.168.48.149;
}

dhcpd 시작
service dhcpd start

 
주의해야 할 문제:
dhcp 서버 관찰
[root@station149 etc]# cat/var/lib/dhcpd/dhcpd.leases
# The format of this file is documented in the dhcpd.leases(5) manual page.
# This lease file was written by isc-dhcp-4.1.1-P1

server-duid "\000\001\000\001\032i\023^\000PV\201\350\247";

lease 192.168.48.60 {
  starts 3 2014/01/15 09:38:11;
  ends 4 2014/01/16 09:38:11;
  cltt 3 2014/01/15 09:38:11;
  binding state active;
  next binding state free;
  hardware ethernet 00:50:56:81:72:9d;
  client-hostname "terry";
}

만약client-hostname "terry"를 발견할 수 없다면;정보는 클라이언트를 구성하고 DHCP 를 추가해야 합니다.HOSTNAME 구성
 
클라이언트 구성 정보 참조
[root@terry sysconfig]# cat /etc/sysconfig/network
NETWORKING=yes
HOSTNAME=terry
DHCP_HOSTNAME=terry

 
bind 서버 업데이트 로그 참조
Jan 15 17:40:42 station149 named-sdb[5646]: client 127.0.0.1#46556: signer "rndckey" approved
Jan 15 17:40:42 station149 named-sdb[5646]: client 127.0.0.1#46556: updating zone 'cloud.com/IN': adding an RR at 'terry.cloud.com' A
Jan 15 17:40:42 station149 named-sdb[5646]: client 127.0.0.1#46556: updating zone 'cloud.com/IN': adding an RR at 'terry.cloud.com' TXT
Jan 15 17:40:42 station149 named-sdb[5646]: cloud.com.master.zone.jnl: create: permission denied
Jan 15 17:40:42 station149 named-sdb[5646]: client 127.0.0.1#46556: updating zone 'cloud.com/IN': error: journal open failed: unexpected error
Jan 15 17:40:42 station149 dhcpd: Unable to add forward map from terry.cloud.com. to 192.168.48.60: timed out
Jan 15 17:40:42 station149 dhcpd: DHCPREQUEST for 192.168.48.60 from 00:50:56:81:72:9d (terry) via eth0
Jan 15 17:40:42 station149 dhcpd: DHCPACK on 192.168.48.60 to 00:50:56:81:72:9d (terry) via eth0

 
/var/name/chroot/var/named 디렉터리를 사용자named에서 읽을 수 있는지 주의하십시오
 
모든 것이 정상이라면,/var/named/chroot/var/named 디렉터리에서 jnl 접두사 파일이 자동으로 생성됩니다
[root@station149 named]# cd /var/named/chroot/var/named/
[root@station149 named]# ls *.jnl
48.168.192.in-addr.arpa.master.zone.jnl  cloud.com.master.zone.jnl

 
마지막으로 컴퓨터는 자동으로 DNS에 terry를 등록합니다.cloud.com 및 해당 IP 주소, 확인:
[root@station149 named]# host terry.cloud.com
terry.cloud.com has address 192.168.48.60
[root@station149 named]# host 192.168.48.60
60.48.168.192.in-addr.arpa domain name pointer terry.cloud.com.

 
 
 

좋은 웹페이지 즐겨찾기