Showing posts with label DNS. Show all posts
Showing posts with label DNS. Show all posts

Thursday, 21 April 2016

BIND DNS Server Installation CentOS 6.5


1. Install package :

yum install bind* caching*

2. Edit Configuration File :

vim /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 { 127.0.0.1; 192.168.0.0/24; 0.0.0.0/0; };
    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     { localhost; 192.168.0.0/24; 0.0.0.0/0; };
    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";
};

logging {
        channel default_debug {
                file "data/named.run";
                severity dynamic;
        };
};

zone "." IN {
    type hint;
    file "named.ca";
};


zone"example.net" IN {
type master;
file "forward.example.net";
allow-update { none; };
};
zone"0.168.192.in-addr.arpa" IN {
type master;
file "reverse.example.net";
allow-update { none; };
};

zone"example.cc" IN {
type master;
file "forward.example.cc";
allow-update { none; };
};

zone"example.cc" IN {
type master;
file "forward.example.cc";
allow-update { none; };
};

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

:wq




3. Go to /var/named   and create zone for each required domain name.

forward.example.net & reverse.example.net

# vim  /var/named/forward.example.net

$TTL 86400
@   IN  SOA     ns1.example.net. root.example.net. (
        2011071001  ;Serial
        3600        ;Refresh
        1800        ;Retry
        604800      ;Expire
        86400       ;Minimum TTL
)
@       IN  NS          ns1.example.net.
@       IN  A           192.168.0.54
ns1       IN  A   192.168.0.54
redmine    IN    A    192.168.0.150
nagios    IN    A    192.168.100.120
share    IN    A    192.168.100.12
spark    IN    A    192.168.100.12
backup    IN    A    192.168.100.126
gitblit    IN    A    192.168.0.10
helpdesk    IN    A    192.168.100.140

:wq



# vim  /var/named/reverse.example.net


$TTL 86400
@   IN  SOA     ns1.example.net. root.example.net. (
        2011071001  ;Serial
        3600        ;Refresh
        1800        ;Retry
        604800      ;Expire
        86400       ;Minimum TTL
)
@       IN  NS          ns1.example.net.
@       IN  PTR         example.net.
54     IN  PTR         ns1.example.net.
120     IN      PTR     nagios.example.net.
12     IN      PTR     share.example.net.
150     IN      PTR     redmine.example.net.

:wq

Example :

iplastdigit  IN   PTR  subdomain-domainname


4. Restart named service

service named restart
chkconfig named on


Test :

dig redmine.example.net
ping redmine.example.net


Saturday, 12 March 2016

How DNS lookup works

DNS Lookup: How a Domain Name is Translated to an IP Address

At Catchpoint, we believe that fast DNS (Domain Name System) is just as important as fast content. DNS is what translates your familiar domain name (www.google.com) into an IP address your browser can use (173.194.33.174). This system is fundamental to the performance of your webpage, yet most people don’t fully understand how it works. Therefore, in order to help you better understand the availability and performance of your site, we will be publishing a series of blog articles to shed light on the sometimes complex world of DNS, starting with the basics.
For the sake of simplicity, this article is assuming there was no DNS cached anywhere, hence this is a worst case scenario. We will tackle DNS caching in future articles.
Before the page and any resource on the page is loaded, the DNS must be resolved so the browser can establish a TCP connection to make the HTTP request. In addition, for every external resource referenced by a URL, the DNS resolution must complete the same steps (per unique domain) before the request is made over HTTP. The DNS Resolution process starts when the user types a URL address on the browser and hits Enter. At this point, the browser asks the operating system for a specific page, in this case google.com.


