1.环境
内网IP:192.168.3.8
系统:Centos7
2.安装
yum -y install bind*
3.修改bind配置文件
vi /etc/named.conf
options {
listen-on port 53 { 127.0.0.1; any; };
#监听任何ip对53端口的请求
allow-query { localhost; any; };
#接收任何来源查询dns记录
#增加一个xls.com域名的解析,解析规则在/var/named/xls.com.zone里
zone "xls.com" IN {
type master;
file "xls.com.zone";
};
4.配置解析文件
[root@xls named]# cat xls.com.zone
$TTL 1D
@ IN SOA @ root.xls.com. (
0 ; serial
1D ; refresh
1H ; retry
1W ; expire
3H ) ; minimum
NS @
A 192.168.3.8 ;
www A 192.168.3.8 ;
@ MX 10 mx.xls.com. ;
AAAA ::1
5.启动bind
systemctl start named
systemctl enable named
6.修改DNS
vi /etc/resolv.conf
# Generated by NetworkManager
nameserver 192.168.3.8
7.开始测试
[root@xls named]# ping xls.com -c 2
PING xls.com (192.168.3.8) 56(84) bytes of data.
64 bytes from xls (192.168.3.8): icmp_seq=1 ttl=64 time=0.035 ms
64 bytes from xls (192.168.3.8): icmp_seq=2 ttl=64 time=0.088 ms
--- xls.com ping statistics ---
2 packets transmitted, 2 received, 0% packet loss, time 1000ms
rtt min/avg/max/mdev = 0.035/0.061/0.088/0.027 ms
[root@xls named]# ping www.xls.com -c 2
PING www.xls.com (192.168.3.8) 56(84) bytes of data.
64 bytes from xls (192.168.3.8): icmp_seq=1 ttl=64 time=0.050 ms
64 bytes from xls (192.168.3.8): icmp_seq=2 ttl=64 time=0.090 ms
--- www.xls.com ping statistics ---
2 packets transmitted, 2 received, 0% packet loss, time 1001ms
rtt min/avg/max/mdev = 0.050/0.070/0.090/0.020 ms
[root@xls named]# nslookup xls.com
Server: 192.168.3.8
Address: 192.168.3.8#53
Name: xls.com
Address: 192.168.3.8
[root@xls named]# dig www.xls.com
; <<>> DiG 9.9.4-RedHat-9.9.4-74.el7_6.2 <<>> www.xls.com
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 48024
;; flags: qr aa rd ra; QUERY: 1, ANSWER: 1, AUTHORITY: 1, ADDITIONAL: 3
;; OPT PSEUDOSECTION:
; EDNS: version: 0, flags:; udp: 4096
;; QUESTION SECTION:
;www.xls.com. IN A
;; ANSWER SECTION:
www.xls.com. 86400 IN A 192.168.3.8
;; AUTHORITY SECTION:
xls.com. 86400 IN NS xls.com.
;; ADDITIONAL SECTION:
xls.com. 86400 IN A 192.168.3.8
xls.com. 86400 IN AAAA ::1
;; Query time: 0 msec
;; SERVER: 192.168.3.8#53(192.168.3.8)
;; WHEN: 四 8月 08 20:34:12 CST 2019
;; MSG SIZE rcvd: 114