Wednesday, 23 January 2013

DHCP configuration



DHCP Configuration in Redhat /Cent OS

One of the basics elements found on all networks is a Dynamic Host Configuration Protocol (DHCP) server, making it an important part of any network. DHCP makes network administration easy because you can make changes to a single point (the DHCP server) on your network and let those changes filter down to the rest of the network. 

Before you can begin the installation or setup of a DHCP server, you need to verify that the server is configured with a static IP address. To verify this, you can look at the interface config file:

# cat /etc/sysconfig/network-scripts/ifcfg-eth0

DEVICE=”eth0”
NM_CONTROLLED=”yes”
ONBOOT=yes
HWADDR=00:0C:29:80:F1:FD
TYPE=Ethernet
BOOTPROTO=static
DEFROUTE=yes
PEERDNS=yes
PEERROUTES=yes
IPADDR=192.168.1.253
NETMASK=255.255.255.0
IPV4_FAILURE_FATAL=yes
IPV6INIT=no

Installing a DHCP Server

Strangely, the DHCP server package is called dhcp, while the service is called dhcpd.

Step 1.         Start by installing the dhcp package:
                   # yum install -y dhcp

Step 2.         With the package installed, make sure that the dhcpd service starts when the system boots as well:
                  # chkconfig dhcpd on

Step 3.          Verify that the DHCP service starts on boot:
                  # chkconfig dhcpd --list
                  dhcpd      0:off     1:off    2:on   3:on   4:on   5:on   6:off

Configuring the DHCP Server

To start the configuration, let’s look at the important files that handle the options
for the DHCP service:

/etc/dhcp/dhcpd.conf               Main config file for the DHCP service using IPv4 addresses
/etc/dhcp/dhcpd6.conf             Main config file for the DHCP service using IPv6 addresses
/var/lib/dhcpd/dhcpd.leases       IPv4 client lease file
/var/lib/dhcpd/dhcpd6.leases     IPv6 client lease file

The main config file is usually empty aside from a comment or two. The good news is that the package does provide a sample config file for you to use. This sample file provides examples and comments on how you can configure options for your DHCP server.

To copy the sample file, use the following command:
# cp /usr/share/doc/dhcp-4.1.1/dhcpd.conf.sample /etc/dhcp/dhcpd.conf

Or else u can edit the same configuration file.

Here is the sample DHCP server config file:

# Global Options

     ddns-update-style none;

# Subnet definition

               subnet 192.168.1.0 netmask 255.255.255.0 {
                             # Parameters for the local subnet
                             option routers                               192.168.1.1;
                             option subnet-mask                       255.255.255.0;
                             option domain-name                      “example.com”;
                             option domain-name-servers          192.168.1.1;
                             default-lease-time                          21600;
                             max-lease-time                             43200;

# Client IP range
                            range  192.168.1.100 192.168.1.200;
}

Let’s break down this file into sections. The first section contains two options for the DHCP server itself, also called global options:

ddns-update-style: none     This means that the DHCP server won’t update client DNS records.
authoritative                     This informs the client that the DHCP server contains legitimate information.


The next section defines a subnet. Any options that you list in a subnet section are
specific to the subnet for which you define them.

We also need to adjust the /etc/sysconfig/dhcpd file. In this case, you need to edit the following daemon option:

DHCPDARGS=”eth0”


After that we want to test the configuration file is correct or not.

Check the config file for any errors:

# service dhcpd configtest
Syntax: OK


Now restart the DHCP service:

# service dhcpd start
Starting dhcpd: [ OK ]

Verify that the service is running:

# service dhcpd status
dhcpd (pid 3366) is running...

Client Configuration

Go to the configuration of networking 

#system-config-network


Select the device


Now u can select the dhcp that will resolve ip address from the server




The ipaddress will be in the range of 100 to 200..


As a final tip, make sure you use the configtest option to test the syntax of your config files before starting or restarting the service.This prevents any errors from occurring when you try to start the service.Thank you....



Sunday, 6 January 2013

Linux DNS server Configuration

DNS Server Configuration in RHEL 6.0


DNS stands for Domain Name Server. DNS allows systems to look up host names, both within the private network and across the Internet. There are other ways of doing this, for example you could just run identical hosts files on all your machines. 

