This is default featured slide 1 title

Go to Blogger edit html and find these sentences.Now replace these sentences with your own descriptions.

This is default featured slide 2 title

Go to Blogger edit html and find these sentences.Now replace these sentences with your own descriptions.

This is default featured slide 3 title

Go to Blogger edit html and find these sentences.Now replace these sentences with your own descriptions.

This is default featured slide 4 title

Go to Blogger edit html and find these sentences.Now replace these sentences with your own descriptions.

This is default featured slide 5 title

Go to Blogger edit html and find these sentences.Now replace these sentences with your own descriptions.

Wednesday, December 28, 2011

Configure Web Server on Red Hat Enterprise Linux 5


Web Server Configuration on RHEL 5


Step-1:  To check web server  rpm package is installed or not by   following this command:

[root@web ~]#rpm -qa | grep –i httpd*  php*  mod_ssl* mysql* or
[root@web ~]# rpm –qa httpd*  php* mod_ssl* mysql*

            If not installed, then installed the packages using Yum command:

[root@web ~]# Yum Install httpd*  php* mod_ssl* mysql* -y

Step-2: Check and Configure the Network Card:

[root@web ~]# vi /etc/sysconfig/network-scripts/ifcfg-eth0

(Original File):

#Broadcom Corporation Net link BCM57875 Gigabyte Ethernet PCI Express
DEVICE=eth0
BOOTPROTO=dhcp
HWADDR=00:0C:29: EB: B2: CA
ONBOOT=yes

(Modified File):

#Broadcom Corporation Net link BCM57875 Gigabyte Ethernet PCI Express
DEVICE=eth0
BOOTPROTO=static
HWADDR=00:0C:29:EB:B2:CA
ONBOOT=yes
TYPE=Ethernet
PEERDNS=no
USERCTL=no
IPV6INIT=no
IPADDR=210.207.201.5
NETMASK=255.255.255.0
NETWORK=210.207.201.0
BROADCAST=210.207.255.255

Press Esc → Shift + : → x! → Enter (For Save and Exit the Vi Editor).

After changing you have to reload/restart the NIC(eth0) card by following command:

[root@web ~]# ifdown eth0
[root@web ~]# ifup eth0
[root@web ~]# service network restart

Step-3:  After complete the NIC configure you have to change the host name by following this                             command:

[root@web ~]# vi /etc/sysconfig/network

(Original File):

NETWORKING=yes
NETWORKING_IPV6=no
HOSTNAME=localhost.localdomain

(Modified File):

NETWORKING=yes
NETWORKING_IPV6=no
HOSTNAME=web.alphabd.net

Press Esc → Shift + : → x! → Enter

Step-4: Now Edit hosts file for host name resolution by following this command:

[root@web ~]# vi /etc/hosts

(Original File):

# Do not remove the following line, or various programs
# that require network functionality will fail.
127.0.0.1       localhost.localdomain localhost

(Modified File):

# that require network functionality will fail.
127.0.0.1       localhost.localdomain localhost
210.207.201.5   web.alphabd.net      web


Esc → Shift + : → x! → Enter

Step-5:  Edit the resolv.conf file by following this command

[root@web ~]# vi /etc/resolv.conf

search alphabd.net
nameserver 210.207.201.1
nameserver 210.207.201.2

Esc → Shift + : → x! → Enter

Change In Primary DNS Server:

Step-6:  Edit Forward Lookup zone file for WEB server record

[root@ns1 ~]# cd /var/named/chroot/var/named/
[root@ns1 named]# vi alphabd.fz

Original File:  alphabd.fz

$TTL 86400
@          IN SOA     ns1.alphabd.net.       root.alphabd.net. (
                           2011022500 ; serial (d. adams)
                           3H         ; refresh
                           15M        ; retry
                           1W         ; expiry
                           1D )       ; minimum

           IN NS     ns1.alphabd.net.
