Ȼ/11

Top / Ȼ / 11

DNS հλȤ

BIND ϤˡհλȤߤˤĤƤ⿨Ƥ.
¤ϡѼԤΤ褯ľȰۤʤꡤDNS εհ(IP ɥ쥹¾ξΤ)̤ʻȤߤѰդƤʤ.

IP ɥ쥹 FQDN Τ褦˳ع¤򤷤Ƥ뤳ȤѤơ
IP ɥ쥹ۥ̾ΰǤȤߤʤ DNS λȤߤʶޤ
Ȥǵհ¸Ƥ.

Ūˤϡ"in-addr.arpa." Ȥ̤ʥɥᥤ*1βˡIP ɥ쥹ոˤ*2ۥ̾Ȥߤʤ DNS Ǽ갷.
㤨С192.168.125.107 Ȥ IP ɥ쥹ϡ107.125.168.192.in-addr.arpa. Ȥۥ̾ DNS Ͽ뤳Ȥˤʤ.

հǤϤμɬפʤΤdzФƤ.

½

dig ޥɤʤɤǡλȤߤ´Ƥߤ褦.
ŪˤϡʬΥޥ IP ɥ쥹 192.168.125.??? ˤ

 host -t PTR ???.125.168.192.in-addr.arpa.
 dig -t PTR ???.125.168.192.in-addr.arpa.
 nslookup -q=PTR ???.125.168.192.in-addr.arpa.

ȤơʬΥޥ̾ƤΤǧƤߤ褦*3.

ޤ

 nslookup -q=ANY 125.168.192.in-addr.arpa.

ʤɤȤƤߤˤɤֻ֤äƤ뤫Ƥߤ.

DNS 䤤碌饤ȤȤƤ

ޤ BINDˡDNS 䤤碌 FreeBSD ǤɤΤ褦ˤƤ뤫񤤤Ƥ.
FreeBSD Ǥ DNS 䤤碌ԤϴŪ /etc/resolv.conf Ȥե˽񤭹ळȤˤʤäƤ.
ܺ٤ man resolv.conf ȤɤǤ餦Ȥˤơ¤񤤤Ƥ.

ץ(ɤ1Ԥǽ񤫤)
nameservernameserver 192.168.125.14DNS (ƵŪ)䤤碌. դƤǤʤȤʤ. nameserver ץ 3ĤޤǻǤ夫˻.
domaindomain cl.math.sci.osaka-u.ac.jpɥᥤ̾. 񤤤ƤСɥᥤ˽°ۥȤ򸡺ݤ˺ǽ . ʹߤάǤ. search Ȥ¾Ū.
searchsearch math.sci.osaka-u.ac.jp sci.osaka-u.ac.jpκݡ䴰뤿˻ȤɥᥤΥꥹ. Ƕڤ. domain Ȥ¾Ū.

½

/etc/resolv.conf search ץꤷơѤƤߤ褦.
Ūˤϡ

search cl.math.sci.osaka-u.ac.jp math.sci.osaka-u.ac.jp sci.osaka-u.ac.jp

Ȥ(1Ԥǽ񤯤) resolv.conf ˲ä塤

host www

dig +search -t ANY mail

ʤɤȤƤߤ褦*4.

DNS Ф¿Ų

ˡDNS Ф¿ŲˤĤƤҤ٤Ƥ.

DNS Фϥ󥿡ͥåȤ˽פ̤ΤǤΤǡɥᥤƤ륵Ф 1椷ʤȤ֤Ϥޤˤ⿴٤򤱤٤Ǥ.
ǡDNS ФϴŪ2սʾ¿Ų뤳ȤˤʤäƤ*5.

ơǡ䡤ˤĤƤϻȤߤȹͤƤ.
ϡ1ĤΥ(1Ĥ DNS ǤϰϤȻפФ褤)ˤĤơΥꥸʥĥ ޥ 1ȡΥԡĥ 졼֥ 1ʾѰդ뤳ȡȤƼ¸.
ơꥸʥ󤬥ޥФ饹졼֥ФŪʤϹˤԡ*6ȤǡʣΥФۤƱĻȤߤˤʤäƤ.

ʤDNS 䤤碌Ԥ饤Ȥ鸫ȥޥФ졼֥Фζ̤Ϥʤñˡ᤯ۡפʤɤ褦ˤʤäƤ.

DNS ФοƻҴط

