DNS (Domain Name Server, domain name server) is a server that converts a domain name (domain name) and its corresponding IP address (IP address). |
Environmental description
Server IP 10.68.19.61
Operating system Ubuntu 13.04
DNS program Bind9
Test domain mycloud.com
Target IP 10.68.19.134
Installation and configuration of BIND9
apt-get install bind9
A total of 2 files need to be edited and 2 new files are added as follows: Modify /etc/bind/named.conf.options, remove the comment of forwarders, the IP is the DNS server provided by the network operator, here we use Google's DNS .
forwarders { 8.8.8.8; 8.8.4.4; };
Modify /etc/bind/named.conf.local and add two-way analysis code at the end:
zone "mycloud.com" { type master; file "/etc/bind/db.mycloud.com"; }; zone "19.68.10.in-addr.arpa" { type master; file "/etc/bind/db.10.68.19"; };
Note: 19.68.10 is the first three segments of the target IP 10.68.19.134, representing an IP address segment.
Added a new domain name (mycloud.com) parsing file /etc/bind/db.mycloud.com, the content is as follows:
; ; BIND data file for dev sites ; $TTL 604800 @ IN SOA mycloud.com. root.mycloud.com. ( 1 ; Serial 604800 ; Refresh 86400 ; Retry 2419200 ; Expire 604800 ) ; Negative Cache TTL ; @ IN NS mycloud.com. @ IN A 10.68.19.134 *.mycloud.com. 14400 IN A 10.68.19.134
The newly added IP address reverse analysis file /etc/bind/db.10.68.19, the content is as follows:
; ; BIND reverse data file for dev domains ; $TTL 604800 @ IN SOA dev. root.dev. ( 1 ; Serial 604800 ; Refresh 86400 ; Retry 2419200 ; Expire 604800 ) ; Negative Cache TTL ; @ IN NS mycloud.com. 134 IN PTR mycloud.com.
Restart the BIND9 service
service bind9 restart
Modify the local configuration
Modify each dns configuration file that needs to use the DNS server
south you /etc/resolv.conf
Modify nameserver to the DNS server IP configured above
nameserver 10.68.19.61
This modification will be overwritten every time the server is restarted, and the configuration file can be modified
south vi /etc/resolvconf/resolv.conf.d/base
Add one
nameserver 10.68.19.61
After restarting the server, the DNS configuration is still valid, and then restart the network service to refresh the DNS cache.
service networking restart
Test effect
root@controller:/etc/bind# nslookup > baidu.com Server: 10.68.19.61 Address: 10.68.19.61#53 Non-authoritative answer: Name: baidu.com Address: 220.181.111.86 Name: baidu.com Address: 123.125.114.144 Name: baidu.com Address: 220.181.111.85 > mycloud.com Server: 10.68.19.61 Address: 10.68.19.61#53 Name: mycloud.com Address: 10.68.19.134 > uaa.mycloud.com Server: 10.68.19.61 Address: 10.68.19.61#53 Name: uaa.mycloud.com Address: 10.68.19.134
The resolution is: domain name: baidu.com, no match is found in the local DNS, and it is resolved through DNS: 8.8.8.8, and mycloud.com has a match in the local DNS, which resolves to 10.68.19.134.
This article address: https://www.linuxprobe.com/ubuntu-dns.html