ÔõÑùÉèÖúÍÖÎÀíLinuxÉϵÄDNSЧÀÍ
ÔõÑùÉèÖúÍÖÎÀíLinuxÉϵÄDNSЧÀÍ
¼ò½é£º
DNS£¨Domain Name System£©ÊÇ»¥ÁªÍøÉÏÓÃÓÚ½«ÓòÃûת»»ÎªIPµØµãµÄϵͳ¡£ÔÚLinuxϵͳÖУ¬ÎÒÃÇ¿ÉÒÔʹÓÃһЩ¿ªÔ´Èí¼þÀ´ÉèÖúÍÖÎÀíDNSЧÀÍ¡£±¾ÎĽ«ÏÈÈÝÔõÑùÔÚLinuxÉϾÙÐÐDNSЧÀ͵ÄÉèÖúÍÖÎÀí£¬Í¬Ê±ÌṩÏêϸµÄ´úÂëʾÀý¡£
°ì·¨Ò»£º×°ÖÃDNSЧÀÍÆ÷Èí¼þ
Ê×ÏÈ£¬ÎÒÃÇÐèҪѡÔñ²¢×°ÖÃÊʺϵÄDNSЧÀÍÆ÷Èí¼þ¡£ÔÚLinuxϵͳÖУ¬³£ÓõÄDNSЧÀÍÆ÷Èí¼þÓÐBindºÍPowerDNSµÈ¡£ÒÔÏÂÊÇ×°ÖÃBindµÄʾÀýÏÂÁÊÊÓÃÓÚDebian/Ubuntuϵͳ£©£º
sudo apt-get update sudo apt-get install bind9
µÇ¼ºó¸´ÖÆ
°ì·¨¶þ£ºÉèÖÃÖ÷ÒªÉèÖÃÎļþ
Ò»µ©DNSЧÀÍÆ÷Èí¼þ×°ÖÃÍê³É£¬ÎÒÃÇÐèÒª±à¼Ö÷ÒªµÄÉèÖÃÎļþÒÔÖ¸¶¨DNSЧÀÍÆ÷µÄÐÐΪ¡£ÒÔÏÂÊÇBindµÄÖ÷ÒªÉèÖÃÎļþʾÀý£¨Â·¾¶Îª/etc/bind/named.conf£©£º
// È«¾ÖÉèÖà options { directory "/var/cache/bind"; recursion yes; allow-recursion { any; }; }; // ½ç˵ÍâµØÇøÃûÇøÓò zone "example.com" { type master; file "/etc/bind/db.example.com"; }; // ½ç˵·´ÏòÆÊÎöÇøÓò zone "0.168.192.in-addr.arpa" { type master; file "/etc/bind/db.192"; };
µÇ¼ºó¸´ÖÆ
°ì·¨Èý£ºÉèÖÃÓòÃûÆÊÎöÎļþ
³ýÁËÉèÖÃÖ÷ÒªµÄÉèÖÃÎļþÍ⣬ÎÒÃÇ»¹ÐèÒª½¨ÉèÓòÃûÆÊÎöÎļþÒÔÖ¸¶¨ÓòÃûºÍIPµØµãµÄ¶ÔÓ¦¹Øϵ¡£ÒÔÏÂÊÇʾÀýµÄÓòÃûÆÊÎöÎļþ£¨Â·¾¶Îª/etc/bind/db.example.com£©£º
$ORIGIN . $TTL 86400 example.com IN SOA ns1.example.com. admin.example.com. ( 2021102601 ; serial 3600 ; Ë¢ÐÂÖÜÆÚ 1800 ; ÖØÊÔÖÜÆÚ 604800 ; ÓâÆÚʱ¼ä 86400 ; »º´æʱ¼ä ) NS ns1.example.com. NS ns2.example.com. A 192.168.0.10 $ORIGIN example.com. ns1 A 192.168.0.10 ns2 A 192.168.0.20 www CNAME example.com.
µÇ¼ºó¸´ÖÆ
°ì·¨ËÄ£ºÉèÖ÷´ÏòÆÊÎöÎļþ
ΪÁËʵÏÖ´ÓIPµØµãµ½ÓòÃûµÄÆÊÎö£¬ÎÒÃÇ»¹ÐèÒªÉèÖ÷´ÏòÆÊÎöÎļþ¡£ÒÔÏÂÊÇʾÀýµÄ·´ÏòÆÊÎöÎļþ£¨Â·¾¶Îª/etc/bind/db.192£©£º
$ORIGIN . $TTL 86400 0.168.192.in-addr.arpa IN SOA ns1.example.com. admin.example.com. ( 2021102601 ; serial 3600 ; Ë¢ÐÂÖÜÆÚ 1800 ; ÖØÊÔÖÜÆÚ 604800 ; ÓâÆÚʱ¼ä 86400 ; »º´æʱ¼ä ) NS ns1.example.com. NS ns2.example.com. 10 PTR example.com.
µÇ¼ºó¸´ÖÆ
°ì·¨Î壺ÖØÆôDNSЧÀÍ
Íê³ÉÒÔÉÏÉèÖúó£¬ÎÒÃÇÐèÒªÖØÆôDNSЧÀÍÒÔʹÉèÖÃÉúЧ¡£ÒÔÏÂÊÇʾÀýµÄÖØÆôÏÂÁÊÊÓÃÓÚDebian/Ubuntuϵͳ£©£º
sudo systemctl restart bind9
µÇ¼ºó¸´ÖÆ
°ì·¨Áù£º²âÊÔDNSЧÀÍ
ΪÁËÑéÖ¤DNSЧÀ͵Ä׼ȷÐÔ£¬ÎÒÃÇ¿ÉÒÔʹÓÃdigÏÂÁîÅÌÎÊÖ¸¶¨ÓòÃûµÄIPµØµã¡£ÒÔÏÂÊÇʾÀýµÄdigÏÂÁ
dig example.com
µÇ¼ºó¸´ÖÆ
½áÂÛ£º
ͨ¹ýÒÔÉÏ°ì·¨£¬ÎÒÃÇ¿ÉÒÔÔÚLinuxϵͳÉÏÀÖ³ÉÉèÖúÍÖÎÀíDNSЧÀÍ¡£Ê×ÏÈÎÒÃÇ×°ÖÃÁËDNSЧÀÍÆ÷Èí¼þ£¬È»ºóÉèÖÃÁËÖ÷ÒªµÄÉèÖÃÎļþÒÔ¼°ÓòÃûÆÊÎöºÍ·´ÏòÆÊÎöÎļþ£¬×îºóÖØÆôDNSЧÀͲ¢¾ÙÐÐÁ˲âÊÔ¡£Í¨¹ýÕâЩ°ì·¨£¬ÎÒÃÇ¿ÉÒÔΪ×Ô¼ºµÄÍøÂçÇéÐÎÌṩ¿É¿¿µÄÓòÃûÆÊÎöЧÀÍ¡£
Çë×¢ÖØ£¬ÒÔÉÏʾÀýÖеÄ·¾¶ºÍÎļþÃû¿ÉÄÜ»áÓÉÓÚ²î±ðµÄLinux¿¯Ðаæ¶øÓÐËù²î±ð¡£ÔÚÏÖʵÉèÖÃÖУ¬Çëƾ֤×Ô¼ºµÄÇéÐνϸÄ·¾¶ºÍÎļþÃû¡£
²Î¿¼ÎÄÏ×£º
BIND 9 Administrator Reference Manual: https://downloads.isc.org/isc/bind9/cur/9.16/doc/arm/Bv9ARM.ch01.html
“How To Configure BIND as a DNS Server on Ubuntu 20.04”: https://www.digitalocean.com/community/tutorials/how-to-configure-bind-as-a-dns-server-on-ubuntu-20-04-zh
ÒÔÉϾÍÊÇÔõÑùÉèÖúÍÖÎÀíLinuxÉϵÄDNSЧÀ͵ÄÏêϸÄÚÈÝ£¬¸ü¶àÇë¹Ø×¢±¾ÍøÄÚÆäËüÏà¹ØÎÄÕ£¡