您好,登錄后才能下訂單哦!
這篇文章將為大家詳細講解有關Oracle Linux 7.1如何配置DNS服務,小編覺得挺實用的,因此分享給大家做個參考,希望大家閱讀完這篇文章后可以有所收獲。
Oracle Linux 7.1配置DNS服務
一.安裝DNS需要的軟件包
# yum install bind-libs bind bind-utils
二.編輯named.conf文件
在編輯前先復制一份named.conf文件
[root@jytest1 ~]# cp /etc/named.conf /etc/named.conf.backup [root@jytest1 ~]# vi /etc/named.conf // // named.conf // // Provided by Red Hat bind package to configure the ISC BIND named(8) DNS // server as a caching only nameserver (as a localhost DNS resolver only). // // See /usr/share/doc/bind*/sample/ for example named configuration files. // options { listen-on port 53 { any; };--將127.0.0.1修改成any listen-on-v6 port 53 { ::1; }; directory "/var/named"; dump-file "/var/named/data/cache_dump.db"; statistics-file "/var/named/data/named_stats.txt"; memstatistics-file "/var/named/data/named_mem_stats.txt"; allow-query { any; };--將127.0.0.1修改成any /* - If you are building an AUTHORITATIVE DNS server, do NOT enable recursion. - If you are building a RECURSIVE (caching) DNS server, you need to enable recursion. - If your recursive DNS server has a public IP address, you MUST enable access control to limit queries to your legitimate users. Failing to do so will cause your server to become part of large scale DNS amplification attacks. Implementing BCP38 within your network would greatly reduce such attack surface */ recursion yes; dnssec-enable yes; dnssec-validation yes; dnssec-lookaside auto; /* Path to ISC DLV key */ bindkeys-file "/etc/named.iscdlv.key"; managed-keys-directory "/var/named/dynamic"; pid-file "/run/named/named.pid"; session-keyfile "/run/named/session.key"; }; logging { channel default_debug { file "data/named.run"; severity dynamic; }; }; zone "." IN { type hint; file "named.ca"; }; include "/etc/named.rfc1912.zones"; include "/etc/named.root.key";
三.配置host.conf
[root@jytest1 ~]# cat /etc/host.conf multi on
該文件指定如何解析主機名。Linux通過解析器庫來獲得主機名對應的IP地址。下面是一個“/etc/host.conf”的示例:
order bind,hosts
multi on
nospoof on
“order bind,hosts”指定主機名查詢順序,這里規定先使用DNS來解析域名,然后再查詢“/etc/hosts”文件(也可以相反)。
“multi on”指定是否“/etc/hosts”文件中指定的主機可以有多個地址,擁有多個IP地址的主機一般稱為多穴主機。
“nospoof on”指不允許對該服務器進行IP地址欺騙。IP欺騙是一種攻擊系統安全的手段,通過把IP地址偽裝成別的計算機,來取得其它計算機的信任。
四.修改/etc/named.rfc1912.zones
[root@jytest1 ~]# cp /etc/named.rfc1912.zones /etc/named.rfc1912.zones.backup [root@jytest1 ~]# vi /etc/named.rfc1912.zones // named.rfc1912.zones: // // Provided by Red Hat caching-nameserver package // // ISC BIND named zone configuration for zones recommended by // RFC 1912 section 4.1 : localhost TLDs and address zones // and http://www.ietf.org/internet-drafts/draft-ietf-dnsop-default-local-zones-02.txt // (c)2007 R W Franks // // See /usr/share/doc/bind*/sample/ for example named configuration files. // zone "localhost.localdomain" IN { type master; file "named.localhost"; allow-update { none; }; }; zone "localhost" IN { type master; file "named.localhost"; allow-update { none; }; }; 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" IN { type master; file "named.loopback"; allow-update { none; }; }; zone "1.0.0.127.in-addr.arpa" IN { type master; file "named.loopback"; allow-update { none; }; }; zone "0.in-addr.arpa" IN { type master; file "named.empty"; allow-update { none; }; }; --下面為增加的內容,jybd.net.forward為正向解析,jydba.net.reverse為反向解析 zone "jydba.net" IN { type master; file "jydba.net.forward"; allow-update { none; }; }; zone "130.138.10.in-addr.arpa" IN { type master; file "jydba.net.reverse"; allow-update { none; }; }; "/etc/named.rfc1912.zones" 54L, 1171C written
五.修改具體的zone配置文件
[root@jytest1 named]# cd /var/named [root@jytest1 named]# cp named.localhost jydba.net.forward [root@jytest1 named]# cp named.loopback jydba.net.reverse [root@jytest1 named]# vi jydba.net.forward $TTL 1D @ IN SOA @ root.jydba.net. ( 0 ; serial 1D ; refresh 1H ; retry 1W ; expire 3H ) ; minimum NS @ A 10.138.130.171 AAAA ::1 jytest1 A 10.138.130.171 jytest2 A 10.138.130.172 jytest1-vip A 10.138.130.175 jytest2-vip A 10.138.130.176 jytest-scan A 10.138.130.177 jytest-scan A 10.138.130.178 jytest-scan A 10.138.130.179 [root@jytest1 named]# vi jydba.net.reverse $TTL 1D @ IN SOA @ root.jydba.net. ( 0 ; serial 1D ; refresh 1H ; retry 1W ; expire 3H ) ; minimum NS @ A 10.138.130.171 AAAA ::1 PTR localhost. 171 PTR jytest1 172 PTR jytest2 175 PTR jytest1-vip 176 PTR jytest2-vip 177 PTR jytest-scan 178 PTR jytest-scan 179 PTR jytest-scan
六.配置resolv.conf
[root@jytest1 named]# cat /etc/resolv.conf # Generated by NetworkManager search jydba.net # No nameservers found; try putting DNS servers into your # ifcfg files in /etc/sysconfig/network-scripts like so: # # DNS1=xxx.xxx.xxx.xxx # DNS2=xxx.xxx.xxx.xxx # DOMAIN=lab.foo.com bar.foo.com search jydba.net nameserver 10.138.130.171
七.測試
[root@jytest1 named]# dig -x 10.138.130.172 ; < <>> DiG 9.9.4-RedHat-9.9.4-18.el7 < <>> -x 10.138.130.172 ;; global options: +cmd ;; Got answer: ;; ->>HEADER<
上面出現錯誤,server can't find jytest1: SERVFAIL,錯誤信息是因為之前創建文件時使用的是root用戶,將這些創建的文件修改為named用戶與組。
[root@jytest1 named]# ls -lrt total 32 -rw-r-----. 1 root named 152 Jun 21 2007 named.localhost -rw-r-----. 1 root named 168 Dec 15 2009 named.loopback -rw-r-----. 1 root named 152 Dec 15 2009 named.empty -rw-r-----. 1 root named 2076 Jan 28 2013 named.ca drwxrwx---. 2 root named 6 Mar 6 2015 dyndb-ldap drwxrwx---. 2 named named 6 Mar 6 2015 slaves drwxr-x---. 7 root named 56 Nov 5 11:03 chroot -rw-r----- 1 root named 728 Mar 17 18:45 named.jydba -rw-r--r-- 1 root root 829 Mar 17 18:45 jydba.zone drwxrwx---. 2 named named 22 Mar 17 18:45 data -rw-r----- 1 root root 503 Mar 17 19:13 jydba.net.forward -rw-r----- 1 root root 406 Mar 17 19:15 jydba.net.reverse drwxrwx---. 2 named named 58 Mar 17 19:16 dynamic [root@jytest1 named]# chown -R named:named jydba* [root@jytest1 named]# ls -lrt total 32 -rw-r-----. 1 root named 152 Jun 21 2007 named.localhost -rw-r-----. 1 root named 168 Dec 15 2009 named.loopback -rw-r-----. 1 root named 152 Dec 15 2009 named.empty -rw-r-----. 1 root named 2076 Jan 28 2013 named.ca drwxrwx---. 2 root named 6 Mar 6 2015 dyndb-ldap drwxrwx---. 2 named named 6 Mar 6 2015 slaves drwxr-x---. 7 root named 56 Nov 5 11:03 chroot -rw-r----- 1 root named 728 Mar 17 18:45 named.jydba -rw-r--r-- 1 named named 829 Mar 17 18:45 jydba.zone drwxrwx---. 2 named named 22 Mar 17 18:45 data -rw-r----- 1 named named 503 Mar 17 19:13 jydba.net.forward -rw-r----- 1 named named 406 Mar 17 19:15 jydba.net.reverse drwxrwx---. 2 named named 58 Mar 17 19:16 dynamic
[root@jytest1 named]# systemctl restart named.service [root@jytest1 named]# nslookup jytest1 Server: 10.138.130.171 Address: 10.138.130.171#53 Name: jytest1.jydba.net Address: 10.138.130.171 [root@jytest1 named]# nslookup jytest1.jydba.net Server: 10.138.130.171 Address: 10.138.130.171#53 Name: jytest1.jydba.net Address: 10.138.130.171 [root@jytest1 named]# nslookup jytest2-priv.jydba.net Server: 10.138.130.171 Address: 10.138.130.171#53 ** server can't find jytest2-priv.jydba.net: NXDOMAIN [root@jytest1 named]# nslookup jytest2-vip.jydba.net Server: 10.138.130.171 Address: 10.138.130.171#53 Name: jytest2-vip.jydba.net Address: 10.138.130.176 [root@jytest1 named]# nslookup jytest-scan.jydba.net Server: 10.138.130.171 Address: 10.138.130.171#53 Name: jytest-scan.jydba.net Address: 10.138.130.178 Name: jytest-scan.jydba.net Address: 10.138.130.179 Name: jytest-scan.jydba.net Address: 10.138.130.177 [root@jytest1 named]# nslookup 10.138.130.179 Server: 10.138.130.171 Address: 10.138.130.171#53 179.130.138.10.in-addr.arpa name = jytest-scan.130.138.10.in-addr.arpa.
通過測試可以看到DNS通過正向與反向解析都是正常的,說明配置成功。
注意:
對于Linux 使用NetworkManager來控制網絡的操作系統,當主機重啟之前/etc/resolv.conf文件可能會被重寫。如果發生這種情況,需要對相應的網卡配置文件增加以下記錄
對于Oracle Linux 6修改類似文件 /etc/sysconfig/network-scripts/ifcfg-eth0 (ifcfg-eth2 etc.)
對于Oracle Linux 7修改類似文/etc/sysconfig/network-scripts/ifcfg-ens160 (ifcfg-ens34 etc.)
DNS1=10.138.130.171
DOMAIN=jydba.net
關于“Oracle Linux 7.1如何配置DNS服務”這篇文章就分享到這里了,希望以上內容可以對大家有一定的幫助,使各位可以學到更多知識,如果覺得文章不錯,請把它分享出去讓更多的人看到。
免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。