ns1      IN A       210.207.201.1

Modified File:  alphabd.fz

$TTL 86400
@          IN SOA     ns1.alphabd.net.       root.alphabd.net. (
                           2011022501 ; serial (d. adams)
                           3H         ; refresh
                           15M        ; retry
                           1W         ; expiry
                           1D )       ; minimum

           IN NS     ns1.alphabd.net.
           IN NS     ns2.alphabd.net.
mail.alphabd.net.          IN NS      ns3.mail.alphabd.net.
ns1        IN A      210.207.201.1
ns2        IN A      210.207.201.2
web        IN A      210.207.201.5
www        IN CNAME  web.alphabd.net.
ns3.mail.alphabd.net. IN A 210.207.201.3

Esc → Shift + : → x! → Enter

Note:  Change The Forward & Reverse Lookup Zone File Serial Number Last two Digit in Primary DNS Server if you change or enter a new record for host, otherwise Secondary DNS server will fail to reload the new record.

 Step-7:  Edit Reverse Lookup zone file for Web server record

[root@ns1 named]# vi alphabd.rz

Original File:  alphabd.rz

$TTL 86400
@          IN SOA     ns1.alphabd.net.       root.alphabd.net. (
                           2011022500 ; serial (d. adams)
                           3H         ; refresh
                           15M        ; retry
                           1W         ; expiry
                           1D )       ; minimum

             IN NS        ns1.alphabd.net.
             IN NS        ns2.alphabd.net.
1            IN PTR       ns1.alphabd.net.
2            IN PTR       ns2.alphabd.net.

Modified File:  alphabd.rz

$TTL 86400
@          IN SOA     ns1.alphabd.net.       root.alphabd.net. (
                           2011022501 ; serial (d. adams)
                           3H         ; refresh
                           15M        ; retry
                           1W         ; expiry
                           1D )       ; minimum

           IN NS      ns1.alphabd.net.
           IN NS      ns2.alphabd.net.
mail.alphabd.net.     IN NS ns3.mail.alphabd.net.
1          IN PTR     ns1.alphabd.net.
2          IN PTR     ns2.alphabd.net.
3          IN PTR     ns3.mail.alphabd.net.
5          IN PTR     web.alphabd.net.

Esc → Shift + : → x! → Enter

Step-8:    Check the named.conf & zone file by following this commands,

[root@ns1 ~]# named-checkzone  alphabd.net  /var/named/chroot/var/named/
alphabd.fz
[root@ns1 ~]# named-checkzone  alphabd.rz   /var/named/chroot/var/named/
alphabd.rz


Step-9:  Start & stop all the required services.

[root@ns1 ~]# service iptables stop
[root@ns1 ~]# service network restart
[root@ns1 ~]# chkconfig named on
[root@ns1 ~]# service named restart

Change in Web Server:

Step-10:  Now Edit the main web server configuration file for Configuring Web Server:

[root@web ~]# vi /etc/httpd/conf/httpd.conf


Directives
Description
Line Number
Original File Text
Modified File Text
Listen
Specify the Port Number where apache will listen on
134
80
210.207.201.5:80
ServerAdmin
e-mail address of the server administrator
251
root@localhost
root@alphabd.net
ServerName
Put the host name(FQDN)of web server
265
www.example.com:80
www.alphabd.net:80
DocumentRoot
Specify the html file location of the web server
281
“/var/www/html”
“/var/www/html”
DirectoryIndex
Set the type of index file type
391
Index.html index.html.var
Index.html index.php default.asp
NameVirtualHost
Set web Server IP which will contain the virtual host
972
*:80
210.207.201.5:80

Tips: To edit httpd.conf file set Line number & enter Follow the method.

Esc→set number→Enter→Esc→Shift+ :→type line number which you want to edit → Enter→go to insert mode → then edit→Save & Exit.