Step 1: OS Recursive Query to DNS Resolver
Since the operating system doesn’t know where “www.google.com” is, it queries a DNS resolver. The query the OS sends to the DNS Resolver has a special flag that tells it is a “recursive query.” This means that the resolver must complete the recursion and the response must be either an IP address or an error.
For most users, their DNS resolver is provided by their Internet Service Provider (ISP), or they are using an open source alternative such as Google DNS (8.8.8.8) or OpenDNS (208.67.222.222). This can be viewed or changed in your network or router settings. At this point, the resolver goes through a process called recursion to convert the domain name into an IP address.
Settings
DNS Settings on a Mac (left) and Windows Settings for IPv4 Protocol of the network connection (right).


Step 2: DNS Resolver Iterative Query to the Root Server
The resolver starts by querying one of the root DNS servers for the IP of “www.google.com.” This query does not have the recursive flag and therefore is an “iterative query,” meaning its response must be an address, the location of an authoritative name server, or an error. The root is represented in the hidden trailing “.” at the end of the domain name. Typing this extra “.” is not necessary as your browser automatically adds it.
There are 13 root server clusters named A-M with servers in over 380 locations. They are managed by 12 different organizations that report to the Internet Assigned Numbers Authority (IANA), such as Verisign, who controls the A and J clusters. All of the servers are copies of one master server run by IANA.


Step 3: Root Server Response
These root servers hold the locations of all of the top level domains (TLDs) such as .com, .de, .io, and newer generic TLDs such as .camera.
The root doesn’t have the IP info for “www.google.com,” but it knows that .com might know, so it returns the location of the .com servers. The root responds with a list of the 13 locations of the .com gTLD servers, listed as NS or “name server” records.


Step 4:  DNS Resolver Iterative Query to the TLD Server
Next the resolver queries one of the .com name servers for the location of google.com. Like the Root Servers, each of the TLDs have 4-13 clustered name servers existing in many locations. There are two types of TLDs: country codes (ccTLDs) run by government organizations, and generic (gTLDs). Every gTLD has a different commercial entity responsible for running these servers. In this case, we will be using the gTLD servers controlled by Verisign, who run the .com, .net, .edu, and .gov among gTLDs.


Step 5: TLD Server Response
Each TLD server holds a list of all of the authoritative name servers for each domain in the TLD. For example, each of the 13 .com gTLD servers has a list with all of the name servers for every single .com domain. The .com gTLD server does not have the IP addresses for google.com, but it knows the location of google.com’s name servers. The .com gTLD server responds with a list of all of google.com’s NS records. In this case Google has four name servers, “ns1.google.com” to “ns4.google.com.”


Step 6: DNS Resolver Iterative Query to the Google.com NS
Finally, the DNS resolver queries one of Google’s name server for the IP of “www.google.com.”


Step 7: Google.com NS Response
This time the queried Name Server knows the IPs and responds with an A or AAAA address record (depending on the query type) for IPv4 and IPv6, respectively.
dns101



Step 8: DNS Resolver Response to OS
At this point the resolver has finished the recursion process and is able to respond to the end user’s operating system with an IP address.



Step 9: Browser Starts TCP Handshake
At this point the operating system, now in possession of www.google.com’s IP address, provides the IP to the Application (browser), which initiates the TCP connection to start loading the page. For more information of this process, we wrote a blog post on the anatomy of HTTP.
As mentioned earlier, this is worst case scenario in terms of the length of time to complete the resolution. In most cases, if the user has recently accessed URLs of the same domain, or other users relying on the same DNS resolver have done such requests, there will be no DNS resolution required, or it will be limited to the query on the local DNS resolver. We will cover this in later articles.
In this DNS non-cached case, four sets of DNS servers were involved, hence a lot could have gone wrong. The end user has no idea what is happening behind the scenes; they are simply are waiting for the page to load and all of these DNS queries have to happen before the browser can request the webpage.
This is why we stress the importance of fast DNS. You can have a fast and well-built site, but if your DNS is slow, your webpage will still have poor response time.


VERIFICATION:
http://simpledns.com/lookup-dg.aspxDNS Request Trace

Sunday, 6 March 2016

Installing MyDNS And The MyDNSConfig Control Panel On CentOS 6.5


