µ±Ç°Î»ÖãºLinux½Ì³Ì - Linux - ÖÐСÆóÒµ·þÎñÆ÷ÅäÖ÷½°¸ µÚ¶þÕÂ

ÖÐСÆóÒµ·þÎñÆ÷ÅäÖ÷½°¸ µÚ¶þÕÂ

×÷ Õߣº ÌÀº£¾©


( E-mail:[email protected] )

µÚ¶þÕ DNS·þÎñÆ÷

µÚÒ»½Ú Ö÷DNS·þÎñÆ÷


1.1 ¼ò½é

ÓòÃûϵͳΪһ¸ö·Ö²¼Ê½Êý¾Ý¿â,Ëüʹ±¾µØ¸ºÔð¿ØÖÆÕû¸ö·Ö²¼Ê½Êý¾Ý¿âµÄ²¿·Ö¶Î,ÿһ¶ÎÖеÄÊý¾Ýͨ¹ý¿Í»§,·þÎñÆ÷ģʽÔÚÕû¸öÍøÂçÉϾù¿É´æÈ¡,ͨ¹ý²ÉÓø´ÖƼ¼ÊõºÍ»º´æ¼¼ÊõʹµÃÕû¸öÊý¾Ý¿â¿É¿¿µÄͬʱ,ÓÖÓµÓÐÁ¼ºÃµÄÐÔÄÜ.

ÓòÃû·þÎñÆ÷°üº¬Êý¾Ý¿âµÄ²¿·Ö¶ÎµÄÐÅÏ¢,²¢¿ÉÌṩ±»³Æ֮Ϊ½âÎöÆ÷µÄ¿Í»§À´·ÃÎÊ.