DNS ŪǤꡤξ DNS ФⳬŪˤʤäƤ뤳ȤμȤ dig +trace ǤƤ.
ơǤϤγءƻҴط(Ƥ礭ʥɥᥤ򡤻ҤϤΥ֥ɥᥤƤ륵ФȤȤˤʤ)ϼºݤˤɤΤ褦˴Ƥ.

Ϥäȹͤʬ뤳ȤֿƥФҥФ֥ɥᥤƤ뤳ȤΤäƤФ褤*7.
ŪˤϡƥФΤΥ(ɥᥤ)ˡҥФ륾(ɥᥤ)ȤλҥФбƤФ褤.

ʬפ褦˶ǽ񤳤.
㤨СƥФ aaa.com ɥᥤƤơҥ ns.sub.aaa.com(192.168.125.105) ֥ɥᥤ sub.aaa.com Ȥ褦.
λϡƥФ aaa.com

 sub.aaa.com.  IN NS  ns.sub.aaa.com.
 ns.sub.aaa.com. IN A 192.168.125.105

Ƚ񤯤Ȥˤʤ.
ܤξ󤬤˽񤤤Ƥ뤫¾DNSʤȡns.sub.aaa.com. ˥ǤʤΤǰ̣ʤ.

ơäդ˸С
ֿƥФҥФ֥ɥᥤƤ뤳ȤΤʤ= ֿƥФǾΤ褦򤷤Ƥʤ
ˤСΥ֥ɥᥤξϡֻҥФľ䤤碌ͤΤʤפΤǡޤǥ˥֥ɥᥤȤȤǽǤ*8

BIND δ

BIND λŻϥ꥾(DNS䤤碌뤳)ʤɤ櫓ޤư˺¤ԤäƤߤ褦.
Ǥ⽼ʬ̣.

named.conf

/etc/namedb ( /var/named/etc/namedb )ʲˡBIND ȤեǤ named.conf .
񤭴СBIND ޤưѤ.
ʤߤˡnamed.conf ʸˡåѤ named-checkconf ȤޥɤΤdzФƤ.

ơȤ̵뤹ȡǥեȤǤϤΥեˤϼΤ褦ʹܤʤ.

 options {
         directory       "/etc/namedb";
         pid-file        "/var/run/named/pid";
         dump-file       "/var/dump/named_dump.db";
         statistics-file "/var/stats/named.stats";
         listen-on       { 127.0.0.1; };
 };
 
 zone "." {
         type hint;
         file "named.root";
 };
 
 zone "0.0.127.IN-ADDR.ARPA" {
         type master;
         file "master/localhost.rev";
 };
 
 zone "1.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.IP6.ARPA" {
         type master;
         file "master/localhost-v6.rev";
 };

ߤȤ褽ʬ褦ˡΥեñǡoptions zone 餤ܤϤʤ.
ºݤˤ¾ acl(¤򤫤), include(ե̤ɤ߹), server(¾ DNS ФȤ³)ʤɤǤ뤬, ޤϵˤʤƤ褤.

named.conf options

named.conf ԽˤޤϥХååפȤ*9.

ơoptions Ǥ BIND Ȥư륪ץꤹ롥
ǥեȤǽ񤫤ƤΤϤۤܤΤޤ޻ȤΤȤơۤȤɤʤǤ褤.

줫鳧ΥФϳơ¾䤤碌ˤ DNS ФȤꤹΤǡ¾䤤碌̵뤷Ƥϰ̣ʤ.
ǡ

 //      listen-on       { 127.0.0.1; };

, listen-on ԤϥȥȤƤ.

¾ options ˤ褯ȤʤΤȤƤϰʲΤΤ.

ơȥ
forwardforward only; ⤷ forward first;only ξ硤ʬǻäƤʤƿǤ(^-^) first ξϡޤͤǤơʤ鼫ʬǤʤȤ.
forwardersforwarders {192.168.125.xxx; 192.168.125.yyy;};forward
recursionrecursion yes; ⤷ recursion no;BIND ƵŪ䤤碌Ԥɤ. ԤʤϽ˥󶡼ԤȤʤ.
allow-queryallow-query { 192.168.125.xxx; 127.0.0.1; };䤤碌դۥ̾. ꤷʤ(ǥե)ɤǤդ.
allow-recursionallow-recursion { 192.168.125.xxx; 127.0.0.1; };ƵŪ䤤碌դۥ̾. ꤷʤ(ǥե)ɤǤդ.
allow-transferallow-transfer { 192.168.125.xxx; 127.0.0.1; };žդۥ̾. ꤷʤ(ǥե)ɤǤդ.̾ϴԥФȥ졼֥ФΤߤˤƤΤ褤Ȥ.