Installing MyDNS And The MyDNSConfig Control Panel On CentOS 6.4  
============================================


Server IP:- 66.85.156.87
Hostname :- dns.example.com 

    In this tutorial I will describe how to install and configure MyDNS and MyDNSConfig on CentOS 6.4.
MyDNS is a DNS server that uses a MySQL database as backend instead of configuration files like, for example, Bind or djbdns.
The advantage is that MyDNS simply reads the records from the database, and it does not have to be restarted/reloaded when DNS records change or zones are created/edited/deleted.
A secondary nameserver can be easily set up by installing a second instance of MyDNS that accesses the same database or, to be more redundant,
uses the MySQL master / slave replication features to replicate the data to the secondary nameserver.

   MyDNSConfig is an easy to use web-based interface to MyDNS. MyDNSConfig can create all types of DNS records that are available in MyDNS,
and adds features like user management and access privileges.

Installation:-

First we enable the RPMforge repository on our CentOS system as some of the packages that we are going to install.

Create download directory
[root@server~]# mkdir download
[root@server~]# cd download/
[root@server~]# wget  http://apt.sw.be/redhat/el6/en/x86_64/rpmforge/RPMS/rpmforge-release-0.5.3-1.el6.rf.x86_64.rpm       
[root@server~]# rpm -ivh rpmforge-release-0.5.3-1.el6.rf.x86_64.rpm

MyDNSConfig is a web-based interface to MyDNS written in PHP. This requires a webserver with PHP enabled and the MySQL database server.
Lets we setup LAMP Server for this.

Installing Apache2 With PHP5 And MySQL Support On CentOS 6.4 (LAMP)

[root@server~]# yum install mysql mysql-server
[root@server~]# chkconfig mysqld on
[root@server~]# /etc/init.d/mysqld start
[root@server~]# mysql_secure_installation


NOTE: RUNNING ALL PARTS OF THIS SCRIPT IS RECOMMENDED FOR ALL MySQL
      SERVERS IN PRODUCTION USE!  PLEASE READ EACH STEP CAREFULLY!


In order to log into MySQL to secure it, we'll need the current
password for the root user.  If you've just installed MySQL, and
you haven't set the root password yet, the password will be blank,
so you should just press enter here.

Enter current password for root (enter for none):
OK, successfully used password, moving on...

Setting the root password ensures that nobody can log into the MySQL
root user without the proper authorisation.

Set root password? [Y/n] <-- ENTER
New password: <-- yourrootsqlpassword
Re-enter new password: <-- yourrootsqlpassword
Password updated successfully!
Reloading privilege tables..
 ... Success!


By default, a MySQL installation has an anonymous user, allowing anyone
to log into MySQL without having to have a user account created for
them.  This is intended only for testing, and to make the installation
go a bit smoother.  You should remove them before moving into a
production environment.

Remove anonymous users? [Y/n] <-- ENTER
 ... Success!

Normally, root should only be allowed to connect from 'localhost'.  This
ensures that someone cannot guess at the root password from the network.

Disallow root login remotely? [Y/n] <-- ENTER
 ... Success!

By default, MySQL comes with a database named 'test' that anyone can
access.  This is also intended only for testing, and should be removed
before moving into a production environment.

Remove test database and access to it? [Y/n] <-- ENTER
 - Dropping test database...
 ... Success!
 - Removing privileges on test database...
 ... Success!

Reloading the privilege tables will ensure that all changes made so far
will take effect immediately.

Reload privilege tables now? [Y/n] <-- ENTER
 ... Success!

Cleaning up...



All done!  If you've completed all of the above steps, your MySQL
installation should now be secure.

Thanks for using MySQL!


[root@server~]# yum install httpd
[root@server~]# chkconfig httpd on
[root@server~]# /etc/init.d/httpd start