You can set up the DNS server on any Unix system. I am going to configure in Redhat 6.0. As a result, I'm going to talk about BIND.

To configure the DNS server, you need to set up a number of (text) database files. The DNS server daemon (called named) first consults a boot file. This boot file tells the daemon to consult a series of further database files which gives it enough information to start serving names.

The port number for named server is 53 and bind is the utility used for DNS.

There are different way you can classify the name servers:
1. Master.
2. Slave.
3. Caching only.
4. Forwarding.

I am going to create Caching only named server.

1. Setting up BIND

Step 1: Install the required packages : 
           #  yum install -y bind bind-utils bind-libs

Step 2: Verify that the packages have been installed:
           # rpm -qa | grep ^bind

Step 3: Ensure the services is set to start on boot:
           # chkconfig named on

Step 4: Verify that the service is set to start on boot:
          #  chkconfig --list named 
          named            0:off   1: off    2:on      3:on     4:on     5:on   6:off


2. Configure a DNS server


To begin configuration the DNS server, check out these key config files for a BIND server.

/etc/named.conf                                     Main config file
/etc/named.rfc1912.zone                       Main zone file



Before you do anything, you should make a backup of the /etc/named.conf file:

# cp /etc/named.conf /etc/named.conf.orig
# vi /etc/named.conf


  Line no 11      listen-on port 53 { 192.168.1.25; }; //change the ipaddress of your server.
  Line no 12      #       listen-on-v6 port 53 { ::1; }; //if u want to disable ipv6 then commend this   line.
  //Last line
        include "/etc/named.rfc1912.zones";
   :wq



Step5:     Edit the "/etc/named.rfc1912.zones" file.
              # vi /etc/named.rfc1912.zones 

              ; Append this lines to the configuration file to mention forward and reverse file locations.

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


              zone "1.168.192.in-addr.arpa" IN {
                type master;
                file "reverse.zone";
                allow-update { none; };
               };

After that we want to create the forward and reverse file

No need to create the forward and reverse files . The same file for loopback will be edited.
Firstly copy the two files and change the name..

#cp -a /var/named/named.localhost /var/named/forward.zone
#cp -a /var/named/named.loopback /var/named/reverse.zone

Next we want to edit the forward zone file as shown below

# vi forward.zone
$TTL 1D
@       IN SOA  sarin.example.com. root.example.com. (
                                        12122012        ; serial
                                        1D      ; refresh
                                        1H      ; retry
                                        1W      ; expire
                                        3H )    ; minimum
        IN      NS      sarin.example.com.
        IN      A       192.168.1.253
sarin              IN      A       192.168.1.25
desktop3        IN      A       192.168.1.26
sarinnath       IN      A       192.168.1.30

Reverse as shown below



# vi reverse.zone 

$TTL 1D
@       IN SOA  sarin.example.com. root.example.com. (
                                        12122012        ; serial
                                        1D      ; refresh
                                        1H      ; retry
                                        1W      ; expire
                                        3H )    ; minimum
           IN      NS      sarin.example.com.
@       IN      A       192.168.1.25
25      IN      PTR     sarin.example.com.
26      IN      PTR     desktop3.example.com.
30      IN      PTR     sarinnath.example.com.




Everything is now in place for you to begin using your DNS server. Before starting
the service, however, make sure that the config files don’t have any syntax errors.


Step 1:                  # named-checkconf /etc/named.conf 
                              If this doesn't leave error then your configuration is ok...


Step 2:                   Because no errors are displayed, you can start the service:
                              # service named start
                              Starting named: [ OK ]


DNS Utilities and Troubleshooting


For the server and client, there are a handful of utilities you can use to verify the
functionality of DNS. These utilities include

dig                    DNS lookup utility
host                  DNS lookup utility
ping                  Network or hostname verification utility
nslookup           Utility to lookup a hostname from an IP addresses
hostname          Utility to sets or show the system hostname (FQDN)



At this point, you should have a fully functional  DNS server. Although you
aren’t required to know how to set up a DNS server for the Red Hat exams,
this task is commonly performed in the real world. Thank you..Best of Luck.