ǤϡƤ named.conf options ­Ƥ.

 forward only;
 forwarders { 192.168.125.14; };

ơǰΰ٤ named-checkconf ǥåƤ.

 named-checkconf

ʤСʸˡϤʤȤȤ. ¿Ƽؿʤ⤦.
ȡǰΰ٤

 named-checkconf -z

Ȥ⤷Ƥ(顼ǤϤ. ܤϸ.).

½

ޤǤκȤԤ.
ޤΰ̣Ҥ٤(listen-on ΰ̣Ĵ٤Ƥ).

named.conf zone

ޤnamed.conf ˤ zone Ȥܤ.
줬ּʬ륾(ɥᥤȻפäƤ褤)ˤĤƤξפꤹȤ.
ɤߤʬ褦ˡŪʤȤ named.conf ˤϤۤȤɤʤ̤

 file "named.root";

ʤɤȤɤ߹褦ˤʤäƤ.

ơˤޤǤ named.conf Ǥ zone ˤĤ褦.
zone ܤϰ̤

 zone "̾(ɥᥤ̾)" {
   type Υ;
   masters { ޥФ IPɥ쥹 };  󥿥פ slave ξ
   file ŪƤ񤤤Ƥե̾;
   };

Ȥ򤷤Ƥ.

̾Ϥޤ狼.

Υפϡ hint(롼ȥѤ̤ʤΤȻפäƤ褤)*10, master(ʬޥФǤ뤳Ȥ̣), slave(ʬ졼֥ФǤ뤳Ȥ̣) 3ȻפäƤФ褤.

masters ϡʬ졼֥ФǤˡǡ򤯤ޥФꤹ뤿ˤ.

file ϡʬޥФξϼʬǺꡤmaster ǥ쥯ȥβ֤.
ʬ졼֥Фξ硤slave ǥ쥯ȥβ˥ԡƤΤǡե̾ˤƤ.

ơǥեȤߤȡǤ 3Ĥ̤ zone ꤵƤ.

Ƥɤɤȡzone "0.0.127.IN-ADDR.ARPA"*11 zone "1.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.IP6.ARPA"*12꤬񤫤ƤϤΥե master/localhost.rev master/localhost-v6.rev"¸ߤƤʤȤ˵Ť.
ǤޤϤΥե.
ȤϤäƤȤ˹ͤɬפϤʤơroot

 cd /etc/namedb
 sh ./make-localhost

ȤмưŪˤΥե뤬褦ˤʤäƤΤǡ褦.

ǤȤꤢǥե +ե ѤϤʤΤǡޤ

 named-checkconf -z 

Ȥơ顼Ǥʤå褦.

¤εưå

Ȥꤢ BIND Ϻ¤ưϤ.

ȤȤǡ/etc/resolv.conf nameserver ܤ

 nameserver 127.0.0.1

Ƚ/etc/rc.conf

 named_enable="YES"

Ŭڤʾ˽񤭹ǥ֡Ȥ褦*13.

ơưޤ

 ps -axuww | grep /sbin/named

ȤƤߤ褦.

 /usr/sbin/named -t /var/named -u bind

ȤΤСϤҤȤޤޤäƤ.

ˡ

 dig www.osaka-u.ac.jp

ʤɤȤƤߤ. ΤȤ

 ; <<>> DiG 9.3.3 <<>> www.osaka-u.ac.jp
 ;; global options:  printcmd
 ;; Got answer:
 ;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 54421
 ;; flags: qr rd ra; QUERY: 1, ANSWER: 1, AUTHORITY: 5, ADDITIONAL: 3
 
 ;; QUESTION SECTION:
 ;www.osaka-u.ac.jp.             IN      A
 
 ;; ANSWER SECTION:
 www.osaka-u.ac.jp.      259111  IN      A       133.1.8.18
 
 ;; AUTHORITY SECTION:
 osaka-u.ac.jp.          259111  IN      NS      vanilla-ice.odins.osaka-u.ac.jp.
 osaka-u.ac.jp.          259111  IN      NS      ns.osaka-u.ac.jp.
 osaka-u.ac.jp.          259111  IN      NS      ns1.ai3.net.
 osaka-u.ac.jp.          259111  IN      NS      name-server.suita.odins.osaka-u.ac.jp.
 osaka-u.ac.jp.          259111  IN      NS      vanilla-ice.gw.osaka-u.ac.jp.
 
 ;; ADDITIONAL SECTION:
 ns1.ai3.net.            23282   IN      A       202.249.24.33
 name-server.suita.odins.osaka-u.ac.jp. 107664 IN A 133.1.119.1
 vanilla-ice.odins.osaka-u.ac.jp. 107664 IN A    133.1.192.4
 
 ;; Query time: 0 msec
 ;; SERVER: 127.0.0.1#53(127.0.0.1)
 ;; WHEN: Thu Jan 24 21:07:10 2008
 ;; MSG SIZE  rcvd: 234
 