Now direct your browser and you should see the Apache2 placeholder page: [e.g http://192.168.0.100]

[root@server~]# yum install php*
[root@server~]# /etc/init.d/httpd restart

The document root of the default web site is /var/www/html. We will now create a small PHP file (info.php) in that directory and call it in a browser. The file will display lots of useful details about our PHP installation, such as the installed PHP version.

[root@server~]# vi /var/www/html/info.php
     
<?php
phpinfo();
?>

:wq

[root@server~]# /etc/init.d/httpd restart

Now we call that file in a browser (e.g. http://192.168.0.100/info.php)

Ensure below packages are installed.

php-mysql php-gd php-imap php-ldap php-mbstring php-odbc php-pear php-xml php-xmlrpc php-pecl-apc 

if now then you need to install manually with yum install command

phpMyAdmin:-

 is a web interface through which you can manage your MySQL databases.

First we enable the RPMforge repository on our CentOS system as phpMyAdmin is not available in the official CentOS 6.4 repositories:

Import the RPMforge GPG key:

[root@server~]# rpm --import http://dag.wieers.com/rpm/packages/RPM-GPG-KEY.dag.txt

[root@server~]# yum install http://pkgs.repoforge.org/rpmforge-release/rpmforge-release-0.5.2-2.el6.rf.x86_64.rpm

[root@server~]# yum install phpmyadmin

 Now we configure phpMyAdmin. We change the Apache configuration so that phpMyAdmin allows connections not just from localhost (by commenting out the <Directory "/usr/share/phpmyadmin"> stanza):

[root@server~]# vi /etc/httpd/conf.d/phpmyadmin.conf

#
#  Web application to manage MySQL
#

#<Directory "/usr/share/phpmyadmin">
#  Order Deny,Allow
#  Deny from all
#  Allow from 127.0.0.1
#</Directory>

Alias /phpmyadmin /usr/share/phpmyadmin
Alias /phpMyAdmin /usr/share/phpmyadmin
Alias /mysqladmin /usr/share/phpmyadmin

Next we change the authentication in phpMyAdmin from 'cookie' to 'http':

[root@server~]# vi /usr/share/phpmyadmin/config.inc.php

[...]
/* Authentication type */
$cfg['Servers'][$i]['auth_type'] = 'http';
[...]

:wq

[root@server~]# /etc/init.d/httpd restart 

Afterwards, you can access phpMyAdmin under http://192.168.0.100/phpmyadmin/

3 Installing MyDNSConfig:-
==========================


Log in to MySQL and create the database:

[root@server~]# mysql -u root -p
<Enter MySQL Password>

CREATE DATABASE mydns;
GRANT SELECT, INSERT, UPDATE, DELETE ON mydns.* TO 'mydns'@'localhost' IDENTIFIED BY 'mydnspassword';
GRANT SELECT, INSERT, UPDATE, DELETE ON mydns.* TO 'mydns'@'localhost.localdomain' IDENTIFIED BY 'mydnspassword';
FLUSH PRIVILEGES;
quit;


OR

CREATE USER 'mydns'@'%' IDENTIFIED BY 'Mysql@212';
grant all on *.* to 'mydns'@'%' with grant option;
flush privileges;


Replace the word mydnspassword in the above commands with a password of your choice.

Download MyDNSConfig:

[root@server~]# cd download
[root@server~]# wget http://liquidtelecom.dl.sourceforge.net/project/mydnsconfig/mydnsconfig/MyDNSConfig-3.0.1/MyDNSConfig-3.0.1.tar.gz
[root@server~]# tar -xvfz MyDNSConfig-1.1.0.tar.gz
[root@server~]# cd MyDNSConfig-1.1.0

Install MyDNSConfig:

[root@server~]# mkdir /usr/share/mydnsconfig
[root@server~]# cp -rf interface/* /usr/share/mydnsconfig/
[root@server~]# ln -s /usr/share/mydnsconfig/web/ /var/www/html/mydnsconfig

Install the MyDNSConfig MySQL Database:

[root@server~]# mysql -u root -p mydns < install/mydnsconfig.sql

The command above asks for a password, please enter the password of the MySQL root user.

Edit the MyDNSConfig configuration; please make sure you fill in the correct database settings:

[root@server~]# vim /usr/share/mydnsconfig/lib/config.inc.php


        Database Settings
*/

$conf["db_type"]        = 'mysql';
$conf["db_host"]        = 'localhost';    -->  keep as it
$conf["db_database"]    = 'mydns';
$conf["db_user"]        = 'mydns';
$conf["db_password"]    = 'mydnspassword';

/*

:wq

Afterwards, you can remove the downloaded MyDNSConfig installer from the download directory:

[root@server~]# cd download
[root@server~]# rm -rf MyDNSConfig-1.1.0/
[root@server~]# rm -f MyDNSConfig-1.1.0.tar.gz
[root@server~]# wget http://mydns.bboy.net/download/mydns-mysql-1.1.0-1.i386.rpm
[root@server~]# rpm -ivh mydns-mysql-1.1.0-1.i386.rpm

Open the MyDNS configuration file /etc/mydns.conf, fill in the correct database details, allow zone transfers by setting allow-axfr to yes, enable TCP (allow-tcp = yes), and specify a recursive resolver (i.e., a valid nameserver, e.g. from your ISP; e.g. recursive = 213.191.92.86) so that MyDNS can answer queries for domains that it isn't authoritative for:

OR


log = LOG_DAEMON                # Facility to use for program output (LOG_*/stdout/stderr)
pidfile = /var/run/mydns.pid    # Path to PID file
timeout = 120                   # Number of seconds after which queries time out
multicpu = 1                    # Number of CPUs installed on your system
recursive = 213.191.92.86       # Location of recursive resolver
allow-axfr = yes                # Should AXFR be enabled?
allow-tcp = yes                 # Should TCP be enabled?
allow-update = no               # Should DNS UPDATE be enabled?
ignore-minimum = no             # Ignore minimum TTL for zone?
soa-table = soa                 # Name of table containing SOA records
rr-table = rr                   # Name of table containing RR data
soa-where =                     # Extra WHERE clause for SOA queries
rr-where =                      # Extra WHERE clause for RR queries


[root@server~]# vim /etc/mydns.conf

Next, create the system startup links for MyDNS and start MyDNS:

[root@server~]# chkconfig mydns on
[root@server~]# /etc/init.d/mydns start

Finally, we need to fix the system startup links for MyDNS. MyDNS depends on MySQL, so MyDNS must start after MySQL has started, otherwise it will fail. The default startup links for MyDNS make it start before MySQL which is wrong, so we fix this as follows:

[root@server~]# cd /etc/rc.d/rc3.d
[root@server~]# mv S52mydns S99mydns     << ---  here name will be differenet please check proper
[root@server~]# cd /etc/rc.d/rc4.d
[root@server~]# mv S52mydns S99mydns     << ---  here name will be differenet please check proper
[root@server~]# cd /etc/rc.d/rc5.d
[root@server~]# mv S52mydns S99mydns     << ---  here name will be differenet please check proper

MySQL uses the startup links S64mysql, so renaming the MyDNS startup links from S52mydns to S99mydns makes sure that MyDNS starts after MySQL.

The basic installation of MyDNS and MyDNSConfig is now finished. To log in to the MyDNSConfig interface, open a web browser and enter enter the following URL:

http://<your_ip_address>/mydnsconfig/

Replace <your_ip_address> with the IP address of your server.

The default username and password of MyDNSConfig are:

Username: admin
Password: admin

Don't forget to change the password after login under System > Users.

   
######### Reference Links ##############

http://www.howtoforge.com/installing-mydns-mydnsconfig-centos-5.1                                   <---- For MyDNS Installation                                
http://www.howtoforge.com/installing-apache2-with-php5-and-mysql-support-on-centos-6.4-lamp         <---- For LAMP Installation



https://www.howtoforge.com/installing-mydns-mydnsconfig-fedora8-p2