The DNS translates Internet domain and host names to IP addresses.
DNS automatically converts the names we type in our Web browser address
bar to the IP addresses of Web servers hosting those sites.
DNS implements a distributed database to store this name and address
information for all public hosts on the Internet. DNS assumes IP
addresses do not change (are statically assigned rather than dynamically
assigned).
The DNS database resides on a hierarchy of special database servers.
When clients like Web browsers issue requests involving Internet host
names, a piece of software called the DNS resolver (usually built into the network operating system) first contacts a DNS server
to determine the server's IP address. If the DNS server does not
contain the needed mapping, it will in turn forward the request to a
different DNS server at the next higher level in the hierarchy. After
potentially several forwarding and delegation messages are sent within
the DNS hierarchy, the IP address for the given host eventually arrives
at the resolver, that in turn completes the request over Internet
Protocol.
DNS additionally includes support for caching requests and for redundancy.
Most network operating systems support configuration of primary,
secondary, and tertiary DNS servers, each of which can service initial
requests from clients. Internet Service Providers (ISPs) maintain their own DNS servers and use DHCP to automatically configure clients, relieving most home users of the burden of DNS configuration.
History
Using a simpler, more memorable name in place of a host's numerical address dates back to the ARPANET era. The staff at Stanford Research Institute created and updated a file named Hosts.TXT that mapped intelligible names to the numerical addresses of computers
on ARPANET. SRI transmitted this file, and updates of this file, to each
computer connected to ARPANET, which later became the Internet
The Internet's rapid growth required an automated system for
maintaining and distributing domain names and their corresponding
numerical addresses, to replace SRI's centrally maintained, manually
entered Hosts.TXT file.
The original UNIX implementation was done by four graduate students in Berkeley in 1984. It was then added to Berkeley UNIX distribution in the mid 1985 and known as BIND (Berkeley Internet Name Domain). It is a open source project.
Bind is available for UNIX/Linux as well as Windows. Since the DNS protocol is standardized. UNIX and non-UNIX DNS implementations can all inter-operate and share data.
In the beginning, BIND was the only DNS implementation in widespread use. Today there are several;
- BIND, author is ISC.
- NSD, author is NLnet Labs.
- PowerDNS, author is PowerDNS BV.
- djbdns, author is Danbernstein.
- Microsoft DNS, author is Microsoft.
- ANS, CNS author is Nominum.
DNS defines;
- A hierarchical name space for hosts and IP addresses.
- A distributed database of host name and address information.
- A resolver to query this database.
- Improved routing for email.
- A mechanism for finding services on a network.
- A protocol for exchanging naming information.
DNS is a client/server system. Servers load the data from your DNS files into memory and use it to answer queries both from internal clients and from clients and other servers out on the Internet.
The DNS Name space.
The DNS name space is an
important part of DNS, as it gives an understanding of why domain
names look the way they do, and how DNS works. The namespace refers
to the hierarchical layout of DNS names; the DNS namespace is laid
out in an inverted tree. This means the root of the tree is at the
top, and the branches of the tree grow downwards. At the top of the
DNS namespace is the root (dot); all domain names start at the root
which is defined by a null character. Note that domain names read
from right to left, that is the highest level of the name space, the
root, is the furthest right portion of the DNS name. The root is not
normally explicitly specified in user applications, as most
applications assume it. It is often explicitly specified in DNS
server configuration files and is denoted by a trailing period. Below
the root in the DNS namespace, are the top level domains or TLDs.
These are the highest names in the name space, for example, .com or
.net. These TLDS are maintained by the Internet corporation for
assigned names and numbers, or ICAN, for Internet use.
In the USA, top level domains originally described organizational and political structure were given three letter names such as com or edu. Some of these domains are used outside the USA as well, they are called generic top-level domains or gTLDs for short.
The top level domains were fixed by ICANN. Most important gLDs,
| .edu | USA educational Institutions |
| .gov | USA governmental |
| .mil | US military |
| .aero | air-transport industry |
| .asia | Asia-Pacific region |
| .biz | business |
| .cat | Catalan |
| .com | commercial |
| .coop | cooperatives |
| .info | information |
| .int | international organizations |
| .jobs | companies |
| .mobi | mobile devices |
| .museum | museums |
| .name | individuals, by name |
| .net | network |
| .org | organization |
| .post | postal services |
| .pro | professions |
| .tel | Internet communication services |
| .travel | travel and tourism industry related sites |
| .xxx | adult entertainment |
Country code Top-Level Domain.
DNS Configuration.
Port 53 is used for DNS. Here we describe the basic setup for BIND and PowerDNS.
BIND.
BIND is an implementation of the Domain Name System (DNS) protocols. The name BIND stands for “Berkeley Internet Name Domain”, because the software originated in the early 1980s at the University of California at Berkeley. In recent years, the word BIND has become, like “radar” and “laser”, more word than acronym.
The DNS protocols are part of the core Internet standards. They specify the process by which one computer can find another computer on the basis of its name. ‘An implementation of DNS protocols’ means our software distribution contains all of the software necessary for asking and answering name service questions.
The BIND software distribution has three parts:
A Domain Name System server
A program called “named” (pronounced “name-dee”), which stands for Name Daemon, answers all received questions by following the rules specified in the DNS protocol standards. You can provide DNS services on the Internet by installing this software on a server computer and giving it correct information about your domain names.
A Domain Name System resolver library
A resolver is a program that resolves questions about names by sending those questions to appropriate servers and responding appropriately to the servers’ replies. A resolver library is a collection of software components that a programmer can add to software being developed, which will give that software the ability to resolve names. For example, a programmer who was programming a new web browser does not need to create the part of it that looks up names in DNS; he or she can plug in the resolver library and then send questions to the library software components. This saves time (the programmer does not need to re-invent that particular wheel) and helps ensure that the new browser correctly follows the DNS standards.
Software tools for testing servers
These are the tools we use, and we include them in the distribution to assist you with your own diagnostics.
When you install an operating system on your computer, that operating system will contain whatever resolver library its developers selected for it. When you set up a server computer, its vendor usually has provided some DNS server software (usually BIND) so that the server will work as delivered. Because BIND faithfully implements the DNS protocols, there is no need for the resolver (which asks questions) and the server (which answers questions) to be running the same software.
Install BIND
root@debian:#apt-get install bind
- Edit named file.
root@debian:#nano /etc/bind/named.conf
On the last part can see one line include "/etc/bind/named.conf.local"; Use Ctrl + K (Cut) the line and use Ctrl +U to paste it twice. Now change the name to preffered one.
include "/etc/bind/named.conf.local";
include "/etc/bind/growwithlinux.com.conf";
- Copy named.conf to growwithlinux.com.conf
root@debian:#cp /etc/bind/named.conf /etc/bind.growwithlinux.com.conf
- Edit growwithlinux.com.conf
root@debian:#nano /etc/bind/growwithlinux.com.conf
Keep the below part and delete rest all on that file.
zone "localhost" {
type master;
file "/etc/bind/db.local";
};
zone "127.in-addr.arpa" {
type master;
file "/etc/bind/db.127";
};
Change the above file to
zone "growwithlinux.com" {
type master;
file "/etc/bind/growwithlinux.com.f";
};
zone "16.168.in-addr.arpa" {
type master;
file "/etc/bind/growwithlinux.com.r";
};
Here in forward zone give the prescribed data and in reserve zone give the network part of the IP address in reserve example the IP address In B Class is 168.16.56.29 just 16.168. If C Class IP address 192.168.29.50 just 29.168.192.
root@debian:#cp /etc/bind/db.127 /etc/bind/growwithlinux.com.r
;
; BIND data file for local loopback interface
;
$TTL 604800
@ IN SOA growwithlinux.com. root.growwithlinux.com. (
2 ; Serial
604800 ; Refresh
86400 ; Retry
2419200 ; Expire
604800 ) ; Negative Cache TTL
;
@ IN NS growwithlinux.com.
IN MX0 mail.growwithlinux.com.
IN A 168.16.56.29
www IN A 168.16.56.29
mail IN A 168.16.56.30
game IN A 168.16.56.31
type master;
file "/etc/bind/growwithlinux.com.f";
};
zone "16.168.in-addr.arpa" {
type master;
file "/etc/bind/growwithlinux.com.r";
};
Here in forward zone give the prescribed data and in reserve zone give the network part of the IP address in reserve example the IP address In B Class is 168.16.56.29 just 16.168. If C Class IP address 192.168.29.50 just 29.168.192.
- Copy the forward and reverse files.
root@debian:#cp /etc/bind/db.127 /etc/bind/growwithlinux.com.r
- Edit the forward file.
;
; BIND data file for local loopback interface
;
$TTL 604800
@ IN SOA growwithlinux.com. root.growwithlinux.com. (
2 ; Serial
604800 ; Refresh
86400 ; Retry
2419200 ; Expire
604800 ) ; Negative Cache TTL
;
@ IN NS growwithlinux.com.
IN MX0 mail.growwithlinux.com.
IN A 168.16.56.29
www IN A 168.16.56.29
mail IN A 168.16.56.30
game IN A 168.16.56.31
- Edit the reverse file
root@debian:#nano /etc/bind/growwithlinux.com.r
;
; BIND reverse data file for local loopback interface
;
$TTL 604800
@ IN SOA growwithlinux.com. root.growwithlinux.com. (
1 ; Serial
604800 ; Refresh
86400 ; Retry
2419200 ; Expire
604800 ) ; Negative Cache TTL
;
@ IN NS growwithlinux.com.
29.56 IN PTR growwithlinux.com.
29.56 IN PTR www.growwithlinux.com.
30.56 IN PTR mail.growwithlinux.com.
31.56 IN PTR game.growwithlinux.com.
- Restart the Service
Don't forget to update the serial number and reload the name servers.
Don't forget to add dot at the end of the hostname in the PTR reverse entry.
For checking the DNS use;
#dig {address.com}
Install PowerDNS
PowerDNS is a DNS server, written in C++ and licensed under the GPL. It runs on most Unix derivatives. PowerDNS features a large number of different backends ranging from simple BIND style zonefiles to relational databases and load balancing/failover algorithms. A DNS recursor is also included as a separate program.PowerDNS is a product of the Dutch company PowerDNS.COM BV, with numerous contributions from the open source community. The principal author is Bert Hubert.
- Database Configuration
Install MariaDB
# apt-get install MariaDB-server
# apt-get install MariaDB-client
Configure MariaDB
#nano /etc/my.cnf.d/server.conf
[server]
bind-address=127.0.0.1
# service mysql start
# /usr/bin/mysql_secure_installation
Create an sql script to create mariadb database for storing DNS records
# nano /root/pdns.sql
CREATE DATABASE pdb;
GRANT ALL ON pdb.* TO 'growwithlinux'@'localhost' IDENTIFIED BY 'password';
GRANT ALL ON pdb.* TO 'growwithlinux'@'localhost.localdomain' IDENTIFIED BY 'password';
FLUSH PRIVILEGES;
CREATE TABLE domains (
id INT auto_increment,
name VARCHAR(255) NOT NULL,
master VARCHAR(128) DEFAULT NULL,
last_check INT DEFAULT NULL,
type VARCHAR(6) NOT NULL,
notified_serial INT DEFAULT NULL,
account VARCHAR(40) DEFAULT NULL,
primary key (id)
);
CREATE UNIQUE INDEX name_index ON domains(name);
CREATE TABLE records (
id INT auto_increment,
domain_id INT DEFAULT NULL,
name VARCHAR(255) DEFAULT NULL,
type VARCHAR(10) DEFAULT NULL,
content VARCHAR(64000) DEFAULT NULL,
ttl INT DEFAULT NULL,
prio INT DEFAULT NULL,
change_date INT DEFAULT NULL,
primary key(id)
);
CREATE TABLE domains (
id INT auto_increment,
name VARCHAR(255) NOT NULL,
master VARCHAR(128) DEFAULT NULL,
last_check INT DEFAULT NULL,
type VARCHAR(6) NOT NULL,
notified_serial INT DEFAULT NULL,
account VARCHAR(40) DEFAULT NULL,
primary key (id)
);
CREATE UNIQUE INDEX name_index ON domains(name);
CREATE TABLE records (
id INT auto_increment,
domain_id INT DEFAULT NULL,
name VARCHAR(255) DEFAULT NULL,
type VARCHAR(10) DEFAULT NULL,
content VARCHAR(64000) DEFAULT NULL,
ttl INT DEFAULT NULL,
prio INT DEFAULT NULL,
change_date INT DEFAULT NULL,
primary key(id)
);
CREATE INDEX nametype_index ON records(name,type);
CREATE INDEX domain_id ON records(domain_id);
CREATE TABLE supermasters (
ip VARCHAR(64) NOT NULL,
nameserver VARCHAR(255) NOT NULL,
account VARCHAR(40) DEFAULT NULL
);
Create database from sql script
#mysql -u root -p < /root/pdns.sql
- PowerDNS Configuration.
Install PowerDNS
#apt-get install pdns pdns-backend-mysql
Configure mysql backend credentials in PowerDNS
#nano /etc/pdns/pdns.conf
launch=gmysql
gmysql-host=127.0.0.1
gmysql-user=padmin
gmysql-password=p1234
gmysql-dbname=pdb
Start PowerDNS
#service pdns start
Install Apache webserver
#apt-get install httpd
Install php
#apt-get install php php-devel php-gd php-imap php-ldap php-mysql php-odbc php-pear php-xml php-xmlrpc php-mbstring php-mcrypt gettext php-pear-DB php-pear-MDB2-Driver-mysql
Configure Apache webserver
#nano /etc/httpd/conf/httpd.conf
ServerName 10.10.10.3:80
Start Apache webserver
#service httpd start
Check php configurations by looking at http://10.10.10.3/info.php after saving below file
#nano /var/www/html/info.php
<?php
phpinfo();
?>
Download PowerAdmin
# wget https://github.com/downloads/poweradmin/poweradmin/poweradmin-2.1.6.tgz
# tar -xvzf poweradmin-2.1.6.tgz
# cp -pr poweradmin-2.1.6 /var/www/html/poweradmin
# chown -R root:root /var/www/html/poweradmin
Login to PowerAdmin web install
http://10.10.10.3/poweradmin/install
Select option “I prefer to proceed in English” in installation step 1
Proceed to next page in installation step 2
Enter below details in installation step 3
Username=growwithlinux
Password=password
Database type=MySQL
Hostname=127.0.0.1
DB Port=3306
Database=pdb
Poweradmin administrator password=admin1234
Enter below details in installation step 4
Username=admin
Password=admin1234
Hostmaster=hostmaster.test.lab
Primary nameserver=ns1.test.lab
Secondary nameserver=ns2.test.lab
Run the sql query displayed in installation step 5 inside MariaDB
#mysql -u root -p
Save the contents printed on the page to /var/www/html/poweradmin/inc/config.inc.php in installation step 6
Remove install directory and login to poweradmin website using the specified link and credentials in installation step 7
# rm -rf /var/www/html/poweradmin/install
- DNS Record Creation.
Create a master zone example.com and below records in it
www.growwithlinux.com A 192.168.10.10
internal.growwithlinux.com A 192.168.10.20
mail.growwithlinux.com MX internal.growwithlinux.com
chat.growwithlinux.com CNAME www.growwithlinux.com
192.168.10.20 PTR internal.growwithlinux.com
Install DNS client dig
# apt-get install bind-utils
Query PowerDNS server using dig to return above records
# dig @10.10.10.3 www.growwithlinux.com A
# dig @10.10.10.3 internal.growwithlinux.com A
# dig @10.10.10.3 mail.growwithlinux.com MX
# dig @10.10.10.3 chat.growwithlinux.com
# dig @10.10.10.3 192.168.10.20.growwithlinux.com PTR
Log in to MariaDB and show stored DNS records in database
# mysql -u root -p
mysql> use pdb;
mysql> select * from domains;
mysql> select * from records;
mysql> exit;
No comments:
Post a Comment