ʤɤȤʤꡤ(ݤ) 127.0.0.1Ĥޤ꼫ʬȤ DNS ФȤ䤤碌Ȥ狼*14.
ǡʤȤ BIND ưǧǤ.

BIND ǥ

ơBIND ܼŪŻǤ롤(ɥᥤ)򤷤Ƥߤ褦.
ǤϡƼΥޥǼºݤ˥֥ɥᥤäƴ褦 BIND ꤷƤߤ褦.
ޤơΥ֥ɥᥤϼΤ褦ʤΤȤ.

Ȼ/03 ͥåȥ PC ֹȤˡ

֥ɥᥤ̾subPCֹ.cl.math.sci.osaka-u.ac.jpե٥åȤ "sub" ֹˤĤ. ξ 0 ĤƤΤ. 㤨СPC ֹ椬 08 ξ硤sub08 Ǥ.
Ȥ IP192.168.125.105+(5*PCֹ) 192.168.125.109+(5*PCֹ) 5ĤɬפϤʤ.
졼֥ïƤͤȤǡοͤΥФȤ졼֥Фϲ椢äƤ褤Τǡ3͡4ͤȤǤʤ

Ȥ褦.

ޥФ - named.conf

㤨СPC ֹ椬 17 ΥޥǤ

 zone "sub17.cl.math.sci.osaka-u.ac.jp" {
         type master;
         file "master/sub17.zone";
 };

Ȥäơzone "sub17.cl.math.sci.osaka-u.ac.jp" δʬ(ޥФȤ)Ԥ! .

󡤤ä

 named-checkconf

ȤƥåƤ.

ޥФ - ե

ơοΥեǤ뤬ξȡmaster/sub17.zone Ȥʤ.
ǡ˼ưŪ˺Ƥե򻲾Ȥƺ.

 cd /etc/namedb
 cd master
 cp localhost.rev sub17.zone

ȤƿѰդ. 줫顤sub17.zone ŬԽơǤ

 $TTL    3600
 @       IN      SOA     q17.cl.math.sci.osaka-u.ac.jp. root.q17.cl.math.sci.osaka-u.ac.jp.  (
                                 2008012403      ; Serial
                                 3600    ; Refresh
                                 900     ; Retry
                                 3600000 ; Expire
                                 3600 )  ; Minimum
         IN      NS      q17.cl.math.sci.osaka-u.ac.jp.
 test01  IN      A       192.168.125.190

ʤɤȤ.
ʤߤˡNS A ʤɤǤʤȤޤ褦.
ޤNS FQDN ǽ񤯤ȤȤˤդ褦.

ơ zone եȤƤϺ¤Ǥ뤬ȤꤢưϤǤ.

zone եνǤ뤬ʸƬ SOA ; Minimum ޤǤϤȤꤢ饳ԡΤ򴫤.
ޤޤ굤ˤʤƤ褤Τ SOA Ȥΰ̣ϼȻ˸Ƭ뤬Ĥ SOA ǽפʤΤƤ.
SOA Serial ͤǤ.
ϡΥեΡֿפ򼨤ͤǡ줬礭ʤȥե뤬줿ȤȤʤꡤͥåȥ˹줿ή뤳Ȥˤʤ.
ĤޤꡤեԽ, ɬ Serial ͤ䤷ƤʤȤʤ*15.

ˡΤˤĤƤϡޤĤιܤΤäƤפ.

ƹԤν̾ IN 쥳̾ Ƚ񤫤뤳ȤˤʤäƤ
@named.conf ǻꤷΥ̾. sub17.cl.math.sci.osaka-u.ac.jp. Ȥʤ.
񤤤ƤʤȤ@ Ȳᤵ. ʬˤIN NS q17.cl.math.sci.osaka-u.ac.jp. ιƬ.
.ǽäƤʤޥ̾.@