Step-11:  If DNS is not use for virtual hosting in web server then put the web site name and IP address in to the /etc/hosts file in web server machine. The Configuration file will look like this,

[root@web ~]# vi /etc/hosts

# Do not remove the following line, or various programs
# that require network functionality will fail.
127.0.0.1       localhost.localdomain           localhost
210.207.201.5   www.alphabd.net                 www
210.207.201.5   www.networkingsolution.com      www
210.207.201.5   www.linuxzone.com               www


Virtual Hosting:  Virtual hosting means, hosting many websites in a single server. There are two types of virtual hosting, “Name Based” and IP based virtual hosting. Name Based virtual hosting is popular hosting, because it reduce IP wastage. You can enable your web server to host more than one web site using a single IP address by using apache “NameNirtualHost” feature.

Name-base Virtual Hosting

In this tutorial we will create two virtual web site in a web server,One will be www.networkingsolution.com and another is www.linuxzone.com that can be access with any browser.

Change In Primary DNS Server:

Step-1:  Go to Primary DNS Server and create two zone file named networkingsolution.fz and alphabd.fz  in /etc/named .conf file and also create two zone file into /var/named/chroot/var/named/ directory.

[root@ns1 ~]# vi /etc/named.conf

Original File:

// named.rfc1912.zones:
//
// Provided by Red Hat caching-nameserver package
//
// ISC BIND named zone configuration for zones recommended by
// RFC 1912 section 4.1 : localhost TLDs and address zones
//
// See /usr/share/doc/bind*/sample/ for example named configuration files.
//
options {

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

zone "localdomain" IN {
     type master;
     file "localdomain.zone";
     allow-update { none; };
};

zone "localhost" IN {
     type master;
     file "localhost.zone";
     allow-update { none; };
};

zone "0.0.127.in-addr.arpa" IN {
     type master;
     file "named.local";
     allow-update { none; };
};

zone "0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.ip6.arpa" IN {
        type master;
     file "named.ip6.local";
     allow-update { none; };
};

zone "255.in-addr.arpa" IN {
     type master;
     file "named.broadcast";
     allow-update { none; };
};

zone "0.in-addr.arpa" IN {
     type master;
     file "named.zero";
     allow-update { none; };
};

zone "alphabd.net" IN {
     type master;
     file "alphabd.fz";
     allow-update { 210.207.201.2; }; 

};

zone "201.207.210.in-addr.arpa" IN {
     type master;
     file "alphabd.rz";
     allow-update { 210.207.201.2; };
};

Modified File:

// named.rfc1912.zones:
//
// Provided by Red Hat caching-nameserver package
//
// ISC BIND named zone configuration for zones recommended by
// RFC 1912 section 4.1 : localhost TLDs and address zones
//
// See /usr/share/doc/bind*/sample/ for example named configuration files.
//
options {

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

zone "localdomain" IN {
     type master;
     file "localdomain.zone";
     allow-update { none; };
};

zone "localhost" IN {
     type master;
     file "localhost.zone";
     allow-update { none; };
};

zone "0.0.127.in-addr.arpa" IN {
     type master;
     file "named.local";
     allow-update { none; };
};

zone "0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.ip6.arpa" IN {
        type master;
     file "named.ip6.local";
     allow-update { none; };
};

zone "255.in-addr.arpa" IN {
     type master;
     file "named.broadcast";
     allow-update { none; };
};

zone "0.in-addr.arpa" IN {
     type master;
     file "named.zero";
     allow-update { none; };
};

zone "alphabd.net" IN {
     type master;
     file "alphabd.fz";
     allow-update { 210.207.201.2; }; 

};

zone "201.207.210.in-addr.arpa" IN {
     type master;
     file "alphabd.rz";
     allow-update { 210.207.201.2; };
};

zone "networkingsolution.com" IN {
     type master;
     file "networkingsolution.fz";
    
};

zone "linuxzone.com" IN {
     type master;
     file "alphabd.fz";
    
};

Esc → Shift + : → x! → Enter

Step-2:  Now create two zone file named networkingsolution.fz and alphabd.fz

[root@ns1 ~]# cd /var/named/chroot/var/named/
[root@ns1 named]# cp localhost.zone  networkingsolution.fz
[root@ns1 named]# vi networkingsolution.fz

$TTL 86400
@          IN SOA     ns1.networkingsolution.com.       root.networkingsolution.com. (
                           2011022500 ; serial (d. adams)
                           3H         ; refresh
                           15M        ; retry
                           1W         ; expiry
                           1D )       ; minimum

           IN NS     ns1.networkingsolution.com.
ns1        IN A      210.207.201.1
web        IN A      210.207.201.5
www        IN CNAME  web.networkingsolution.com.

Step-3: Now Copy & rename the networkingsolution.fz file in to alphabd.fz then edit.

[root@ns1 named]# cp networkingsolution.fz  alphabd.fz

$TTL 86400
@          IN SOA     ns1.linuxzone.com.       root.linuxzone.com. (
                           2011022500 ; serial (d. adams)
                           3H         ; refresh
                           15M        ; retry
                           1W         ; expiry
                           1D )       ; minimum

           IN NS     ns1.linuxzone.com.
ns1        IN A      210.207.201.1
web        IN A      210.207.201.5
www        IN CNAME  web.linuxzone.com.

Change in Web Server Machine:   

As  the web site of alphabd.net DocumentRoot is /var/www/html/ , So we have to create two more directory into this directory for containing our two web site, So lets take look the steps,

Step-4:

[root@web ~]# mkdir /var/www/html/networkingsolution
[root@web ~]# mkdir /var/www/html/alphabd

Step-5:   Now Edit the main web server configuration file for Configuring Virtual host:

[root@web ~]# vi /etc/httpd/conf/httpd.conf

Go to the end of the Configuration file and put this configure,

<VirtualHost 210.207.201.5:80>
     ServerAdmin     root@alphabd.net
     DocumentRoot    /var/www/html
     ServerName      www.alphabd.net
     ErrorLog        logs/www.alphabd.net-error_log
     CustomLog       logs/www.alphabd.net-access_log common
</virtualHost>

<VirtualHost 210.207.201.5:80>
     ServerAdmin     root@networkingsolution.com
     DocumentRoot    /var/www/html/networkingsolution
     ServerName      www.networkingsolution.com  
     ErrorLog        logs/www.networkingsolution.com-error_log
     CustomLog       logs/www.networkingsolution.com-access_log common
</virtualHost>

<VirtualHost 210.207.201.5:80>
     ServerAdmin     root@linuxzone.com
     DocumentRoot    /var/www/html/alphabd
     ServerName      www.linuxzone.com  
     ErrorLog        logs/www.linuxzone.com-error_log
     CustomLog       logs/www.linuxzone.com-access_log common
</virtualHost>

Step-5:   Now create a sample index.html file into those directories and restart the http services.

Creating index.html file for alphabd.net

[root@web ~]# cd /var/www/html
[root@web ~]# vi index.html

<html>
<title>alphabd.net</title>
<body bgcolor=”skyblue”>
<center><h3>Web Administration</h3></center
<marquee> Wellcome to www.alphabd.net </marquee>
</body>
</html>
Creating index.html file for networkingsolution.com

[root@web ~]# cd /var/www/html/networkingsolution/
[root@web ~]# vi index.html

<html>
<title>networkingsolution.com</title>
<body bgcolor=”skyblue”>
<center><h3>Web Administration</h3></center
<marquee> Wellcome to www.networkingsolution.com </marquee>
</body>
</html>
Creating index.html file for networkingsolution.com

[root@web ~]# cd /var/www/html/alphabd/
[root@web ~]# vi index.html

Step-6:  Now restart the http services.

[root@web ~]# service iptables stop
[root@web ~]# service network restart
[root@web ~]# service httpd restart

Step-7:   Now Check the web Server form Linux or Windows

For Linux:

[root@client01 ~]# vi /etc/resolve.conf

search alphabd.net
nameserver 210.207.201.1
nameserver 210.207.201.2

Now Browse the wibe site using any Browser.

For Windows:

Set the DNS server IP address on your NIC properties then Browse the site with any Browser.

Tuesday, December 27, 2011

Configure DHCP Server on Red Hat Enterprise Linux 5


DHCP Server Configuration

Step-1:  To check dhcp  rpm package is installed or not by following this command:
                       
(if installed then it will show dhcp packages)

[root@dhcp ~]# rpm -qa | grep –i dhcp*    or
[root@dhcp ~]#  rpm –qa dhcp*

dhcp-3.0.5-21.el5
dhcp-devel-3.0.5-21.el5
libdhcp-devel-1.20-10.el5
dhcpv6-client-1.0.10-17.el5
libdhcp-1.20-10.el5
libdhcp4client-3.0.5-21.el5
libdhcp6client-devel-1.0.10-17.el5
libdhcp4client-devel-3.0.5-21.el5
dhclient-3.0.5-21.el5

           If not installed, then installed the packages using  Yum command:

[root@dhcp ~]# Yum Install dhcp* lib*

Step-2: Check and Configure the Network Card:

[root@dhcp ~]# vi /etc/sysconfig/network-scripts/ifcfg-eth0

(Original File):

#Broadcom Corporation Net link BCM57875 Gigabyte Ethernet PCI Express
DEVICE=eth0
BOOTPROTO=dhcp
HWADDR=00:0C:29: EB: B2: CA
ONBOOT=yes

(Modified File):

#Broadcom Corporation Net link BCM57875 Gigabyte Ethernet PCI Express
DEVICE=eth0
BOOTPROTO=static
HWADDR=00:0C:29: EB: B2: CA
ONBOOT=yes
TYPE=Ethernet
PEERDNS=no
USERCTL=no
IPV6INIT=no
IPADDR=210.207.201.4
NETMASK=255.255.255.0
NETWORK=210.207.201.0
BROADCAST=210.207.201.255

Press Esc → Shift + : → x! → Enter (For Save and Exit the Vi Editor).

After changing you have to reload/restart the NIC(eth0) card by following command:

[root@dhcp ~]# ifdown eth0
[root@dhcp ~]# ifup eth0
[root@dhcp ~]# service network restart

Step-3:  After complete the NIC configure you have to change the host name by following this                             command:

[root@dhcp ~]# vi /etc/sysconfig/network

(Original File):

NETWORKING=yes
NETWORKING_IPV6=no
HOSTNAME=localhost.localdomain

(Modified File):

NETWORKING=yes
NETWORKING_IPV6=no
HOSTNAME=dhcp
Press Esc → Shift + : → x! → Enter

Step-3:  Edit the resolv.conf file by following this command

[root@dhcp ~]# vi /etc/resolv.conf

search alphabd.net
nameserver 210.207.201.1
nameserver 210.207.201.2

Step-4:  Copy & Rename the DHCP configuration file & Change the permission by following this                                command:

[root@dhcp ~]# cd /usr/share/doc/dhcp-3.0.5/
[root@dhcp dhcp-3.0.5]# cp dhcpd.conf.sample  /etc/dhcpd.conf
[root@dhcp dhcp-3.0.5]# chmod 777 /etc/dhcpd.conf

Now Edit this file using vi editor & make some change in to this file.

[root@dhcp ~]# vi /etc/dhcpd.conf

(Original File):

ddns-update-style interim;
ignore client-updates;

subnet 192.168.0.0 netmask 255.255.255.0 {

# --- default gateway
      option routers                192.168.0.1;
      option subnet-mask            255.255.255.0;

      option nis-domain       "domain.org";
      option domain-name            "domain.org";
      option domain-name-servers    192.168.1.1;

      option time-offset            -18000;     # Eastern Standard Time
#     option ntp-servers            192.168.1.1;
#     option netbios-name-servers   192.168.1.1;
# --- Selects point-to-point node (default is hybrid). Don't change this unless
# -- you understand Netbios very well
#     option netbios-node-type 2;

      range dynamic-bootp 192.168.0.128 192.168.0.254;
      default-lease-time 21600;
      max-lease-time 43200;

      # we want the nameserver to appear at a fixed address
      host ns {
            next-server marvin.redhat.com;
            hardware ethernet 12:34:56:78:AB:CD;
            fixed-address 207.175.42.254;
      }
}
(Modified File):

ddns-update-style interim;
ignore client-updates;

subnet 210.207.201.0 netmask 255.255.255.0 {

# --- default gateway
      option routers                210.207.201.4;        
      option subnet-mask            255.255.255.0;

#     option nis-domain       "domain.org";
      option domain-name            "alphabd.net";        
      option domain-name-servers    210.207.201.1;

      option time-offset            -18000;     # Eastern Standard Time
#     option ntp-servers            192.168.1.1;
#     option netbios-name-servers   192.168.1.1;
# --- Selects point-to-point node (default is hybrid). Don't change this unless
# -- you understand Netbios very well
#     option netbios-node-type 2;

      range dynamic-bootp 210.207.201.50 210.207.201.254;
      default-lease-time 43200;
      max-lease-time 86400;

      # we want the nameserver to appear at a fixed address
      host ns {
            next-server marvin.redhat.com;
            hardware ethernet 12:34:56:78:AB:CD;
            fixed-address 207.175.42.254;
      }

      host pc01 {
            hardware ethernet 00:1E:68:91:BB:EC;
            fixed-address 210.207.201.100;
      }

      host client01 {
            hardware ethernet 00:0C:29:8C:95:01;
            fixed-address 210.207.201.150;
      }

}
Esc → Shift + : → x! → Enter

Step-5:  Create a dhcp.leases file that the DHCP server grants to the DHCP client to use a particular IP   address. If it does not exist dhcp server will fail to provide IP address for dhcp cient.

[root@dhcp ~]# touch /var/lib/dhcpd/dhcpd.leases
[root@dhcp ~]# service network restart
[root@dhcp ~]# service dhcpd restart

Step-6:   Client Configuration for using DHCP.

Linux Client

[root@dhcp ~]# vi /etc/sysconfig/network-scripts/ifcfg-eth0

#Broadcom Corporation Net link BCM57875 Gigabyte Ethernet PCI Express
DEVICE=eth0
BOOTPROTO=dhcp
HWADDR=00:0C:29: EB: B2: CA
ONBOOT=yes
TYPE=Ethernet

Windows Client

From NIC Properties =>> set Obtain an IP Address Automatically

Step-7:   Renewing IP Address

Renew an IP Address in Linux

The -r flag explicitly releases the current lease, and once the lease has been released, the client exits. For example, open terminal and type the command:

[root@dhcp ~]# dhclient –r

Now obtain fresh IP:

[root@client1 ~]# dhclient

Or you can put the two commands on a single line:

[rnbsp; oot@client1 ~]# dhclient -r; dhclient

There is no need to restart network service. Above command should work with any Linux distro such as RHEL, Fedora, and others. On a related note you can also try out the following commands:

[root@client1 ~]# ifdown eth0
[root@client1 ~]# ifup eth0
[root@client1 ~]# /etc/init.d/network restart

Renew an IP Address in Windows

Open Command Prompt → Then Type The following command

C:\Documents and Settings\Administrator> Ipconfig  /release
C:\Documents and Settings\Administrator> Ipconfig  /renew
C:\Documents and Settings\Administrator> Ipconfig  /all