DNSµÄÊý¾Ý¿â½á¹¹ÐγÉÒ»¸öµ¹Á¢µÄÊ÷×´½á¹¹,¸ùµÄÃû×ÖÓÿÕ×Ö·û´®""""À´±íʾ,µ«ÔÚÎı¾ÖÐÓÃ"".""À´Êéд.Ê÷µÄÿһ¸ö½Úµã¶¼±íʾÕû¸ö·Ö²¼Ê½Êý¾Ý¿âÖеÄÒ»¸ö·ÖÇø(Óò),ÿ¸öÓò¿ÉÔÙ½øÒ»²½»®·Ö³É×Ó·ÖÇø(Óò),ÿ¸öÓò¶¼ÓÐÒ»¸ö±êÇ©(LABEL),±êÃ÷ÁËËüÓ븸ÓòµÄ¹Øϵ.ÓòÒ²ÓÐÒ»¸öÓòÃû(domain name),¸ø³öËüÔÚÕû¸ö·Ö²¼Ê½Êý¾Ý¿âÖеÄλÖÃ.ÔÚDNSÖÐ,ÓòÃûÈ«³ÆÊÇÒ»¸ö´Ó¸ÃÓòµ½¸ùµÄ±êÇ©ÐòÁÐ,ÒÔ"".""·Ö¸ôÕâЩ±êÇ©.¸Ã±êÇ©×î¶à¿É°üº¬63¸ö×Ö·û.Ê÷ÖÐÿһ½ÚµãµÄÍêÕûÓòÃûΪ´Ó¸Ã½Úµãµ½¸ùÖ®¼ä·¾¶ÉϵıêÇ©ÐòÁÐ.

Èç¹û¸ùÓòÔÚ½ÚµãµÄÓòÃûÖгöÏÖ,¸ÃÃû×Ö¿´ÆðÀ´¾ÍÏóÒÔµã½áβ(ʵ¼ÊÉÏÊÇÒÔµãºÍ¿Õ±êÇ©×÷½áβ).ÕâЩÒÔµã½áβµÄÓòÃû±»³Æ֮Ϊ¾ø¶ÔÓòÃû(Absoulte Domain Name).²»ÒÔµã½áβµÄÓòÃû±»³Æ֮ΪÏà¶ÔÓòÃû.

Óò(Domains)¼´ÎªÊ÷×´ÓòÃû¿Õ¼äÖеÄÒ»¿Ã×ÓÊ÷,ÓòµÄÓòÃûͬ¸Ã×ÓÊ÷¸ù½ÚµãµÄÓòÃûÒ»Ñù.Ò²¾ÍÊÇ˵,ÓòµÄÃû×Ö¾ÍÊǸÃÓòÖÐ×î¸ß²ã½ÚµãµÄÃû×Ö.¾ÙÀýÀ´Ëµ,zhuhai.gd.cnÓòµÄ¶¥¶Ë¾ÍÊÇÃûΪzhuhai.gd.cnµÄ½Úµã.

ÔÚDNSÖÐ,ÿ¸öÓò·Ö±ðÓɲ»Í¬µÄ×éÖ¯½øÐйÜÀí.ÿ¸ö×éÖ¯¶¼¿ÉÒÔ½«ËüµÄÓòÔÙ·Ö³ÉÒ»¶¨ÊýÁ¿µÄ×ÓÓò²¢½«ÕâЩ×ÓÓòίÍиøÆäËû×éÖ¯½øÐйÜÀí.Óò¼ÈÄÜ°üÀ¨Ö÷»úÓÖÄÜ°üÀ¨ÆäËûÓò(ËüµÄ×ÓÓò).ÓòÃû±»ÓÃ×öDNSÊý¾Ý¿âÖеÄË÷Òý.×ÓÓòÖÐÈκÎÓòÃû±»ÈÏΪÊÇÓòµÄÒ»²¿·Ö.

ÊÂʵÉÏ,Ö÷»ú¼´ÎªÓò,ÓòÃû½öÊÇDNSÊý¾Ý¿âÖеÄË÷Òý,""Ö÷»ú""¿ÉÓÉÖ¸ÏòÏà¹ØÖ÷»úÐÅÏ¢µÄÓòÃûÀ´Ë÷Òý,Óò°üº¬ËùÓÐÆäÓòÃûÔÚ¸ÃÓòµÄÖ÷»ú.

ÔÚÓòÃûÊ÷ÖÐ,Ò¶½ÚµãµÄÓòͨ³£´ú±íÖ÷»ú,ËüÃǵÄÓòÃû¿ÉÖ¸ÏòÍøÂçµØÖ·,Ó²¼þÐÅÏ¢ºÍÓʼþ·ÓÉÐÅÏ¢.ÔÚÊ÷ÄڵĽڵã,ÆäÓòÃû¼È¿ÉÃüÃûһ̨Ö÷»ú,Ò²¿ÉÖ¸ÏòÓйظÃÓòµÄ×ÓËï»ò×ÓÓòµÄ½á¹¹ÐÅÏ¢,ÔÚÓòÃûÊ÷ÖеÄÄÚ²¿ÓòÃû²¢²»ÊÜΨһÐÔÏÞÖÆ,ËüÃǼȿɱíʾËüÃÇËù¶ÔÓ¦µÄÓò,ÓÖ¿É´ú±íÍøÂçÖÐij̨Ìض¨µÄÖ÷»ú.ÀýÈç,sun.com¼ÈÊÇsunµÄÓò,ÓÖÊÇÔÚsunºÍinternet¼äת·¢ÐżþµÄÓʼþ·þÎñÆ÷µÄÓòÃû.


1.2 ËùÐè×ÊÔ´

1.2.1 ËùÐè°ü
RedHat6.2 ·þÎñÆ÷ģʽ°²×°

1.2.2 ËùÐèÅäÖÃÎļþ
/etc/named.conf ϵͳ×Ô´ø£¬¹ÜÀíÔ±ÅäÖÃ
/etc/hosts ϵͳ×Ô´ø£¬¹ÜÀíÔ±ÅäÖÃ
/etc/resolv.conf ϵͳ×Ô´ø£¬¹ÜÀíÔ±ÅäÖÃ
/var/named/name2ip.conf ϵͳûÓУ¬¹ÜÀíÔ±´´½¨
/var/named/ip2name.conf ϵͳûÓУ¬¹ÜÀíÔ±´´½¨
/etc/named.boot ϵͳ×Ô´ø£¬²»ÐèÒªÐÞ¸Ä
/etc/host.conf ϵͳ×Ô´ø£¬²»ÐèÒªÐÞ¸Ä
/etc/nsswitch.conf ϵͳ×Ô´ø£¬²»ÐèÒªÐÞ¸Ä
/var/named/named.local ϵͳ×Ô´ø£¬²»ÐèÒªÐÞ¸Ä
/var/named/named.ca ϵͳ×Ô´ø£¬²»ÐèÒªÐÞ¸Ä

1.2.3 Ïà¹Ø¹¤¾ß
1. nslookup
˵Ã÷£º¼ì²âDNSÊÇ·ñÅäÖÃÕýÈ·µÄ¹¤¾ß£¬ÏµÍ³×Ô´ø¡£


1.3 ÅäÖ÷½°¸

/etc/named.conf
˵Ã÷£ºDNSÖ÷ÅäÖÃÎļþ£¬¶¨ÒåÁËÓòÊý¾Ý¿âÐÅÏ¢µÄ»ù±¾²ÎÊýºÍÔ´µã£¬¸ÃÎļþ¿ÉÒÔ´æ·ÅÔÚ±¾µØ»òÔ¶³ÌµÄ·þÎñÆ÷ÉÏ¡£
Ô´Îļþ£º
options {
¡¡¡¡directory ""/var/named""; ££¶¨ÒåÁËnamedÒª¶ÁдÎļþµÄ·¾¶
¡¡¡¡};
zone ""."" {
¡¡¡¡type hint;¡¡¡¡££±íÃ÷ÔÚÆô¶¯Ê±±»ÓÃÀ´³õʼ»¯ÓòÃû·þÎñÆ÷µÄÎļþ
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡ÊÇÒ»¸öÏßË÷Îļþ£¬Ã¿¸ö·þÎñÆ÷¶¼ÓÐÒ»¸öÏßË÷Çø¡£
file ""named.ca"";££Ö¸¶¨ËùÒª¶ÁÈ¡µÄÎļþÃû
};
zone ""0.0.127.in-addr.arpa"" {
type master;¡¡¡¡¡¡¡¡££±íÃ÷·þÎñÆ÷ÊÇÖ÷ÓòÃû·þÎñÆ÷
file ""named.local"";
};
zone ""0.168.192.in-addr.arpa"" { # ¶¨Òå±»½âÊÍÍø¶Î
type master;
file ""ip2name.conf"";
};
zone ""weboa.com.cn"" in {¡¡¡¡¡¡¡¡¡¡# ±»½âÊ͵ÄÓòÃû
type master;
file ""name2ip.conf"";
};

/var/named/name2ip.conf
˵Ã÷£ºÕýÏò½âÎöÅäÖÃÎļþ,¼´ÊµÏÖÓòÃûµ½IPµÄ¶ÔÓ¦
Ô´Îļþ£º
@ IN SOA¡¡¡¡www.weboa.com.cn. root.www.weboa.com.cn.
££ËùÓеÄÇøÎļþ¶¼ÒÔSOA¿ªÍ·£¬@Ö¸¶¨µ±Ç°µÄÐÅÏ¢Ô´£¬www.weboa.com.cnÕâ¸öÖµ¿ÉÒÔ½«ÓòÃûºÍnamed.confÁ¬½ÓÆðÀ´¡£Í¨³£Ö»ÓÐÒ»¸ö@·ûºÅ¡£
(¡¡¡¡1997022700 ; Serial¡¡¡¡££ÐòÁкÅ
¡¡¡¡ 28800¡¡¡¡¡¡; Refresh¡¡ ££Ë¢ÐÂÖÜÆÚ,ÒÔÃëΪµ¥Î»
¡¡¡¡ 14400¡¡¡¡¡¡; Retry¡¡¡¡ ££Ñ­»·ÖÜÆÚ
¡¡¡¡ 3600000¡¡¡¡; Expire¡¡¡¡££ÖÐֹʱ¼ä
¡¡¡¡ 86400 )¡¡¡¡; Minimum¡¡ ££time-to-liveµÄʱ¼ä
¡¡¡¡¡¡¡¡¡¡¡¡ IN¡¡¡¡NS¡¡¡¡www.weboa.com.cn.
££¶¨ÒåÓòÃû·þÎñÆ÷
¡¡¡¡¡¡¡¡¡¡¡¡ IN¡¡¡¡MX¡¡10¡¡mail.weboa.com.cn.
££¶¨ÒåÓʼþ·þÎñÆ÷£¬10±íʾÓÅÏȼ¶£¬Ô½Ð¡Ô½¸ß
££ÊµÏÖÓòµ½IPµÄÓ³Éä:
localhost¡¡¡¡IN¡¡¡¡A¡¡¡¡127.0.0.1
www¡¡¡¡¡¡¡¡¡¡IN¡¡¡¡A¡¡¡¡192.168.0.1
mail¡¡¡¡¡¡¡¡ IN¡¡¡¡A¡¡¡¡192.168.0.1
pop3¡¡¡¡¡¡¡¡ IN¡¡¡¡A¡¡¡¡192.168.0.1
smtp¡¡¡¡¡¡¡¡ IN¡¡¡¡A¡¡¡¡192.168.0.1
@¡¡¡¡¡¡¡¡¡¡¡¡IN¡¡¡¡A¡¡¡¡192.168.0.1

/var/named/ip2name.conf
˵Ã÷£ºDNS·´Ïò½âÎöÅäÖÃÎļþ£¬¼´ÊµÏÖIPµØÖ·ºÜÓòÃûµÄÓ³Éä
Ô´Îļþ£º
@ IN SOA www.weboa.com.cn. root.www.weboa.com.cn. (
¡¡¡¡¡¡1997022700 ; Serial
¡¡¡¡¡¡28800¡¡¡¡¡¡; Refresh
¡¡¡¡¡¡14400¡¡¡¡¡¡; Retry
¡¡¡¡¡¡3600000¡¡¡¡; Expire
¡¡¡¡¡¡86400 )¡¡¡¡; Minimum
¡¡¡¡¡¡IN¡¡¡¡NS¡¡¡¡¡¡www.weboa.com.cn.
¡¡¡¡¡¡IN¡¡¡¡MX¡¡10¡¡mail.weboa.com.cn.
1¡¡¡¡ IN¡¡¡¡PTR¡¡¡¡ www.weboa.com.cn.
££ÆäÖÐÄǸö1µÄÒâ˼ÊÇIPµÄ×îºóһ룬¿ÉÒÔÊÇ0-255£¬ËüÓë
/etc/named.confÖÐÁíÍâÈýλIPÒ»Æð×é³ÉÒ»¸öIP£»¶¨ÒåÄæÏò¹Øϵ£¬
¼´www.weboa.com.cnºÍ192.168.0.1Ö®¼äµÄ¶ÔÓ¦¡£

/etc/hosts
˵Ã÷£ºÊµÏÖÓëÍøÉÏÆäËûÖ÷Òª¼ÆËã»úµÄÓ³É䣬Ëüͨ³£Êǵ±×÷DNSµÄ±¸
·Ý³öÏֵģ¬Ò²¾ÍÊÇ˵£¬µ±DNSϵͳ³öÏÖÎÊÌâµÄʱºò²ÅʹÓÃHosts±í¡£
Ô´Îļþ£º
127.0.0.1¡¡¡¡¡¡localhost.localdomain¡¡¡¡¡¡localhost
192.168.0.1¡¡¡¡www.weboa.com.cn¡¡¡¡¡¡¡¡¡¡ www
££ÓÉÓÚÿ̨·þÎñÆ÷¶¼»áÓм¸¸öÓòÃûÓëIPµÄ¶ÔÓ¦¹ØϵÊÇÓÀ¾ÃµÄ£¬ Ëù
ÒÔHosts±íÖдæ·ÅµÄÓ¦¸ÃÊÇËüÃÇ¡£

/etc/resolv.conf
˵Ã÷£ºÖ¸¶¨ÓòÃû·þÎñÆ÷µÄIPºÍËÑË÷˳Ðò¡£
Ô´Îļþ£º
domain
££¶¨Òå±¾µØÓòÃû¡£
search weboa.com.cn
££¼ò»¯Óû§ÊäÈëµÄÖ÷»úÃû£¬¼´µ±Óû§ÊäÈëmailʱ£¬Ê¹µÃDNS¿ÉÒÔ°Ñ
Ëü³É¹¦µØ½âÎöΪmail.weboa.com.cn¡£ËüÓëdomainÊÇ»¥³âµÄ£¬ÎÞÂÛ
Ë­³öÏÖ¶¼ÊÇÓÃÀ´¶¨ÒåsearchÁбíµÄ¡£
nameserver 192.168.0.1
££¶¨ÒåÓòÃû·þÎñÆ÷µÄIP,×î¶àÈý¸ö£¬½¨ÒéÒ»°ãʹÓÃÁ½¸ö¡£

1.4 ²âÊÔ¼°¹ÜÀí°ì·¨

1.4.1 ²âÊÔ·½·¨
1. ¹ÜÀíÔ±ÐÞ¸ÄÍêDNSµÄÅäÖÃÎļþ£¬ÐèÒªÖ´ÐÐ/etc/rc.d/init.d/named
restartÀ´ÊǸü¸ÄÉúЧ¡£

2. nslookup£º²âÊÔÕýÏò¡¢·´ÏòµÄ½âÎöÊÇ·ñÕý³£


1.5 С½á

DNS·þÎñÊÇÐí¶à·þÎñµÄ»ù´¡£¬ËùÒÔÅäÖÃһ̨Linux ServerÓ¦¸Ã´ÓDNS¿ªÊ¼£¬²¢Òª´ÓÒ»¿ªÊ¼¾Í¶ÔÄãµÄ·þÎñÆ÷ÅäÖóÉʲôÑù×ÓÓÐÒ»¸öÕûÌåµÄ°ÑÎÕ£¬ÕâÑù²ÅÄܱ£Ö¤ÅäÖÃÖ®¼äÄܹ»Ï໥Эµ÷£¬±ÜÃâ´íÎóµÄ·¢Éú¡£