ơ zone եå褦.

 named-checkzone ̾  åե

ȤХåǤ. Ǥϡ

 named-checkzone sub17.cl.math.sci.osaka-u.ac.jp ./sub17.zone

Ȥơ顼ǤʤФ褤.

ޤä顤BIND եɤľ褦. ˤ

 rndc reload

ȤФ褤.

ơưǧ褦. ˤϡ¾Υޥ󤫤餳ξ

 dig test01.sub17.cl.math.sci.osaka-u.ac.jp

ʤɤȤ

 ;; ANSWER SECTION:
 test01.sub17.cl.math.sci.osaka-u.ac.jp. 2959 IN A 192.168.125.190

Ф褤.

졼֥Ф

ˡ졼֥Ф򤷤Ƥߤ褦.
ϥޥñǤ.

㤨Сsub16.cl.math.sci.osaka-u.ac.jp ɥᥤ(ޥФ q16.cl...) Υ졼֥Ф q17 Ȥ褦.
λ˹Ԥ󥫽Ǥ.

ޥ¦Υե˥졼֥Ф NS ȤƲä.

Ūˤϡ

 IN  NS  q17.cl.math.sci.osaka-u.ac.jp.

򥵡 q16 Υե˲äƤǤ(쥳 A ˽񤤤Ƥ).

졼¦ named.conf ǥ졼֥򤹤

q17 named.conf

 zone "sub16.cl.math.sci.osaka-u.ac.jp" {
         type slave;
         masters { 192.168.125.106; };  q16 Υɥ쥹
         file "slave/sub16.zone";
 };

Ƚ񤭲äǤ. "slave/sub16.zone" ȤեϾ˥ԡƤΤǺäꤤäꤷʤƤ褤(ȤäƤϤʤ).

½

ïȤǡ졼֥ޤǹԤ.
ޤưǧԤäƤߤ.

Ūˤϡ/ưޤǤǤȻפä顤Ǹ¾Υޥ󤫤

 dig -t NS sub16.cl.math.sci.osaka-u.ac.jp

ʤɤȤƤߤơsub16.cl.math.sci.osaka-u.ac.jp NS ȤơꤷʣΥФɽ뤳ȤǧФ褤*16.

հ

ϼ¤ϡֿƥФλ/פ礭ѤäƤΤǤޤŪǤʤ ΤǤȤꤢάƤ

ݡ

ޤǤκȤԤʤġƤİ.
NS, A 쥳ɤꤷʤäMX ꤷƤߤ.
ޤ5Ĥ IP ȤäƤߤ.


*1 ĤޤꡤհѤΥɥᥤ
*2 IP ɥ쥹ϡֺ¦礭ʥ롼פǡ¦ۤɺ٤פǡۥ̾ϤεդǤ뤿
*3 䤤碌פ쥳 "PTR" ˤƤ. "ANY" ˤƤ褤.
*4 dig ޥɤϡǥեȤǤ search ץ̵뤹뤳ȤΤ, +search ȤƤ
*5 ޤޤ dig DNS 򸫤ȤˡɤΥɥᥤôФʣäȤפФ
*6 򥾡žȤ.ž DNS ФλŻʤΤǡʹ֤򲼤ɬפäˤʤ.
*7 ҤϿƤľΤɬפϤʤ. ʤʤ־(롼ȥ13)餿ɤкѤΤ.
*8 ǤΤѤ륵֥ɥᥤʤɤͤ. 󡤤ξϤΥ֥ɥᥤȤäƳ饢뤳ȤϤǤʤ.
*9 ʤĤ뤳Ȥڤ. ïˤȤä? Ϥ󷯤ˤȤäƤ.
*10 Τˤϡ־ǤĤޥǤ⥹졼֤Ǥʤ֡פȤȤ.
*11 ʬ 127.0.0.1 ""ɥᥤεհ
*12 ʬȤ""ɥᥤεհ IPv6
*13 Τ named_flags ˤꤷʤȤʤäϥǥեȤ bind 桼 chroot ΤǡǤ褤.
*14 ºݤΤʤ 192.168.125.14 ǤƤ櫓
*15 Emacs Ȥäƥե zone ⡼ɤԽȡSerial ͤưŪ. ꤬
*16 ¾ˤ⡤졼֥Ф /etc/namedb/slave ˥ԡƤϤΥեľįƤߤȤ⤢