Wednesday, February 08, 2012

Apache with DNS Server


Introduction:-
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. Domain Name System to determine the IP address associated with a domain name. This process is also known as forward DNS resolution. Reverse DNS lookup is the inverse process, the resolution of an IP address to its designated domain name.

Requirement:-
  • Package = bind, caching, httpd
  • Service = named, httpd
  • Port no. = 53 – DNS, 80 – HTTP
  • Configuration file = /etc/named.caching-nameserver.conf
           /etc/named.rfc1912.zones
           /etc/httpd/conf/httpd.conf
Per quest:-
  • Configure Server IP - 192.168.1.1
  • Configure Virtual IP – 192.168.1.10 & 192.168.1.20
  • Configure Server Hostname – server.rootuser.in
Configure DNS Server:-
1] Install required packages for DNS.
[root@server ~]# yum install bind* caching* -y

2] Edit main configuration file of DNS.
[root@server ~]# vi /etc/named.caching-nameserver.conf
listen-on port 53 { 127.0.0.1; 192.168.1.1;};
allow-query { none; 192.168.1.0/24;};
match-clients { none; 192.168.1.0/24;};
:wq

3] Add the website zone in rfc1912.zones file.
[root@server ~]# vi /etc/named.rfc1912.zones
#Go to end of the file and type as follows.
zone “rootuser.in” IN {
type master;
file “localhost.zone”;
allow-update { none; };
};
zone “anup.com” IN {
type master;
file “localhost.zone”;
allow-update { none; };
};
zone “shubham.com” IN {
type master;
file “localhost.zone”;
allow-update { none; };
};
zone “1.168.192.in-addr.arpa” IN {
type master;
file “named.local”;
allow-update { none; };
};
:wq

4] Now configure zone files.
[root@server ~]# cd /var/named/chroot/var/named
[root@server named]# cp localhost.zone localhost.zone.backup
[root@server named]# vi localhost.zone
$TTL 86400
@          SOA         server.rootuser.in.       root (
                                              42 ; serial
                                              3H ; refresh
                                              15M ; retry
                                              1W ; expiry
                                              1D ) ; minimum
                                 IN NS server.rootuser.in.
rootuser.in               IN A 192.168.1.1
www.anup.com         IN A 192.168.1.10
www.shubham.com  IN A 192.168.1.20
:wq

[root@server named]# cp named.local named.local.backup
[root@server named]# vi named.local
$TTL 86400
@          SOA         server.rootuser.in.      root.localhost. (
                                            1997022700 ; Serial
                                            28800 ; Refresh
                                            14400 ; Retry
                                            3600000 ; Expiry
                                            86400 ) ; Minimum
             IN NS server.rotuser.in.
1           IN PTR server.rootuser.in.
10         IN PTR www.anup.com.
20         IN PTR www.shubham.com.
:wq

[root@server named]# cd

5] Set primary DNS server.
[root@server ~]# vi /etc/resolv.conf
nameserver 192.168.1.1
:wq

6] Start named service.
[root@server ~]# service named start
[root@server ~]# chkconfig named on

7] Use following command to test DNS server.
[root@server ~]# dig server.rootuser.in
[root@server ~]# dig www.anup.com
[root@server ~]# dig www.shubham.com
[root@server ~]# nslookup anup.com
[root@server ~]# nslookup shubham.com

Configure Aapche Web Server:-
8] Now install packeges for apache web server.
[root@server ~]# yum install http* -y

9] Edit & Append the following line in httpd.conf file.
[root@server ~]# vi /etc/httpd/conf/httpd.conf
#Name VirtualHosts *:80 --> Name VirtualHosts 192.168.1.1:80

#Go to end of file.
<VirtualHost 192.168.1.1:80>
ServerAdmin root@server.rootuser.in
DocumentRoot /var/www/html/rootuser.in
ServerName server.rootuser.in
DirectoryIndex index.html
</VirtualHost>

<VirtualHost 192.168.1.1:80>
ServerAdmin root@server.rootuser.in
DocumentRoot /var/www/html/anup.com
ServerName www.anup.com
DirectoryIndex index.html
</VirtualHost>

<VirtualHost 192.168.1.1:80>
ServerAdmin root@server.rootuser.in
DocumentRoot /var/www/html/shubham.com
ServerName www.shubham.com
DirectoryIndex index.html
</VirtualHost>
:wq

10] Create web pages for website.
[root@server ~]# cd /var/www/html
[root@server html]# mkdir rootuser.in anup.com shubham.com
[root@server ~]# cd rootuser.in
[root@server rootuser.in]# cat > index.html
<b><font size=15 color=orange><center>This is Rootuser.in</center></font></b>
^+d

[root@server rootuser.in]# cd ..
[root@server html]# cd anup.com
[root@server anup.com]# cat > index.html
<b><font size=15 color=blue><center>This is Anup.com</center></font></b>
^+d

[root@server anup.com]# cd ..
[root@server html]# cd shubham.com
[root@server shubham.com]# cat > index.html
<b><font size=15 color=green><center>This is Shubham.com</center></font></b>
^+d
[root@server shubham.com]# cd

11] Start httpd service.
[root@server ~]# service httpd start
[root@server ~]# chkconfig httpd on

12] Point your Web Browser to following URL.
http://server.rootuser.in
http://www.anup.com
http://www.shubham.com

No comments: