§Ú̪¾¹D¹q¸£ºô¸ô¨t²Î¥u»{ÃѩҿתºIP¡A¦ý¬O¡A±z¥i¯à°O±o¦íºô¸ô¤W±©Ò¦³¥D¾÷ªºIP¶Ü¡H´N³¾ô¨Ó»¡¡A³s¦Û¤vªº¥D¾÷ªºIP³£°O¤£°_¨Ó¤F¡A«ç»ò¥i¯à³s¨ä¥Lªº¥D¾÷IP³£°Oªº¦í¡I¦]¬°¡A¤H¸£¹ï©ó¼Æ¦r²Õ¦¨ªºIPªº°O¾Ð¹ê¦b¬O......¤£«ç»ò¼Ë¡C¦ý¬O¡A¬Û¹ï¨Ó»¡¡A¤H̹ï©ó¥Ñ¤å¦r©Ò²Õ¦¨ªº¥D¾÷¦WºÙ¨º¥i¥H®e©ö°O¾Ðªº¦h¤F¡ã©Ò¥H¡A¤~·|µo®i¥X¥i¥H¸g¥Ñ¥D¾÷¦WºÙ(hostname)¹ïÀ³¨ì¹q¸£IPªº¤@Ó¼Ò¦¡¡A³o¼Ë§ÚÌ´N¥i¥H»´»´ÃPÃPªº°O¦í¥D¾÷¦WºÙ§Y¥i¡A¹q¸£IP¨º´N¥æµ¹Domain Name System(DNS)¥h·d©w§a¡I ¨ºÓDNS¨t²Î¬O¥Ñ¬f§JµÜ¤j¾Çµo®iªºbind³oÓ®M¥ó(Berkeley Internet Name Domain)©Ò´£¨Ñªº°Õ¡I°ò¥»¤W¡ADNS³Ì¥Dnªº¤u§@´N¬O±NHostname¹ïÀ³¨ìIP³oÓ¥\¯à¤F¡A¤£¹L¡An¬[³]¤@Ó¦¨¥\ªºDNS¥D¾÷ªº¸Ü¡AÁÙ±on¹ï©óDNSªº¹B§@«Ü²M·¡¤~¦æ°Ú¡I§_«h¬[³]ªº¤£¹ï¡AÁ٤Ϧӷ|³y¦¨¤j®aªº°ÝÃD³á¡I³oÓ³¹¸`·í¤¤¡An¾Ç·|ªº¸ê®Æ¨ä¹êÁÙÆZ¦hªº¡A»ÝnÁA¸Ñ¡G¤°»ò¬O¥¿¸Ñ¡B¤°»ò¬O¤Ï¸Ñ¡B¤°»ò¬OZone¡B«È¤áºÝ(Client)¬O¸g¥Ñ¤°»ò©N©N¨Ó¬d¸ß±o¨ìIPªº©O¡H¡I¥H¤ÎDNSªº±ÂÅv°ÝÃDµ¥µ¥¡C«z¡I»°§Ö²M¤@²M¸£ªù¡An¦n¦nªº¥Î¥\Åo¡I^_^ |
/etc/hosts¡Gª½±µ¦bClientºÝªºÀɮפº¿é¤J¥D¾÷¦WºÙ¹ïÀ³ªºIP¨Ó¬d¸ß¡FDNS¨t²Î ¡G§Q¥ÎÃB¥~ªºDNSªA°È¡AÅýClientºÝ¥i¥H³z¹L¦WºÙ¸ÑªR¨Ó¨ú±o¥Øªº¦a¥D¾÷ªºIP |
³¾ô¡B¥_°Ï¡B¥x«n ³¾ô¡B¤¤°Ï¡B¥x«n ³¾ô¡B¥x¥_ ...... |
¦WºÙ | ¥Nªí·N¸q |
com | ¤½¥q¡B¦æ¸¹¡B¥ø·~ |
org | ²Õ´¡B¾÷ºc |
edu | ±Ð¨|³æ¦ì |
gov | ¬F©²³æ¦ì |
net | ºô¸ô¡B³q°T |
mil | x¨Æ³æ¦ì |
[root@linux ~]# rpm -qa | grep bind bind-utils-9.2.4-16.EL4 <==³oÓ¬O¥Î¤áºÝ·j´M¥D¾÷¦WºÙªº¬ÛÃö«ü¥O bind-9.2.4-16.EL4 <==³oÓ¤~¬O DNS ¦øªA¾¹¥Dµ{¦¡ bind-chroot-9.2.4-16.EL4 <==±N bind ¥Dµ{¦¡Ãö¦b®a¸Ì±¡I ^_^ |
[root@linux ~]# vi /etc/sysconfig/named ROOTDIR=/var/named/chroot |
[root@linux ~]# vi /etc/named.conf // ÁöµM CentOS ±N³oÓÀɮשñ¸m¨ì /var/named/chroot/etc ·í¤¤¡A // ¤£¹L¥L«Ü¦n¤ßªºÀ°§Ú̧@¤FÓ³sµ²¡A©Ò¥H§AÁÙ¬O¥i¥Hª½±µ½s¿è³oÓÀÉ®×°Õ¡I options { directory "/var/named"; dump-file "/var/named/data/cache_dump.db"; statistics-file "/var/named/data/named_stats.txt"; pid-file "/var/run/named/named.pid"; forward only; //¥u¤¹³\ forward! forwarders { 168.95.1.1; //§Ú³o¸Ì¨Ï¥Î hinet ªº DNS ¡I 139.175.10.20; //³oÓ¬O seednet ªº DNS ¡I }; }; include "/etc/rndc.key"; |
[root@linux ~]# ls -ald /var/named/chroot/var/run/named drwxrwx--- 2 named named 4096 Oct 12 11:48 /var/named/chroot/var/run/named |
[root@linux ~]# /etc/init.d/named start
Starting named: [ OK ]
|
[root@linux ~]# netstat -utln
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address Foreign Address State
tcp 0 0 192.168.1.254:53 0.0.0.0:* LISTEN
tcp 0 0 127.0.0.1:53 0.0.0.0:* LISTEN
udp 0 0 192.168.1.254:53 0.0.0.0:*
udp 0 0 127.0.0.1:53 0.0.0.0:*
|
[root@linux ~]# tail -n 15 /var/log/messages | grep named
Oct 16 15:08 linux named[76]: starting BIND 9.2.4 -u named -t /var/named/chroot
Oct 16 15:08 linux named[76]: using 1 CPU
Oct 16 15:08 linux named[76]: loading configuration from '/etc/named.conf'
Oct 16 15:08 linux named[76]: listening on IPv4 interface lo, 127.0.0.1#53
Oct 16 15:08 linux named[76]: listening on IPv4 interface eth0, 192.168.1.254#53
Oct 16 15:08 linux named[76]: command channel listening on 127.0.0.1#953
Oct 16 15:08 linux named[76]: command channel listening on ::1#953
Oct 16 15:08 linux named[76]: running
Oct 16 15:08 linux named: named startup succeeded
|
§@·~¨t²Î»P IP | ¹ïÀ³¤§¥D¾÷¦WºÙ | »¡©ú |
OS: Linux IP: 192.168.1.254 | linux.vbird.tsai www.vbird.tsai ftp.vbird.tsai forum.vbird.tsai | ³o³¡¬O¥Dnªº DNS ¦øªA¾¹¡A¥Dn¥D¾÷¦WºÙ¬° linux.vbird.tsai ¡A¨ä¥Lªº¤T³¡¥D¾÷¦WºÙ¬°¥D¾÷§O¦W¡C |
OS: Linux IP: 192.168.1.150 | slave.vbird.tsai | ¥Dn§@¬° slave DNS ¥D¾÷¡A ¬ÛÃöªº slave ³]©w±N¦b¤UÓ¤p¸`¤~·|¤¶²Ðªº°Õ¡I |
OS: Windows XP IP: 192.168.1.100 | winxp.vbird.tsai | ¬Y¤@³¡¥D¾÷ªº IP »P¥D¾÷¦WºÙ¹ïÀ³ |
OS: Sun IP: 192.168.1.200 | sun.vbird.tsai | ¬Y¤@³¡¥D¾÷¡A¥Î¨Óª±ªº¦Ó¤w¡I |
[root@linux ~]# vi /etc/named.conf // ¥ý©w¸q¥X¾ãÓ DNS ¦øªA¾¹ªº¬ÛÃöÀô¹Ò¡A¥]¬A¬d¸ß¡BÀɮשñ¸m¥Ø¿ýµ¥ options { directory "/var/named"; dump-file "/var/named/data/cache_dump.db"; statistics-file "/var/named/data/named_stats.txt"; pid-file "/var/run/named/named.pid"; forwarders { 168.95.1.1; 139.175.10.20; }; allow-query { any; }; // ¬O§_¤¹³\³Q¬d¸ß¡H·íµMn¥i¥H³Q¬d¸ß¡F allow-transfer { none; }; // ¬O§_¤¹³\¶Ç°e zone ¡A¹w³]¤£¥i }; // Ãö©ó DNS ¦øªA¾¹ªº¤@¨Ç¥[±K¸ê®Æ¡A¥ý©¿²¤¹L¥h¥ý¡I include "/etc/rndc.key"; // Ãö©ó root (.) ªº³]©w³á¡G zone "." { type hint; // ¯S®íªºÃþ§O¡I±Mµ¹ root (.) ¥Îªº file "named.root"; // ´N¬OÀɦWªº©w¸q°Õ¡I }; // Ãö©ó¥»¾÷ localhost ªº¥¿¤Ï¸Ñ zone "localhost" { type master; file "named.localhost"; }; zone "0.0.127.in-addr.arpa" { type master; file "named.127.0.0"; }; // ³o¸Ì³W½d¥X§Ú̪º vbird.tsai »â°ì¦W zone "vbird.tsai" { type master; file "named.vbird.tsai"; }; zone "1.168.192.in-addr.arpa" { type master; file "named.192.168.1"; }; |
options¤ºªº¬ÛÃö°Ñ¼Æ»¡©ú | |
³]©wÈ | ·N¸q |
directory | ³oÓ³]©wÈ´N¬O¦b«ü©w§Aªºzone filen©ñ¸m¨ìþӥؿý°Õ¡I«D±`«nªº³]©wÈ¡C»P©³¤Uzone³]©w¶µ¥Øªºfile°t¦X¦Ó¦¨§¹¾ãÀɦW¡C |
dump-file | ¥Ñ¹Ï¤T§Ú̪¾¹DDNS¦øªA¾¹·|±N·j´M¨ìªº¥D¾÷IP¹ïÀ³¸ê®Æ©ñ¸m¨ì§Ö¨ú°O¾ÐÅ餤¡A¨º¦pªG§A·Qn±N¥Ø«eªº§Ö¨ú¸ê®Æ°O¿ý¤U¨Ó®É¡A´N¥Î³oÓ³]©wÈ«ü©wÀÉ®× |
statistics-file | §ÚÌDNSªº¤@¨Ç²Îp¸ê®Æ¡A·Qn¦C¥X®É´N¼g¤J³oÓ³]©wÈ«ü©wªºÀɦW¤º |
pid-file | ±Nnamed³oÓµ{¦¡ªºPID°O¿ý¤U¨Óªº¤@ÓÀɮסA³oÓÀɮ׳q±`¥i¥H¦bnamed±Ò°Ê¡BÃö³¬®É´£¨Ñ¥¿½TªºPID°Õ¡I |
forwarders | «e±½Í¨ìcache-onlyªºDNS¦øªA¾¹³]©wȤw¸g½Í¹L¤F¡A½Ð«e©¹°Ñ¦Ò¡C |
allow-query | ¬O§_¤¹³\¥Î¤áºÝªº¬d¸ß¡C¬d¸ßªº«ÂI´N¬OŪ¨ú¸ê®Æ®wªº¤º®e¡A¬JµMn¬[³]DNS¡A·íµMn¤¹³\¥Î¤áºÝªº¬d¸ß°Õ¡C¤º®e¥i¥H¶ñ¼g¥ô¦ó¨Ó·½(any)©ÎIP©Îºô°ì(IP/netmask)ªº®æ¦¡¡C |
allow-transfer | ¬O§_¤¹³\slave DNSªº¾ãÓ»â°ì¸ê®Æªº¶Ç°e¡H³oÓ³]©wÈ»Pmaster/slave DNS¦øªA¾¹¤§¶¡ªº¸ê®Æ®w¶Ç°e¦³Ãö¡C°£«D§A¦³slave DNS¦øªA¾¹¡A§_«h³o¸Ì¤£n¶}©ñ³á¡I |
zone¤ºªº¬ÛÃö°Ñ¼Æ»¡©ú | |
³]©wÈ | ·N¸q |
type | ¸ÓzoneªºÃþ«¬¡A¥DnªºÃþ«¬¦³¡Gmaster,slave¤Îhint¡C¨ä¤¤»Ýnª`·N³Ì¤W¼hªºDNS(.)¨Ï¥Îªº¬OhintªºÃþ«¬¡AµM«ámaster¥D¾÷¥Îmaster°Ú¡Islave¥D¾÷´N¥Îslave£v£°¡I |
file | ´N¬Ozone file°Õ¡I¨º»ò§¹¾ãªºzone file¦bþ¸Ì°Ú¡H¦b³o¸Ì¡G
/var/named/chroot/var/named/named.root |
¤Ï¸Ñzone | ¥¿¸Ñªºzone«Ü¦n²z¸Ñ¡A¤Ï¸Ñªºzone«ç»ò¨º»ò©_©Ç°Ú¡H´N¦p¦Plinux.vbird.orgn°lÂܮɬO¥Ñorg->vbird->linux¤@¼Ë¡A¦Ü©ó¤Ï¸Ñ«h¨Ò¦p192.168.1.1: 192->168->1->1¡C¥Ñ©óDNSªº»â°ì¦WºÙ³£¬O¥Ñ«á©¹«e§ä¡A¥B¤Ï¸Ñ¬OÓ¯S®íªº»â°ì¡A©Ò¥H¥²»Ýn±NIP¤Ï¹L¨Ó¼g¡A¦P®É¦b³Ì«á±¥[¤W¡y.in-addr.arpa¡z¨Óªí¥Ü¤Ï¸Ñ«Å§i¡I©Ò¥H192.168.1³oÓzone´N±on¼g¦¨1.168.192.in-addr.arpa |
[root@linux ~]# vi /var/named/chroot/var/named/named.root ; ©êºp¡Aª©Åv«Å§i³¡¤À¥ý¬Ù²¤¡ã . 3600000 IN NS A.ROOT-SERVERS.NET. A.ROOT-SERVERS.NET. 3600000 A 198.41.0.4 ;¥D¾÷¦WºÙ©Î»â°ì¦WºÙ TTL RR ¬Û¹ïÀ³ªº¸ê®Æ ; ¥H¤U¬Ù²¤ |
[root@linux ~]# vi /var/named/chroot/var/named/named.localhost ; 1. º¥ý¬O¥D¾÷¬ÛÃöªº³]©w $TTL 600 ; 2. Ãö©ó master/slave ªº±ÂÅv¤º®e¡A¦pªG¨S¦³ slave ¥D¾÷¡A¨ÌÂÂn³]©w³á¡I @ IN SOA localhost. root.localhost. ( 2006102001 ; Serial ¶È§@¬°§Ç¸¹¦Ó¤w 28800 ; Refresh slave ¦øªA¾¹ªº§ó·s®É¶¡ 14400 ; Retry ·í slave ¥D¾÷§ó·s¥¢±Ñ¡A¦h¤[¦A«·s§ó·s¤@¦¸ 720000 ; Expire «½Æ retry ¦h¤[«á´N«Å§i¤£ªv....¤£¦A§ó·s 86400 ) ; Minimum ¥iµø¬° TTL ¡A¤×¨ä¬O§A¨S¦³³]©w $TTL ®É ; 3. ¥»»â°ìªº DNS ¦øªA¾¹ªº¥D¾÷¦WºÙ»P IP ªº¹ïÀ³ @ IN NS localhost. ; ¯S§O¯d·N³Ì«á±ªº¨ºÓ¤p¼ÆÂI¡I localhost. IN A 127.0.0.1 ; 4. ¨ä¥L RR ¥i¥H¥[¤Jªº¦a¤è¡C |
Ãö©ó¥»»â°ìªº¤@¨Ç³]©wÈ | |
³]©wÈ | »¡©ú |
$TTL | ÁÙ°O±o¹Ï¤Tªº¬yµ{§a¡H·í¦³¥~³¡DNS¦øªA¾¹¹ï§AªºDNSªº³oÓ»â°ì¶i¦æ¬d¸ß®É¡A³o¤@µ§°O¿ý·|©ñ¸m¦b¹ï¤èDNS¦øªA¾¹¤º´X¬íÄÁªº·N«ä¡C |
$ORIGIN | ³oÓ³]©wÈ¥i¥H«·s«ü©wzoneªº©w¸q¡C¦b¹w³]ªº±¡ªp¤U¡A³oÓ¥¿¤Ï¸Ñ¸ê®Æ®wÀɮפ¤ªºzone¬O¥Ñ/etc/named.conf©Ò«ü©wªº¡A´N¬Ozone¨ºÓ°Ñ¼Æªº¥\¯à¡C¤£¹L¡A³oÓzone¬O¥i¥H§ïªº¡A´N¬O¥Î$ORIGIN¨Ó×q´N¬O¤F¡C³q±`³oÓ³]©wȤ£·|¥Î¨ìªº¡C |
Ãö©ómaster/slave±ÂÅv¤è±ªº³]©wÈ | |
²Å¸¹»PRR | »¡©ú |
@ | ³oӲŸ¹¥Nªízoneªº·N«ä¡I¥H¤W±ªºnamed.local¨Ó»¡¡A³oÓÀÉ®×¥Ñ/etc/named.conf©w¸q¥Xzone¬°localhost.¡A¦]¦¹¦b¥»Àɮתº@´N¥Nªílocalhost.Åo¡I |
. | ³oÓÂI(.)«Ü«n¡I¦]¬°¥L¥Nªí¤@Ó§¹¾ã¥D¾÷¦WºÙ(FQDN)¦Ó¤£¬O¶È¦³hostname¦Ó¤w¡CÁ|¨Ò¨Ó»¡¡A¦pªG§A¦b¥»³]©wÀɤW±³W½d¤@Ó¥D¾÷¦WºÙ¬°www®É¡A¨º³¡¥D¾÷ªºFQDN¬°www.localhost.¦pªG§A¼g¥Xwww.localhost®É¡A¥Ñ©ó¥½¤F¨S¦³¨ºÓ¤p¼ÆÂI¡A«hzone·|¥D°Ê¥[¤J¸Ó¥D¾÷¦WºÙ¡A©Ò¥H³Ì²×ªºFQDN·|Åܦ¨www.localhost.localhost.³á¡I |
SOA | Start of Authorityªº·N«ä¡C³oӼлx¥NªíµÛmaster/slave¬ÛÃöªº»{ÃÒ¡B±ÂÅv¸ê®Æ¡C¤£½×§AªºDNS¨t²Î¦³¨S¦³³]©wmaster/slaveªº¬[ºc¡A³£»Ýn§t¦³³oÓ³]©w¤~¦n¡CSOA«á±¦@±a¦³¤TӰѼơA©Ò¥H¸Ó¦æ¬°¡G
|
DNS¦Û¤vªº»â°ì¤§¦WºÙ¸ÑªR¾¹ | |
²Å¸¹»PRR | »¡©ú |
NS | ´N¬Oname serverªºÁY¼g¡A³oӼлxªº°Ñ¼Æ¬O¡G
|
A | ¬O¥¿¸Ñªº²Å¸¹¡A°Ñ¼Æ¬O¡G
|
[root@linux ~]# vi /var/named/chroot/var/named/named.vbird.tsai $TTL 600 @ IN SOA linux.vbird.tsai. root.linux ( 2006102001 28800 14400 720000 86400 ) ; ¥»»â°ìªº DNS ¦øªA¾¹ªº¥D¾÷¦WºÙ»P IP ªº¹ïÀ³ @ IN NS linux.vbird.tsai. @ IN NS slave.vbird.tsai. linux IN A 192.168.1.254 slave IN A 192.168.1.150 @ IN MX 10 linux ; ¨ä¥L RR ¥i¥H¥[¤Jªº¦a¤è www IN CNAME linux ftp IN CNAME linux forum IN CNAME linux winxp IN A 192.168.1.100 sun IN A 192.168.1.200 sun IN TXT "The sun solaris OS" sun IN HINFO "Celeron 1G""Solaris 10" |
Ãö©ó¥¿¸Ñªº¨ä¥LRR¼Ð»x | |
²Å¸¹»PRR | »¡©ú |
MX | ´N¬OMail eXchanger(MX)ªºÂ²¼g¡A¥Lªº°Ñ¼Æ¬O³o¼Ë¼gªº¡G
¦pªG§A¤£ª¾¹D¦p¦ó³]©w¡A³q±`«Øij§Aª½±µ³]©w¦¨§Aªºmail server¥D¾÷¦WºÙ§Y¥i |
CNAME | ÅU¦W«ä¸q¡A³oӼлx¦b«Ø¥ß¡y¥D¾÷§O¦W¡zªº°Õ¡I°Ñ¼Æ¬°¡G
|
TXT | ³oÓªF¦è¦b¶i¦æ¡y»¡©ú¡z¦Ó¤w¡I¥ç§Y¬O«e±¨º³¡¥D¾÷ªº¤@¨Ç¸ê°T¡C¯S§Oª`·Nªº¬O¡A¨S¨Æªº¸Ü¡A¡y¸ê°T¤£n¼g±o¤Ó¸Ô²Ó¡A¦³ªº®ÉԬƦÜÀ³¸Ón¼g¨Ç¿ù»~ªº°T®§¡I¡z¬°¤°»ò©O¡H¦pªG¼g±o¤Ó¸Ô²Óªº¸Ü¡A¨º»ò¨º¨ÇÓcracker¤£´N«Ü²³æªº´N¥i¥H±N±zªººô¯¸¸ê°T¨ú±o¡A¨Ã¶i¦Ó¤J«I¤F¶Ü¡H@_@ |
HINFO | ³oÓªF¦è«á±±µ¨âÓ©N©N¡A²Ä¤@Ó±µªº¬OµwÅ骺µ¥¯Å¡A²Ä¤GÓ±µªº«h¬O§@·~¨t²Î¡A³o¨âÓ©N©N³Ì¦n¤£n¥Î¦b¤½¶}ªºDNS¥D¾÷¤W±¡A¸òTXT¤@¼Ëªº°ÝÃD°Õ¡I¦pªGn³]©wªº¸Ü¡A³Ì¦n¨Ï¥ÎÂù¤Þ¸¹¤À¹j¶}¨Ó³á¡I |
[root@linux ~]# vi /var/named/chroot/var/named/named.127.0.0 $TTL 600 @ IN SOA localhost. root.localhost. ( 2006102001 28800 14400 720000 86400 ) ; ¥»»â°ìªº DNS ¦øªA¾¹ªº¥D¾÷¦WºÙ»P IP ªº¹ïÀ³ @ IN NS localhost. 1 IN PTR localhost. |
Ãö©ó¤Ï¸ÑªºRR¼Ð»x | |
²Å¸¹»PRR | »¡©ú |
PTR | PointerªºÂ²¼g¡A¥Lªº°Ñ¼Æ¬O³o¼Ë¼gªº¡G
¨º»ò¸U¤@¤µ¤Ñ§Ú̳W¹ºªº¬OB Classªºzone©O¡H¨Ò¦p127.0³o¼Ëªºzone©O¡H«Ü²³æ°Õ¡I´N¶ñ¨âӼƦr§Y¥i¡I¤]´N¬O0.1Åo¡I ³Ì«nªº¦a¤è´N¬O¡G«á±ªº¥D¾÷ºÉ¶q¨Ï¥Î§¹¾ãFQDN¡A¥ç§Y¥[¤W¤p¼ÆÂI(.)¡I¬°¤°»ò©O¡H¦]¬°¤Ï¸Ñªºzone¬O0.0.127.in-addr.arpa¡A©Ò¥H¦pªG§A¼g¦¨localhost®É¡A§Aªº³oÓIP¹ïÀ³ªº¥D¾÷¦WºÙ±N·|Åܦ¨¡Glocalhost.0.0.127.in-addr.arpa¤§Ãþªº©Ç²§¥D¾÷¦WºÙ°Ú¡I |
[root@linux ~]# vi /var/named/chroot/var/named/named.192.168.1 $TTL 600 @ IN SOA linux.vbird.tsai. root.linux.vbird.tsa. ( 2006102001 28800 14400 720000 86400 ) ; ¥»»â°ìªº DNS ¦øªA¾¹ªº¥D¾÷¦WºÙ»P IP ªº¹ïÀ³ @ IN NS linux.vbird.tsai. @ IN NS slave.vbird.tsai. 254 IN PTR linux.vbird.tsai. 150 IN PTR slave.vbird.tsai. ; ¨ä¥L RR ¥i¥H¥[¤Jªº¦a¤è¡C 100 IN PTR winxp.vbird.tsai. 200 IN PTR sun.vbird.tsai. |
[root@linux ~]# /etc/init.d/named start <==¤]¥i¯à¬O»Ýn restart ³á |
[root@linux ~]# tail -n 20 /var/log/messages | grep named named[28]: starting BIND 9.2.4 -u named -t /var/named/chroot # ¥Ñ³oÓ»¡©ú§ÚÌ¥i¥Hª¾¹D chroot ªº¥Ø¿ý»P named ±Ò°Êªº°Ñ¼Æµ¥¸ê®Æ named[28]: using 1 CPU named[28]: loading configuration from '/etc/named.conf' # ¥Ñ³oÓ»¡©ú¡A¥iª¾¹D¥Dnªº³]©wÀɬO¥Ñþ¸Ì¸ü¤Jªº¡I°O±o¥[¤W chroot named[28]: listening on IPv4 interface lo, 127.0.0.1#53 named[28]: listening on IPv4 interface eth0, 192.168.1.254#53 named[28]: command channel listening on 127.0.0.1#953 named[28]: command channel listening on ::1#953 # ¥Ñ³oÃä¥i¥H¬d¥X DNS ¬ÛÃöªºªA°È¦bþ´XÓ¤¶±¦³´£¨Ñ¡I # ¦Ü©ó¨ºÓ command §Ú̱N¦b«á±¦AÄ~Äò»¡©ú¡C named[28]: zone 0.0.127.in-addr.arpa/IN: loaded serial 2006102001 named[28]: zone 1.168.192.in-addr.arpa/IN: loaded serial 2006102001 named[28]: zone localhost/IN: loaded serial 2006102001 named[28]: zone vbird.tsai/IN: loaded serial 2006102001 # °O±on¦³³o¨Ç loaded serial ªº¸ê®Æ¡A¨Ã¥B¤£¯à¥X²{¥ô¦ó¿ù»~³á¡I named[28]: zone vbird.tsai/IN: sending notifies (serial 2006102001) named[28]: zone 1.168.192.in-addr.arpa/IN: sending notifies (serial 2006102001) # ³oÓ«h¬O¹ï©ó¥~³¡¦³¨ä¥L slave DNS ®É¡A·|µo°eª`·N°T®§ªº»¡©ú¡C |
named: /etc/named.conf:11: missing ';' before '}' # ª`·N¨ì¤W±´£¨ìªºÀÉ®×»P¼Æ¦r¶Ü¡H»¡©úªº¬O /etc/named.conf ªº²Ä 11 ¦æ¡A # ¦Ü©ó¿ù»~¬O¦]¬°¯Ê¤Ö¤À¸¹ (;) ©ÒP¡I¥h×¥¿¤@¤U§Y¥i¡C dns_rdata_fromtext: named.vbird.tsai:5: near eol: unexpected end of input zone vbird.tsai/IN: loading master file named.vbird.tsai: unexpected end of input # «üªº¬O named.vbird.tsai ªº²Ä¤¦æ¦³°ÝÃD¡A³q±`¬O SOA ¨º¤Ó¼Æ¦r¨S¦³§¹¥þ¡I # »°ºò¥h×q¤@¤U§Y¥i°Ú¡I dns_rdata_fromtext: named.vbird.tsai:12: near 'linux': not a valid number zone vbird.tsai/IN: loading master file named.vbird.tsai: not a valid number # »¡©ú²Ä 12 ¦æ¦b linux ªþªñ»Ýn¦³¤@Ó¦Xªkªº¼Æ¦r¡I»°ºò¥hÁ@Á@§ï§ï§Y¥i¡I |
[root@linux ~]# vi /etc/named.conf ....«e±¬Ù²¤.... zone "vbird.tsai" { type master; file "named.vbird.tsai"; allow-transfer { 192.168.1.150; }; }; zone "1.168.192.in-addr.arpa" { type master; file "named.192.168.1"; allow-transfer { 192.168.1.150; }; }; ....«á±¬Ù²¤.... |
[root@slave ~]# vi /etc/named.conf ....«e±¬Ù²¤.... zone "vbird.tsai" { type slave; file "named.vbird.tsai"; masters { 192.168.1.254; }; }; zone "1.168.192.in-addr.arpa" { type slave; file "named.192.168.1"; masters { 192.168.1.254; }; }; ....«á±¬Ù²¤.... |
[root@slave ~]# ls -l /var/named/chroot/var/named -rw-r--r-- 1 root root 229 Oct 18 14:44 named.127.0.0 -rw-r--r-- 1 root root 675 Oct 18 13:44 named.localhost -rw-r--r-- 1 root root 2517 Oct 18 00:34 named.root # ª`·N¡A¥un¤TÓÀɮקY¥i¡A¨ä¥L¨âÓ named.vbird.tsai »P # named.192.168.1 ¤£¥i¥H¦s¦b¡I§_«h·|¦³°ÝÃD°Ú¡I [root@slave ~]# ls -ld /var/named/chroot/var/named drwxr-x--- 4 named named 4096 Oct 19 01:17 /var/named/chroot/var/named # ª`·N¨ì¡A³oӥؿýªº¨Ï¥ÎªÌ¥²¶·n¬O named ¡AµM«á¤À¼Æ¦Ü¤Ö±o 750 ¤~¦æ¡I |
[root@slave ~]# /etc/init.d/named start [root@slave ~]# tail -n 20 /var/log/messages zone 1.168.192.in-addr.arpa/IN: transferred serial 2006102001 transfer of '1.168.192.in-addr.arpa/IN' from 192.168.1.254#53: end of transfer zone 1.168.192.in-addr.arpa/IN: sending notifies (serial 2006102001) zone vbird.tsai/IN: transferred serial 2006102001 transfer of 'vbird.tsai/IN' from 192.168.1.254#53: end of transfer zone vbird.tsai/IN: sending notifies (serial 2006102001) # ²z½×¤W¡A§AÀ³¸Ó·|¬Ý¨ì¦p¤Wªº¿é¥X¸ê°T¤~¹ï¡I¨t²Î·|§iª¾ zone file ªº¶Ç¿éµ²ªG [root@slave ~]# ls -l /var/named/chroot/var/named -rw-r--r-- 1 root root 229 Oct 18 14:44 named.127.0.0 -rw------- 1 named named 472 Oct 19 01:29 named.192.168.1 -rw-r--r-- 1 root root 675 Oct 18 13:44 named.localhost -rw-r--r-- 1 root root 2517 Oct 18 00:34 named.root -rw------- 1 named named 580 Oct 19 01:29 named.vbird.tsai |
1 dumping master file: tmp-XXXXEnDd9D: open: permission denied 2 transfer of 'vbird.tsai/IN' from 192.168.1.254#53: failed while receiving responses: permission denied 3 transfer of 'vbird.tsai/IN' from 192.168.1.254#53: end of transfer |
[root@linux ~]# vi /etc/nsswitch.conf
hosts: files dns
|
[root@linux ~]# vi /etc/resolv.conf
nameserver 192.168.1.254
nameserver 168.95.1.1
nameserver 139.175.10.20
|
»yªk¡G [root@linux ~]# host [-a] [FQDN] [server] [root@linux ~]# host -l [domain] [server] °Ñ¼Æ»¡©ú¡G -a ¡G¥Nªí¦C¥X¸Ó¥D¾÷©Ò¦³ªº¬ÛÃö¸ê°T¡A¥]¬A IP¡BTTL µ¥µ¥ -l ¡GY«á±±µªº¨ºÓ domain ³]©w¤¹³\ allow-transfer ®É¡A«h¦C¥X¸Ó domain ©ÒºÞ²zªº©Ò¦³¥D¾÷¦WºÙ¹ïÀ³¸ê®Æ¡I server¡G³oӰѼƥi¦³¥iµL¡A·í·Qn§Q¥Î«D /etc/resolv.conf ¤ºªº DNS ¥D¾÷ ¨Ó¬d¸ß¥D¾÷¦WºÙ»P IP ªº¹ïÀ³®É¡A´N¥i¥H§Q¥Î³oӰѼƤF¡I ½d¨Ò¤@¡G±j¨î¥H 192.168.1.254 ³o³¡ DNS ¥D¾÷¨Ó¬d¸ß [root@linux ~]# host www.vbird.tsai 192.168.1.254 Using domain server: Name: 192.168.1.254 Address: 192.168.1.254#53 <==³o¸Ì«n¡I§iª¾³oµ§°O¿ý¬Oþ³¡ DNS ¦øªA¾¹¥h§äªº¡I Aliases: www.vbird.tsai is an alias for linux.vbird.tsai. linux.vbird.tsai has address 192.168.1.254 |
½d¨Ò¤G¡G§ä¥X§Ú̦ۤv³oÓ vbird.tsai »â°ìªº©Ò¦³¥D¾÷¹ïÀ³ [root@linux ~]# host -l vbird.tsai 192.168.1.254 Using domain server: Name: 192.168.1.254 Address: 192.168.1.254#53 Aliases: vbird.tsai name server linux.vbird.tsai. vbird.tsai name server slave.vbird.tsai. linux.vbird.tsai has address 192.168.1.254 slave.vbird.tsai has address 192.168.1.150 ....«á±¬Ù²¤.... |
[root@linux ~]# host -l yahoo.com Host yahoo.com not found: 5(REFUSED) ; Transfer failed. |
»yªk¡G [root@linux ~]# nslookup [FQDN] [server] [root@linux ~]# nslookup °Ñ¼Æ»¡©ú¡G 1. ¥i¥Hª½±µ¦b nslookup ¥[¤W«Ý¬d¸ßªº¥D¾÷¦WºÙ©ÎªÌ¬O IP ¡A[server] ¥i¦³¥iµL¡F 2. ¦pªG¦b nslookup «á±¨S¦³¥[¤W¥ô¦ó¥D¾÷¦WºÙ©Î IP ¡A¨º±N¶i¤J nslookup ªº¬d¸ß¥\¯à ¦b nslookup ªº¬d¸ß¥\¯à·í¤¤¡A¥i¥H¿é¤J¨ä¥L°Ñ¼Æ¨Ó¶i¦æ¯S®í¬d¸ß¡A¨Ò¦p¡G set type=any ¡G¦C¥X©Ò¦³ªº¸ê°T¡y¥¿¸Ñ¤è±³]©wÀÉ¡z set type=mx ¡G¦C¥X»P mx ¬ÛÃöªº¸ê°T¡I ½d¨Ò¤@¡Gª½±µ·j´M winxp.vbird.tsai ªº IP ¸ê°T [root@linux ~]# nslookup winxp.vbird.tsai 192.168.1.254 Server: 192.168.1.254 Address: 192.168.1.254#53 <==¦P¼Ëªº¡A½Ðª`·N·j´Mªº DNS IP ³á¡I Name: winxp.vbird.tsai Address: 192.168.1.100 |
[root@linux ~]# nslookup <==¶i¤J nslookup ¬d¸ßµe± > 192.168.1.254 <==°õ¦æ¤Ï¸Ñªº¬d¸ß > www.vbird.tsai <==°õ¦æ¥¿¸Ñªº¬d¸ß # ¤W±³o¨âӶȦC¥X¥¿¤Ï¸Ñªº¸ê°T¡A¨S¦³Ô£¤F¤£°_ªº¦a¤è°Õ¡I > tw.yahoo.com <==°õ¦æ«D¥»¾÷¤Wªº¬d¸ß Server: 192.168.1.254 Address: 192.168.1.254#53 Non-authoritative answer: # ª`·N³oÃä¡A¦]¬°¤£¬O¦Û¤vªº¸ê®Æ®w¡A©Ò¥H¬O¥¼»{ÃÒ¹Lªº¸ê®Æ(¥i¯à¬O§Ö¨ú) tw.yahoo.com canonical name = tw.yahoo-ap1.akadns.net. tw.yahoo-ap1.akadns.net canonical name = vip1.tw.tpe.yahoo.com. Name: vip1.tw.tpe.yahoo.com Address: 202.43.195.52 > set type=any <==Åܧó¬d¸ß¡A¤£¬O¶È¦³ A¡A¥þ³¡¸ê°T³£¦C¥X¨Ó > sun.vbird.tsai Server: 192.168.1.254 Address: 192.168.1.254#53 Name: sun.vbird.tsai Address: 192.168.1.200 sun.vbird.tsai text = "The sun solaris OS" <==¬Ý§a¡I§ó¦h¸ê°T¶]¥X¨Ó¡I sun.vbird.tsai hinfo = "Celeron 1G" "Solaris 10" > exit <==Â÷¶}§a¡I¥Ö¥d¥C |
»yªk¡G [root @test root]# dig [@server] [FQDN] [type] °Ñ¼Æ»¡©ú¡G @server ¡G¦pªG¤£·Q¥H /etc/resolv.conf ¨Ó§@¬° DNS ¥D¾÷¡A«h¥i¦b¦¹¶ñ¤J¨ä¥Lªº IP type ¡G¹w³]¬O¬d¸ß A ¼Ð»x¡A§A¥i¥H¦b³o¸Ì¤J¨ä¥Lªº¼Ð»x¡A¦p mx, ns µ¥¡C ¦¹¥\¯à¥ç¥i¨Ï¥Î [-t type] ¨Ó³B²z¡C ½d¨Ò¤@¡G¬d¸ß linux.vbird.tsai §a¡I [root@linux ~]# dig @192.168.1.254 linux.vbird.tsai ; <<>> DiG 9.2.4 <<>> @192.168.1.254 linux.vbird.tsai ; (1 server found) ;; global options: printcmd ;; Got answer: ;; -;>>HEADER<<- opcode: QUERY, status: NOERROR, id: 8977 ;; flags: qr aa rd ra; QUERY: 1, ANSWER: 1, AUTHORITY: 2, ADDITIONAL: 1 ;; QUESTION SECTION: ;linux.vbird.tsai. IN A ;; ANSWER SECTION: linux.vbird.tsai. 600 IN A 192.168.1.254 ;; AUTHORITY SECTION: vbird.tsai. 600 IN NS slave.vbird.tsai. vbird.tsai. 600 IN NS linux.vbird.tsai. ;; ADDITIONAL SECTION: slave.vbird.tsai. 600 IN A 192.168.1.150 ;; Query time: 4 msec ;; SERVER: 192.168.1.254#53(192.168.1.254) ;; WHEN: Thu Oct 19 15:34:23 2006 ;; MSG SIZE rcvd: 100 |
½d¨Ò¤G¡G¬d¸ß vbird.tsai ³oÓ»â°ìªº MX §a¡I [root@linux ~]# dig @192.168.1.254 vbird.tsai mx ; <<>> DiG 9.2.4 <<>> @192.168.1.254 vbird.tsai mx ; (1 server found) ;; global options: printcmd ;; Got answer: ;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 3390 ;; flags: qr aa rd ra; QUERY: 1, ANSWER: 1, AUTHORITY: 2, ADDITIONAL: 2 ;; QUESTION SECTION: ;vbird.tsai. IN MX <==Á@¡In¨Dªº¸ê®Æ¤£¤@¼Ë¤F³á¡I ;; ANSWER SECTION: vbird.tsai. 600 IN MX 10 linux.vbird.tsai. ;; AUTHORITY SECTION: vbird.tsai. 600 IN NS slave.vbird.tsai. vbird.tsai. 600 IN NS linux.vbird.tsai. ;; ADDITIONAL SECTION: linux.vbird.tsai. 600 IN A 192.168.1.254 slave.vbird.tsai. 600 IN A 192.168.1.150 ;; Query time: 4 msec ;; SERVER: 192.168.1.254#53(192.168.1.254) ;; WHEN: Thu Oct 19 15:45:58 2006 ;; MSG SIZE rcvd: 116 |
[root@linux ~]# whois [domainname] <==ª`·N°Ú¡I¬O domain ¦Ó¤£¬O hostnam [root@linux ~]# whois redhat.com Registrant: Red Hat, Inc. P.O. Box 13588 Research Triangle Park, NC 27709 US Domain Name: REDHAT.COM Administrative Contact, Technical Contact: Network, Operations noc@REDHAT.COM Red Hat, Inc. 1801 Varsity Drive ATTN Domain Administrator Raleigh, NC 27606 US 919.754.3700 fax: 919-754-3704 Record expires on 25-May-2011. Record created on 26-May-1994. Database last updated on 19-Oct-2006 03:58:04 EDT. Domain servers in listed order: NS3.REDHAT.COM 66.187.229.10 NS2.REDHAT.COM 66.187.224.210 NS1.REDHAT.COM 66.187.233.210 |
[root@linux ~]# whois vbird.idv.tw [¬d¸ß whois.twnic.net] [whois.twnic.net] Domain Name: vbird.idv.tw Contact: Der-Min Tsai vbird@aerosol.ev.ncku.edu.tw Record expires on 2008-09-17 (YYYY-MM-DD) Record created on 2002-09-13 (YYYY-MM-DD) Registrar: HINET |
[root@linux ~]# vi /var/named/chroot/var/named/named.vbird.tsai
# ¦b³oÓÀɮתº³Ì¤U¤è¼W¥[³o¨â¦æ¡G
niki IN NS niki.vbird.tsai.
niki IN A 192.168.100.100
|
[root@linux ~]# more /var/log/messages 1 Oct 5 05:02:30 test named[432]: lame server resolving '68.206.244.205. in-addr.arpa' (in '206.244.205.in-addr.arpa'?): 205.244.200.3#53 2 Oct 5 05:02:31 test named[432]: lame server resolving '68.206.244.205. in-addr.arpa' (in '206.244.205.in-addr.arpa'?): 206.105.201.35#53 3 Oct 5 05:02:41 test named[432]: lame server resolving '68.206.244.205. in-addr.arpa' (in '206.244.205.in-addr.arpa'?): 205.244.112.20#53 |
1. קï /etc/named.conf [root@linux ~]# vi /etc/named.conf // ¥[¤J©³¤U³oӰѼơG logging { category lame-servers { null; }; }; 2. «·s±Ò°Ê bind [root@linux ~]# /etc/init.d/named restart |
command channel listening on 127.0.0.1#953 |
couldn't add command channel 127.0.0.1#953: not found |
1. ¥ý«Ø¥ß rndc key ªº¬ÛÃö¸ê®Æ§a¡I [root@linux ~]# rndc-confgen # Start of rndc.conf key "rndc-key" { algorithm hmac-md5; secret "aoIyK4uoiR1hEqedk2D2lw=="; }; options { default-key "rndc-key"; default-server 127.0.0.1; default-port 953; }; # End of rndc.conf # ¤W±ªº¿é¥X½Ð±N¥L¶K¨ì rndc.conf ÀÉ®×·í¤¤§a¡I # Use with the following in named.conf, adjusting the allow list as needed: # key "rndc-key" { # algorithm hmac-md5; # secret "aoIyK4uoiR1hEqedk2D2lw=="; # }; # # controls { # inet 127.0.0.1 port 953 # allow { 127.0.0.1; } keys { "rndc-key"; }; # }; # End of named.conf # ¦Ü©ó¤W±ªº key ¤Î controls ªº¶µ¥Ø«h¶K¨ì named.conf ·í¤¤¥h¡I # ½Ðª`·N¡A³oÓ rndc-confgen ¬O§Q¥Î¶Ã¼Æpºâ¥X¥[±Kªº¨º§â key ¡A # ©Ò¥H¨C¦¸°õ¦æªºµ²ªG³£¤£¤@¼Ë¡C©Ò¥H¤Wzªº¸ê®Æ»P§Aªº¿Ã¹õ·|¦³ÂI¤£¦P¡C 2. «Ø¥ß rndc.conf ÀÉ®× [root@linux ~]# vi /etc/rndc.conf # ¦b³oÓÀÉ®×·í¤¤±N쥻ªº¸ê®Æ¥þ³¡§R°£¡A¨Ã±Nèè±o¨ìªºµ²ªGµ¹¥L¶K¤W¥h key "rndc-key" { algorithm hmac-md5; secret "aoIyK4uoiR1hEqedk2D2lw=="; }; options { default-key "rndc-key"; default-server 127.0.0.1; default-port 953; }; [root@linux ~]# chmod 640 /etc/rndc.conf <==¥²»Ýn³]©w¦nÅv¡I [root@linux ~]# chown root.named /etc/rndc.conf 3. קï named.conf [root@linux ~]# vi /var/named/chroot/etc/named.conf # §ä¨ì¦p¤Uªº³o¤@¦æ¡G include "/etc/rndc.key"; # ±N¤Wz¸ê®Æ§R°£¡I¦]¬°¸Ó¸ê®Æ¬Oªº¡IµM«á¥[¤J³o¤@¬q¡G key "rndc-key" { algorithm hmac-md5; secret "aoIyK4uoiR1hEqedk2D2lw=="; }; controls { inet 127.0.0.1 port 953 allow { 127.0.0.1; } keys { "rndc-key"; }; }; [root@linux ~]# /etc/init.d/named restart |
[root@linux ~]# rndc Usage: rndc [-c config] [-s server] [-p port] [-k key-file ] [-y key] [-V] command command is one of the following: reload Reload configuration file and zones. stats Write server statistics to the statistics file. dumpdb Dump cache(s) to the dump file (named_dump.db). flush Flushes all of the server's caches. status Display status of the server. # ¨ä¥L´Nµ¹¥L¬Ù²¤°Õ¡I½Ð¦Û¦æ¿é¤J³oÓ«ü¥O¨Ó°Ñ¦ÒÅo¡I |
½d¨Ò¤@¡G±N¥Ø«e DNS ¦øªA¾¹ªºª¬ºAÅã¥Ü¥X¨Ó [root@linux ~]# rndc status number of zones: 6 <==³o³¡ DNS ºÞ²zªº zone ¼Æ¶q debug level: 0 <==¬O§_¨ã¦³ debug ¤Î debug ªºµ¥¯Å xfers running: 0 xfers deferred: 0 soa queries in progress: 0 query logging is OFF <==¬O§_±N¬d¸ßªº¸ê®Æ°O¿ý¤U¨Ó¡H server is up and running <==¥D¾÷¥Ø«e¥¿¦b¹B§@·í¤¤ ½d¨Ò¤G¡G±N¥Ø«e¨t²Îªº DNS ²Îp¸ê®Æ°O¿ý¤U¨Ó [root@linux ~]# rndc stats # ¦¹®É¡A¹w³]·|¦b /var/named/chroot/var/named/data ¤º²£¥Í·sÀɮסA§A¥i¥H¥h¬d¾\¡G [root@linux ~]# cat /var/named/chroot/var/named/data/named_stats.txt +++ Statistics Dump +++ (1161322745) success 22 referral 0 nxrrset 0 nxdomain 3 recursion 6 failure 0 --- Statistics Dump --- (1161322745) ½d¨Ò¤T¡G±N¥Ø«e§Ö¨ú°O¾ÐÅé·í¤¤ªº¸ê®Æ°O¿ý¤U¨Ó [root@linux ~]# rndc dumpdb # »P stats Ãþ¦ü¡A·|±N cache ªº¸ê®Æ©ñ¸m¦¨¬°¤@ÓÀɮסA§A¥i¥H¥h¬d¾\¡G # /var/named/chroot/var/named/data/cache_dump.db |
rndc: connection to remote host closed This may indicate that the remote server is using an older version of the command protocol, this host is not authorized to connect, or the key is invalid. |
[root@linux ~]# dnssec-keygen -a [ºtºâªk] -b [±K½Xªø«×] -n [Ãþ«¬] ¦WºÙ °Ñ¼Æ¡G -a ¡G«á±±µªº [type] ¬°ºtºâ¤è¦¡ªº·N«ä¡A¥Dn¦³ RSAMD5, RSA, DSA, DH »P HMAC-MD5 µ¥¡C«Øij§A¥i¥H¨Ï¥Î±`¨£ªº HMAC-MD5 ¨Óºtºâ±K½X¡F -b ¡G§Aªº±K½Xªø«×¬°¦h¤Ö¡H³q±`µ¹¤© 128 ¦ì¤¸´N¥i¥H¤F¡F -n ¡G«á±±µªº«h¬O¥Î¤áºÝ¯à°÷§ó·sªºÃþ«¬¡A¥Dn¦³©³¤U¨âºØ¡A«Øijµ¹ HOST §Y¥i¡G ZONE¡G¥Î¤áºÝ¥i¥H§ó·s¥ô¦ó¼Ð»x¤Î¾ãÓ ZONE¡F HOST¡G¥Î¤áºÝ¶È¥i¥H°w¹ï¥Lªº¥D¾÷¦WºÙ¨Ó§ó·s¡C [root@linux ~]# mkdir -p /var/named/keys; cd /var/named/keys [root@linux keys]# dnssec-keygen -a HMAC-MD5 -b 128 -n HOST web Kweb.+157+50096 [root@linux keys]# ls -l K* -rw------- 1 root root 47 Oct 20 14:20 Kweb.+157+50096.key -rw------- 1 root root 81 Oct 20 14:20 Kweb.+157+50096.private # ¤W±¨º§â¬O¤½Æ_¡A¤U±¨º§â«h¬O¨pÆ_ÀɮסI [root@linux keys]# cat Kweb.+157+50096.key web. IN KEY 512 3 157 +j8TSooNNIUPb3OR9Rh53Q== # ª`·N¨ì³Ì¥kÃ䪺¨ºÓ±K½Xªø«×¡Aµ¥¤@¤U§ÚÌn½Æ»sªº¶È¦³¨ºÓ¦a¤è¡I |
[root@linux ~]# vi /etc/named.conf // ¥ý¦b¥ô·N¦a¤è¥[¤J³oÓ Key ªº¬ÛÃö±K½X¸ê°T¡I key "web" { algorithm hmac-md5; secret "+j8TSooNNIUPb3OR9Rh53Q=="; }; // µM«á±N§A쥻ªº zone ¥[¤J©³¤U³o¤@¬q«Å¥Ü zone "vbird.tsai" { type master; file "named.vbird.tsai"; allow-transfer { 192.168.1.150; }; update-policy { grant web name web.vbird.tsai. A; }; }; [root@linux ~]# chown named /var/named/chroot/var/named [root@linux ~]# /etc/init.d/named restart |
[root@web ~]# cd /usr/local/ddns [root@web ddns]# nsupdate -k Kweb.+157+50096.key > server 192.168.1.254 > update delete web.vbird.tsai <==§R°£ì¦³ªº > update add web.vbird.tsai 600 A 192.168.1.222 <==§ó·s¨ì³Ì·sªº > send > ³Ì«á¦b¦¹«ö¤U [ctrl]+D §Y¥i |
[root@web ~]# vi /usr/local/ddns/ddns_update.sh #!/bin/bash PATH=/sbin:/bin:/usr/sbin:/usr/bin export PATH # 0. keyin your parameters basedir="/usr/local/ddns" # °ò¥»¤u§@¥Ø¿ý keyfile="$basedir"/"Kvbird.+157+05841.key" # ±NÀɦW¶ñ¶i¥h§a¡I ttl=600 # §A¥i¥H«ü©w ttl ªº®É¶¡³á¡I outif="ppp0" # ¹ï¥~ªº³s½u¤¶±¡I hostname="web.vbird.tsai" # §A¦V ISP ¨ú±oªº¨ºÓ¥D¾÷¦WºÙ°Õ¡I servername="192.168.1.254" # ´N¬O§Aªº ISP °Ú¡I # Get your new IP newip=`ifconfig "$outif" | grep 'inet addr' | \ awk '{print $2}' | sed -e "s/addr\://"` checkip=`echo $newip | grep "^[0-9]"` if [ "$checkip" == "" ]; then echo "$0: The interface can't connect internet...." exit 1 fi # create the temporal file tmpfile=$basedir/tmp.txt cd $basedir echo "server $servername" > $tmpfile echo "update delete $hostname A " >> $tmpfile echo "update add $hostname $ttl A $newip" >> $tmpfile echo "send" >> $tmpfile # send your IP to server nsupdate -k $keyfile -v $tmpfile |