配置DNS伺服器

來源:互聯網
上載者:User

標籤:配置dns伺服器   linux dns   

一、安裝

yum install bind-utils.x86_64

yum install bind

二、配置

vim /etc/named.conf

編輯檔案內容為:

############################################################

options {

        listen-on port 53 { 127.0.0.1;192.168.4.103; };

        directory       "/var/named";

        allow-query     { any; };

};

 

zone "." IN {

        type hint;

        file "named.ca";

};

 

zone "example.com" IN {

        type master;

        file "example.com.zone";

};

 

include "/etc/named.rfc1912.zones";

include "/etc/named.root.key";

 

###########################################################

 

 

[[email protected] Desktop]# cd /var/named/

[[email protected] named]# cp named.localhost example.com.zone -p

[[email protected] named]# vim example.com.zone

 

修改為:

 

 

 

 

 

 

 

 

 

###############################################################

$TTL 1D

@       IN SOA  @ root.server03.example.com. (

                                        0       ; serial

                                        1D      ; refresh

                                        1H      ; retry

                                        1W      ; expire

                                        3H )    ; minimum

        NS      @

        A       127.0.0.1

server03        IN      A       192.168.4.103

 

###################################################################

 

[[email protected] named]# /etc/init.d/named restart

 

 

指定DNS伺服器:

[[email protected] named]# vim /etc/sysconfig/network-scripts/ifcfg-eth0

添加:

DNS1=192.168.4.254

 

重啟網卡:

 

[[email protected] named]# /etc/init.d/network restart

 

測試:

[[email protected] named]# nslookup server03

Server: 192.168.4.103

Address: 192.168.4.103#53

 

Name: server03.example.com

Address: 192.168.4.103

 

[[email protected] named]# nslookup server03.example.com

Server: 192.168.4.103

Address: 192.168.4.103#53

 

Name: server03.example.com

Address: 192.168.4.103

 

 

 

 

三、將ip位址解析成網域名稱

編輯name.conf檔案:

新增內容:

zone "4.168.192.in-addr.arpa" IN {

        type master;

        file "192.168.4.zone";

};

 

 

[[email protected] named]# pwd

/var/named

[[email protected] named]# cp example.com.zone 192.168.4.zone -p

 

編輯192.168.4.zone 檔案:

修改為:

$TTL 1D

@       IN SOA  @ root.server03.example.com. (

                                        0       ; serial

                                        1D      ; refresh

                                        1H      ; retry

                                        1W      ; expire

                                        3H )    ; minimum

        NS      @

        A       127.0.0.1

 

103   IN   PTR   server03.example.com.

 

重啟named 

[[email protected] named]# /etc/init.d/named restart

 

測試:

[[email protected] named]# nslookup 192.168.4.103

Server: 192.168.4.103

Address: 192.168.4.103#53

 

103.4.168.192.in-addr.arpa name = server03.example.com.

 

四、讓DNS伺服器變得安全

安裝bind-chroot

!!!停止named服務

[[email protected] named]# service named stop

安裝:

[[email protected] named]# yum install bind-chroot

 

[[email protected] named]# cd /var/named/chroot/etc/

 

 

[[email protected] etc]# cp /etc/named* ./ -p

[[email protected] etc]# cd ../var/named/

[[email protected] named]# ls        為空白為正常

[[email protected] named]# cp -rp /var/named/* ./

[[email protected] named]# rm -rf chroot/

[[email protected] named]# ls

192.168.4.zone  dynamic           named.ca     named.localhost  slaves

data            example.com.zone  named.empty  named.loopback

 

不能有chroot

[[email protected] named]# cd /var/named

 

[[email protected] named]# pwd

/var/named

[[email protected] named]# rm -rf example.com.zone 

[[email protected] named]# rm -rf 192.168.4.zone

 

重啟服務:

[[email protected] etc]# /etc/init.d/named restart

Stopping named:                                            [  OK  ]

Starting named:                                            [  OK  ]

驗證:

[[email protected] etc]# nslookup server03.example.com

Server: 192.168.4.103

Address: 192.168.4.103#53

 

Name: server03.example.com

Address: 192.168.4.103

[[email protected] etc]# nslookup 192.168.4.103

Server: 192.168.4.103

Address: 192.168.4.103#53

 

103.4.168.192.in-addr.arpa name = server03.example.com.

 

現在named.comf 使用的是/var/named/chroot/etc/named.conf

 

Ok!

配置DNS伺服器

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.