Monday, April 23, 2018

VACUMM postgress from pgadmin3

To Vacumm postgress follow mention methode.

First, start postgress service.

Connect the postgress of minder server from pgadminIII

Navigate to mention location
- servers
- Minder (IP address of the minder server)
- Databases
+ ipmreportdb

right click on ipmreportdb and select Maintanance
















Now select Vacuum



















It will take time and once it is comleted click on Done
Now ANALYZE the pgsql.






































Now Re-index the pgsql.






































Now Restart the postgress.

Configure SNMP in Windows Machine

Configure Windows Machine as SNMP device follow mentioned steps.

1. Enable SNMP service from “Turn Windows features on or off

























2. Select SNMP Service and Click on “Ok

3. Now it will request to restart the system, restart the system to apply changes.

4. Now open Services and navigate to SNMP Service Properties.

Verify details as mentioned below (Image is for reference only, you need to set your details)

























5. Now after setting above details restart SNMP service.

6. Now you can verify the connectivity between source machine from where you wants to get the data from SNMP, and windows machine from minder CLI by snmpwalk.


Extend Physical Volume Group

root@ubuntu:/motadata/motadata# fdisk -l
Disk /dev/sda: 322.1 GB , 322122547200 bytes
255 heads, 63 sectors/track, 39162 cylinders, total 629145600 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x000713d6

Device Boot Start End Blocks Id System
/dev/sda1 * 2048 782335 390144 83 Linux
/dev/sda2 782336 209713151 104465408 8e Linux LVM

Disk /dev/mapper/vg0-root: 10.2 GB, 10238296064 bytes
255 heads, 63 sectors/track, 1244 cylinders, total 19996672 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00000000

Disk /dev/mapper/vg0-root doesn't contain a valid partition table

Disk /dev/mapper/vg0-swap: 8191 MB, 8191475712 bytes
255 heads, 63 sectors/track, 995 cylinders, total 15998976 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00000000

Disk /dev/mapper/vg0-swap doesn't contain a valid partition table

Disk /dev/mapper/vg0-motadata: 88.5 GB, 88541757440 bytes
255 heads, 63 sectors/track, 10764 cylinders, total 172933120 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00000000

Disk /dev/mapper/vg0-motadata doesn't contain a valid partition table


root@ubuntu:/motadata/motadata# lvdisplay

--- Logical volume ---
LV Path /dev/vg0/root
LV Name root
VG Name vg0
LV UUID 8lPue7-0uYL-Pra7-FvoN-AVdd-1sxy-l7BFQY
LV Write Access read/write
LV Creation host, time ubuntu, 2017-05-22 12:46:16 +0530
LV Status available
# open 1
LV Size 9.54 GiB
Current LE 2441
Segments 1
Allocation inherit
Read ahead sectors auto
- currently set to 256
Block device 252:0

--- Logical volume ---
LV Path /dev/vg0/swap
LV Name swap
VG Name vg0
LV UUID tFWxPn-WPa5-J56B-8dN3-0fsr-to0K-RXMSWw
LV Write Access read/write
LV Creation host, time ubuntu, 2017-05-22 12:46:16 +0530
LV Status available
# open 2
LV Size 7.63 GiB
Current LE 1953
Segments 1
Allocation inherit
Read ahead sectors auto
- currently set to 256
Block device 252:1

--- Logical volume ---
LV Path /dev/vg0/motadata
LV Name motadata
VG Name vg0
LV UUID ri3bxW-tEPc-XiJB-eu0W-k2Zt-Ri0c-7nbkq7
LV Write Access read/write
LV Creation host, time ubuntu, 2017-05-22 12:46:16 +0530
LV Status available
# open 1
LV Size 82.46 GiB
Current LE 21110
Segments 1
Allocation inherit
Read ahead sectors auto
- currently set to 256
Block device 252:2


root@ubuntu:/motadata/motadata# pvs
PV VG Fmt Attr PSize PFree
/dev/sda2 vg0 lvm2 a-- 99.62g 0


root@ubuntu:/motadata/motadata# lvs
LV VG Attr LSize Pool Origin Data% Move Log Copy% Convert
motadata vg0 -wi-ao--- 82.46g
root vg0 -wi-ao--- 9.54g
swap vg0 -wi-ao--- 7.63g


root@ubuntu:/motadata/motadata# vgs
VG #PV #LV #SN Attr VSize VFree
vg0 1 3 0 wz--n- 99.62g 0


root@ubuntu:/motadata/motadata# lvextend /dev/vg0/motadata /dev/sda2
No free extents on physical volume "/dev/sda2"
No specified PVs have space available


root@ubuntu:/motadata/motadata# fdisk /dev/sda
Command (m for help): n
Partition type:
p primary (2 primary, 0 extended, 2 free)
e extended
Select (default p): p
Partition number (1-4, default 3):
Using default value 3
First sector (209713152-629145599, default 209713152):
Using default value 209713152
Last sector, +sectors or +size{K,M,G} (209713152-629145599, default 629145599):
Using default value 629145599

Command (m for help): t
Partition number (1-4): 3
Hex code (type L to list codes): 8e
Changed system type of partition 3 to 8e (Linux LVM)

Command (m for help): w
The partition table has been altered!

Calling ioctl() to re-read partition table.

WARNING: Re-reading the partition table failed with error 16: Device or resource busy.
The kernel still uses the old table. The new table will be used at
the next reboot or after you run partprobe(8) or kpartx(8)
Syncing disks.


root@ubuntu:/motadata/motadata# df -kh
Filesystem Size Used Avail Use% Mounted on
udev 12G 4.0K 12G 1% /dev
tmpfs 2.4G 704K 2.4G 1% /run
/dev/dm-0 9.3G 3.4G 5.5G 39% /
none 4.0K 0 4.0K 0% /sys/fs/cgroup
none 5.0M 0 5.0M 0% /run/lock
none 12G 0 12G 0% /run/shm
none 100M 0 100M 0% /run/user
/dev/mapper/vg0-motadata 82G 69G 9.4G 88% /motadata
/dev/sda1 361M 40M 299M 12% /boot


root@ubuntu:/motadata/motadata# fdisk -l
Disk /dev/sda: 322.1 GB, 322122547200 bytes
255 heads, 63 sectors/track, 39162 cylinders, total 629145600 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x000713d6

Device Boot Start End Blocks Id System
/dev/sda1 * 2048 782335 390144 83 Linux
/dev/sda2 782336 209713151 104465408 8e Linux LVM
/dev/sda3 209713152 629145599 209716224 8e Linux LVM

Disk /dev/mapper/vg0-root: 10.2 GB, 10238296064 bytes
255 heads, 63 sectors/track, 1244 cylinders, total 19996672 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00000000

Disk /dev/mapper/vg0-root doesn't contain a valid partition table

Disk /dev/mapper/vg0-swap: 8191 MB, 8191475712 bytes
255 heads, 63 sectors/track, 995 cylinders, total 15998976 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00000000

Disk /dev/mapper/vg0-swap doesn't contain a valid partition table

Disk /dev/mapper/vg0-motadata: 88.5 GB, 88541757440 bytes
255 heads, 63 sectors/track, 10764 cylinders, total 172933120 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00000000

Disk /dev/mapper/vg0-motadata doesn't contain a valid partition table


root@ubuntu:/motadata/motadata# partprobe


root@ubuntu:/motadata/motadata# pvcreate /dev/sda3


Physical volume "/dev/sda3" successfully created


root@ubuntu:/motadata/motadata# vgextend vg0 /dev/sda3
Volume group "vg0" successfully extended


root@ubuntu:/motadata/motadata# lvs
LV VG Attr LSize Pool Origin Data% Move Log Copy% Convert
motadata vg0 -wi-ao--- 82.46g
root vg0 -wi-ao--- 9.54g
swap vg0 -wi-ao--- 7.63g


root@ubuntu:/motadata/motadata# pvs
PV VG Fmt Attr PSize PFree
/dev/sda2 vg0 lvm2 a-- 99.62g 0
/dev/sda3 vg0 lvm2 a-- 200.00g 200.00g


root@ubuntu:/motadata/motadata# lvextend -L +180G /dev/vg0/motadata /dev/sda3
Extending logical volume motadata to 262.46 GiB
Logical volume motadata successfully resized


root@ubuntu:/motadata/motadata# resize2fs /dev/vg0/motadata
resize2fs 1.42.9 (4-Feb-2014)
Filesystem at /dev/vg0/motadata is mounted on /motadata; on-line resizing required
old_desc_blocks = 6, new_desc_blocks = 17
The filesystem on /dev/vg0/motadata is now 68802560 blocks long.


root@ubuntu:/motadata/motadata# df -kh
Filesystem Size Used Avail Use% Mounted on
udev 12G 4.0K 12G 1% /dev
tmpfs 2.4G 708K 2.4G 1% /run
/dev/dm-0 9.3G 3.4G 5.5G 39% /
none 4.0K 0 4.0K 0% /sys/fs/cgroup
none 5.0M 0 5.0M 0% /run/lock
none 12G 0 12G 0% /run/shm
none 100M 0 100M 0% /run/user
/dev/mapper/vg0-motadata 259G 69G 180G 28% /motadata
/dev/sda1 361M 40M 299M 12% /boot

Add NTP server entry in Windows machine from Command prompt

Open Command Prompt (Run As Administrator), and execute below mentioned command.

> net stop w32time
> w32tm /config /syncfromflags:manual /manualpeerlist:"0.in.pool.ntp.org, 1.asia.pool.ntp.org, 0.asia.pool.ntp.org"
> w32tm /config /reliable:yes
> net start w32time



Install phantomjs in ubuntu 14.04.5

Find below-mentioned steps to configure phantomjs in ubuntu Mahcine.

root@ubuntu:/motadata/motadata/phantomjs# cd /usr/local/share/

root@ubuntu:/usr/local/share# wget https://bitbucket.org/ariya/phantomjs/downloads/phantomjs-2.1.1-linux-x86_64.tar.bz2

linux-root@ubuntu:/usr/local/share# tar xjf phantomjs-2.1.1-linux-x86_64.tar.bz2

root@ubuntu:/usr/local/share# ln -s /usr/local/share/phantomjs-2.1.1-linux-x86_64/bin/phantomjs /usr/

root@ubuntu:/usr/local/share# ln -s /usr/local/share/phantomjs-2.1.1-linux-x86_64/bin/phantomjs /usr/

root@ubuntu:/usr/local/share# ln -s /usr/local/share/phantomjs-2.1.1-linux-x86_64/bin/phantomjs /usr/

root@ubuntu:/usr/local/share# cd

root@ubuntu:~# phantomjs -v
2.1.1

Assign Unused Space / Reduce space from the LVM Partition in Linux/Unix

Here, we are going to provide all remaining free space of hard disk to /motadata partition.

root@ubuntu:~# df -kh
Filesystem Size Used Avail Use% Mounted on
/dev/mapper/vg0-root 14G 1.9G 12G 14% /
none 4.0K 0 4.0K 0% /sys/fs/cgroup
udev 2.0G 4.0K 2.0G 1% /dev
tmpfs 395M 400K 395M 1% /run
none 5.0M 0 5.0M 0% /run/lock
none 2.0G 0 2.0G 0% /run/shm
none 100M 0 100M 0% /run/user
/dev/xvda1 361M 36M 303M 11% /boot
/dev/mapper/vg0-motadata 71G 52M 67G 1% /motadata
root@ubuntu:~# pvs
  PV         VG   Fmt  Attr PSize   PFree
  /dev/xvda2 vg0  lvm2 a--  129.62g 36.17g
root@ubuntu:~# lvextend /dev/mapper/vg0-motadata /dev/xvda2
Extending logical volume motadata to 107.69 GiB
Logical volume motadata successfully resized
root@ubuntu:~# resize2fs /dev/mapper/vg0-motadata
resize2fs 1.42.9 (4-Feb-2014)
Filesystem at /dev/mapper/vg0-motadata is mounted on /motadata; on-line resizing required
old_desc_blocks = 5, new_desc_blocks = 7
The filesystem on /dev/mapper/vg0-motadata is now 28230656 blocks long.
root@ubuntu:~# df -kh
Filesystem Size Used Avail Use% Mounted on
/dev/mapper/vg0-root 14G 1.9G 12G 14% /
none 4.0K 0 4.0K 0% /sys/fs/cgroup
udev 2.0G 4.0K 2.0G 1% /dev
tmpfs 395M 400K 395M 1% /run
none 5.0M 0 5.0M 0% /run/lock
none 2.0G 0 2.0G 0% /run/shm
none 100M 0 100M 0% /run/user
/dev/xvda1 361M 36M 303M 11% /boot
/dev/mapper/vg0-motadata 106G 60M 101G 1% /motadata

Reduce space from /motadata partition.

root@ubuntu:~# lvs
LV VG Attr LSize Pool Origin Data% Move Log Copy% Convert
motadata vg0 -wi-ao--- 107.69g
root vg0 -wi-ao--- 14.30g
swap vg0 -wi-ao--- 7.63g
root@ubuntu:~# df -kh
Filesystem                Size  Used Avail Use% Mounted on
/dev/mapper/vg0-root       14G  1.9G   12G  14% /
none                      4.0K     0  4.0K   0% /sys/fs/cgroup
udev                      2.0G  4.0K  2.0G   1% /dev
tmpfs                     395M  400K  395M   1% /run
none                      5.0M     0  5.0M   0% /run/lock
none                      2.0G     0  2.0G   0% /run/shm
none                      100M     0  100M   0% /run/user
/dev/xvda1                361M   36M  303M  11% /boot
/dev/mapper/vg0-motadata  106G   60M  101G   1% /motadata
root@ubuntu:~# umount -v /motadata
/dev/mapper/vg0-motadata has been unmounted
root@ubuntu:~# e2fsck -f /dev/mapper/vg0-motadata
e2fsck 1.42.9 (4-Feb-2014)
Pass 1: Checking inodes, blocks, and sizes
Pass 2: Checking directory structure
Pass 3: Checking directory connectivity
Pass 4: Checking reference counts
Pass 5: Checking group summary information
/dev/mapper/vg0-motadata: 27/7061504 files (0.0% non-contiguous), 491233/28230656 blocks
root@ubuntu:~# resize2fs /dev/mapper/vg0-motadata 36G
resize2fs 1.42.9 (4-Feb-2014)
Resizing the filesystem on /dev/mapper/vg0-motadata to 9437184 (4k) blocks.
The filesystem on /dev/mapper/vg0-motadata is now 9437184 blocks long.
root@ubuntu:~# lvreduce -L -36G /dev/mapper/vg0-motadata
  WARNING: Reducing active logical volume to 71.69 GiB
  THIS MAY DESTROY YOUR DATA (filesystem etc.)
Do you really want to reduce motadata? [y/n]: y
  Reducing logical volume motadata to 71.69 GiB
  Logical volume motadata successfully resized
root@ubuntu:~# resize2fs /dev/vg0/motadata
resize2fs 1.42.9 (4-Feb-2014)
Resizing the filesystem on /dev/vg0/motadata to 18793472 (4k) blocks.
The filesystem on /dev/vg0/motadata is now 18793472 blocks long.
root@ubuntu:~# mount /dev/vg0/motadata /motadata/
root@ubuntu:~# lvs
LV VG Attr LSize Pool Origin Data% Move Log Copy% Convert
motadata vg0 -wi-ao--- 71.69g
root vg0 -wi-ao--- 14.30g
swap vg0 -wi-ao--- 7.63g

Create a New partition using attached hard disk.

First Check current HDD.
root@Ubuntu:/# df -kh
Filesystem Size Used Avail Use% Mounted on
udev 3.9G 12K 3.9G 1% /dev
tmpfs 798M 416K 798M 1% /run
/dev/sda1 29G 866M 27G 4% /
none 4.0K 0 4.0K 0% /sys/fs/cgroup
none 5.0M 0 5.0M 0% /run/lock
none 3.9G 0 3.9G 0% /run/shm
none 100M 0 100M 0% /run/user
/dev/sdb1 40G 48M 38G 1% /mnt
root@Ubuntu:/# fdisk -l

Disk /dev/sda: 31.5 GB, 31457280000 bytes
4 heads, 32 sectors/track, 480000 cylinders, total 61440000 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x0004a8a3

   Device Boot      Start         End      Blocks   Id  System
/dev/sda1   *        2048    61439999    30718976   83  Linux

Disk /dev/sdb: 42.9 GB, 42949672960 bytes
255 heads, 63 sectors/track, 5221 cylinders, total 83886080 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes
Disk identifier: 0xb468d93a

   Device Boot      Start         End      Blocks   Id  System
/dev/sdb1            2048    83884031    41940992    7  HPFS/NTFS/exFAT

Disk /dev/sdc: 53.7 GB, 53687091200 bytes
255 heads, 63 sectors/track, 6527 cylinders, total 104857600 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x0cb3884b

   Device Boot      Start         End      Blocks   Id  System
root@Ubuntu:/# fdisk /dev/sdc
Command (m for help): n
Partition type:
p primary (0 primary, 0 extended, 4 free)
e extended
Select (default p): p
Partition number (1-4, default 1):
Using default value 1
First sector (2048-104857599, default 2048):
Using default value 2048
Last sector, +sectors or +size{K,M,G} (2048-104857599, default 104857599):
Using default value 104857599
Command (m for help): t
Selected partition 1
Hex code (type L to list codes): 8e
Changed system type of partition 1 to 8e (Linux LVM)
Command (m for help): w
The partition table has been altered!
Calling ioctl() to re-read partition table.
Syncing disks.
root@Ubuntu:/# mkfs -t ext4 /dev/sdc1
mke2fs 1.42.9 (4-Feb-2014)
Discarding device blocks: done
Filesystem label=
OS type: Linux
Block size=4096 (log=2)
Fragment size=4096 (log=2)
Stride=0 blocks, Stripe width=0 blocks
3276800 inodes, 13106944 blocks
655347 blocks (5.00%) reserved for the super user
First data block=0
Maximum filesystem blocks=4294967296
400 block groups
32768 blocks per group, 32768 fragments per group
8192 inodes per group
Superblock backups stored on blocks:
        32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632, 2654208,
        4096000, 7962624, 11239424

Allocating group tables: done
Writing inode tables: done
Creating journal (32768 blocks): done
Writing superblocks and filesystem accounting information: done
root@Ubuntu:/# tune2fs -m 1 /dev/sdc1
tune2fs 1.42.9 (4-Feb-2014)
Setting reserved blocks percentage to 1% (131069 blocks)
root@Ubuntu:/# mkdir /motadata/
root@Ubuntu:/# mount /dev/sdc1 /motadata/
root@Ubuntu:/# df -kh
Filesystem      Size  Used Avail Use% Mounted on
udev            3.9G   12K  3.9G   1% /dev
tmpfs           798M  416K  798M   1% /run
/dev/sda1        29G  866M   27G   4% /
none            4.0K     0  4.0K   0% /sys/fs/cgroup
none            5.0M     0  5.0M   0% /run/lock
none            3.9G     0  3.9G   0% /run/shm
none            100M     0  100M   0% /run/user
/dev/sdb1        40G   48M   38G   1% /mnt
/dev/sdc1        50G   52M   49G   1% /motadata
root@Ubuntu:/# blkid
/dev/sr0: LABEL="rd_rdfe_stable.161107-1031" TYPE="udf"
/dev/sda1: LABEL="cloudimg-rootfs" UUID="5651329a-c2a3-4ab1-9a39-09a559160b9a" TYPE="ext4"
/dev/sdb1: UUID="a1838da8-2818-4a42-8881-78fdbaee7f28" TYPE="ext4"
/dev/sdc1: UUID="b37b0bde-65c9-47a2-9e93-cad8fcf23364" TYPE="ext4"
root@Ubuntu:/# vim /etc/fstab
 # CLOUD_IMG: This file was created/modified by the Cloud Image build process
UUID=5651329a-c2a3-4ab1-9a39-09a559160b9a       /        ext4   defaults,discard        0 0
/dev/disk/cloud/azure_resource-part1    /mnt    auto    defaults,nobootwait,comment=cloudconfig 0       2
UUID=b37b0bde-65c9-47a2-9e93-cad8fcf23364       /motadata       ext4    defaults,discard  

Extend / Reduce SWAP Partitions in Linux

Extend Swap Partition.

1) Determine the name of the swap logical volume using the "lvs" command:

root@ubuntu:~# lvs
  LV       VG   Attr      LSize  Pool Origin Data%  Move Log Copy%  Convert
  motadata vg0  -wi-ao--- 71.52g
  root     vg0  -wi-ao--- 14.30g
  swap     vg0  -wi-ao---  7.63g
2) Turn off the swap partition:
root@ubuntu:~# swapoff /dev/mapper/vg0-swap
3) Resize the swap partition, adding 15GB more space to it:

root@ubuntu:~# lvresize -L +5G /dev/mapper/vg0-swap
  Extending logical volume swap to 12.63 GiB
  Logical volume swap successfully resized
4) Format the new swap space to make it usable:
root@ubuntu:~# mkswap /dev/mapper/vg0-swap
mkswap: /dev/mapper/vg0-swap: warning: don't erase bootbits sectors
on whole disk. Use -f to force.
Setting up swapspace version 1, size = 13242364 KiB
no label, UUID=a1ea414e-f650-4d11-8525-43ff01ed48d8
5) Turn the swap volume back on:

root@ubuntu:~# swapon /dev/mapper/vg0-swap

6) Use the free command to show your new swap space:
root@ubuntu:~# free -mh | grep -i swap
Swap: 12G 0B 12G

Saturday, April 21, 2018

Configure DNS in Linux

DNS = Domain Naming Service (or) Domain Name System DNS will resolve the host name for the particular IP address.
- WINS provides only netbios to IP but not from IP to netbios
- DNS & WINS reduces the broadcast
- Host file located in /etc/hosts

=> Zone
  - Storage database which contains all the records.
  1. Forward lookup Zone
      - Used for resolving hostnames to IP
      - Maintains host to IP mapping info
  2. Revers lookup Zone
      - Used to resolve IP to hostname
      - Maintains IP to host mapping info

=> Records
  1. PTR Record                                             /Reverse lookup Zone
      - Maps IP to Hostname
  2. SOA Record                                             /Forward lookup Zone
      - First Record in any zone file
      - Primary and Start Of Authority
  3. NS Record                                               /Forward lookup Zone
      - Name server
      - Identifies the DNS servers for each zone
  4. MX Record                                              /Forward lookup Zone
      - Maps domain name to a mail server
      - Mail Exchange
  5. A Record (Address Record)                      /Forward lookup Zone   
      - Maps hostname to an IP address
      - Client Side
  6. SRV Record                                             /Forward lookup Zone
      - Service Record
  7. CNAME Record (Canonical Name)
      - Maps an alias name to a hostname

=> Packages
   - bind*
   - caching-nameserver-*.rpm

=> Port number
   - 53

=> Configuration file
   - /etc/named.caching-nameserve.conf
   - /etc/named.rtc1912.zones

=> Daemon/Service
   - named

Primary(Master) DNS Server Details:
Operating System     : CentOS 6.5 server
Hostname             : masterdns.rhce.local 
IP Address       : 192.168.1.100/24[Installation on Server Side]

Secondary(Slave) DNS Server Details:

Operating System     : CentOS 6.5 server
Hostname             : secondarydns.rhce.local
IP Address           : 192.168.1.101/24

Client Details:
Operating System     : CentOS 6.5 Desktop  
Hostname             : Client.rhce.local
IP Address           : 192.168.1.102/24

Setup Primary(Master) DNS Server
[root@masterdns ~]# yum install bind* -y

1. Configure DNS Server

Add the lines as shown below in ‘/etc/named.conf’ file
[root@master ~]# vi /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.1.100; }; ### Master DNS IP ###
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.1.0/24; }; ### IP Range ### 
allow-transfer{ localhost; 192.168.1.101; };   ### Slave DNS IP ###
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"rhce.local" IN {
type master;
file "forward.rhce";
allow-update { none; };
};
zone"1.168.192.in-addr.arpa" IN {
type master;
file "reverse.rhce";
allow-update { none; };
};
include "/etc/named.rfc1912.zones";
include "/etc/named.root.key";

2. Create Zone files

Create forward and reverse zone files which we mentioned in the ‘/etc/named.conf’ file.

2.1 Create Forward Zone

Create forward.rhce file in the ‘/var/named’ directory.
[root@master ~]# vi /var/named/forward.rhce
$TTL 86400
@   IN  SOA     master.rhce.local. root.rhce.local. (
        2011071001  ;Serial
        3600        ;Refresh
        1800        ;Retry
        604800      ;Expire
        86400       ;Minimum TTL
)
@       IN  NS          master.rhce.local.
@       IN  NS          secondary.rhce.local.
@       IN  A           192.168.1.100
@       IN  A           192.168.1.101
@       IN  A           192.168.1.102
master       IN  A   192.168.1.100
secondary    IN  A   192.168.1.101
client          IN  A   192.168.1.102

2.2 Create Reverse Zone

Create reverse.rhce file in the ‘/var/named’ directory.
[root@master ~]# vi /var/named/reverse.rhce

$TTL 86400
@   IN  SOA     master.rhce.local. root.rhce.local. (
        2011071001  ;Serial
        3600        ;Refresh
        1800        ;Retry
        604800      ;Expire
        86400       ;Minimum TTL
)
@       IN  NS          master.rhce.local.
@       IN  NS          secondary.rhce.local.
@       IN  PTR         rhce.local.
master       IN  A   192.168.1.100
secondary    IN  A   192.168.1.101
client          IN  A   192.168.1.102
100     IN  PTR         master.rhce.local.
101     IN  PTR         secondary.rhce.local.
102     IN  PTR         client.rhce.local.

3. Start the DNS service

[root@master ~]# service named start
Starting named:                                            [  OK  ]
[root@master ~]# chkconfig named on

4. Adjust iptables to allow DNS server from outside of the network

Add the lines as shown below in ‘/etc/sysconfig/iptables’ file.
[root@master ~]# vi /etc/sysconfig/iptables
# Firewall configuration written by system-config-firewall
# Manual customization of this file is not recommended.
*filter
:INPUT ACCEPT [0:0]
:FORWARD ACCEPT [0:0]
:OUTPUT ACCEPT [0:0]
-A INPUT -p udp -m state --state NEW --dport 53 -j ACCEPT
-A INPUT -p tcp -m state --state NEW --dport 53 -j ACCEPT
-A INPUT -m state --state ESTABLISHED,RELATED -j ACCEPT
-A INPUT -p icmp -j ACCEPT
-A INPUT -i lo -j ACCEPT
-A INPUT -m state --state NEW -m tcp -p tcp --dport 22 -j ACCEPT
-A INPUT -j REJECT --reject-with icmp-host-prohibited
-A FORWARD -j REJECT --reject-with icmp-host-prohibited
COMMIT

5. Restart iptables

[root@master ~]# service iptables restart
iptables: Flushing firewall rules:                         [  OK  ]
iptables: Setting chains to policy ACCEPT: filter          [  OK  ]
iptables: Unloading modules:                               [  OK  ]
iptables: Applying firewall rules:                         [  OK  ]

6. Test DNS configuration and zone files for any syntax errors

[root@master ~]# named-checkconf /etc/named.conf 
[root@master ~]# named-checkzone rhce.local /var/named/forward.rhce 
zone rhce.local/IN: loaded serial 2011071001
OK
[root@master ~]# named-checkzone rhce.local /var/named/reverse.rhce
zone rhce.local/IN: loaded serial 2011071001
OK

7. Test DNS Server

[root@master ~]# dig master.rhce.local
; <<>> DiG 9.8.2rc1-RedHat-9.8.2-0.10.rc1.el6_3.6 <<>> master.rhce.local
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 49834
;; flags: qr aa rd ra; QUERY: 1, ANSWER: 1, AUTHORITY: 2, ADDITIONAL: 1
;; QUESTION SECTION:
;master.rhce.local.INA
;; ANSWER SECTION:
master.rhce.local. 86400INA192.168.1.100
;; AUTHORITY SECTION:
rhce.local.86400INNSsecondary.rhce.local.
rhce.local.86400INNSmaster.rhce.local.
;; ADDITIONAL SECTION:
secondary.rhce.local. 86400 INA192.168.1.101
;; Query time: 6 msec
;; SERVER: 192.168.1.100#53(192.168.1.100)
;; WHEN: Thu Mar  7 13:07:56 2013
;; MSG SIZE  rcvd: 114
[root@master ~]# nslookup rhce.local
Server:192.168.1.100
Address:192.168.1.100#53
Name:rhce.local
Address: 192.168.1.102
Name:rhce.local
Address: 192.168.1.100
Name:rhce.local
Address: 192.168.1.101

Now the Primary DNS server is ready to use.

Setup Secondary(Slave) DNS Server

[root@secondary ~]# yum install bind* -y

1. Configure Slave DNS Server

Open the main configuration file ‘/etc/named.conf’ and add the lines as shown below.
[root@secondary ~]# vi /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.1.101; };
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.1.0/24; };
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"rhce.local" IN {
type slave;
file "slaves/rhce.fwd";
masters { 192.168.1.100; };
};
zone"1.168.192.in-addr.arpa" IN {
type slave;
file "slaves/rhce.rev";
masters { 192.168.1.100; };
};
include "/etc/named.rfc1912.zones";
include "/etc/named.root.key";

2. Start the DNS Service

[root@secondary ~]# service named start
Generating /etc/rndc.key:                                  [  OK  ]
Starting named:                                            [  OK  ]
[root@secondary ~]# chkconfig named on

Now the forward and reverse zones are automatically replicated from Master DNS server to ‘/var/named/slaves/’ in Secondary DNS server.
[root@secondary ~]# ls /var/named/slaves/
rhce.fwd  rhce.rev
[root@secondary ~]# cat /var/named/slaves/rhce.fwd 
$ORIGIN .
$TTL 86400; 1 day
rhce.localIN SOAmasterdns.rhce.local. root.rhce.local. (
2011071001 ; serial
3600       ; refresh (1 hour)
1800       ; retry (30 minutes)
604800     ; expire (1 week)
86400      ; minimum (1 day)
)
NS master.rhce.local.
NS secondary.rhce.local.
A192.168.1.100
A192.168.1.101
A192.168.1.102
$ORIGIN rhce.local.
clientA192.168.1.102
masterA192.168.1.100
secondaryA192.168.1.101
[root@secondary ~]# cat /var/named/slaves/rhce.rev 
$ORIGIN .
$TTL 86400; 1 day
1.168.192.in-addr.arpaIN SOAmaster.rhce.local. root.rhce.local. (
2011071001 ; serial
3600       ; refresh (1 hour)
1800       ; retry (30 minutes)
604800     ; expire (1 week)
86400      ; minimum (1 day)
)
NS master.rhce.local.
NS secondary.rhce.local.
PTRrhce.local.
$ORIGIN 1.168.192.in-addr.arpa.
100PTRmaster.rhce.local.
101PTRsecondary.rhce.local.
102PTRclient.rhce.local.
clientA192.168.1.102
masterA192.168.1.100
secondaryA192.168.1.101

3. Add the DNS Server details to all systems

[root@secondary ~]# vi /etc/resolv.conf
# Generated by NetworkManager
search rhce.com
nameserver 192.168.1.100
nameserver 192.168.1.101
nameserver 8.8.8.8

4. Test DNS Server

[root@secondary ~]# dig masterdns.rhce.local
; <<>> DiG 9.8.2rc1-RedHat-9.8.2-0.10.rc1.el6_3.6 <<>> master.rhce.local
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 21487
;; flags: qr aa rd ra; QUERY: 1, ANSWER: 1, AUTHORITY: 2, ADDITIONAL: 1
;; QUESTION SECTION:
;master.rhce.local.INA
;; ANSWER SECTION:
master.rhce.local. 86400INA192.168.1.100
;; AUTHORITY SECTION:
rhce.local.86400INNSmaster.rhce.local.
rhce.local.86400INNSsecondary.rhce.local.
;; ADDITIONAL SECTION:
secondary.rhce.local. 86400 INA192.168.1.101
;; Query time: 15 msec
;; SERVER: 192.168.1.100#53(192.168.1.100)
;; WHEN: Thu Mar  7 13:27:57 2013
;; MSG SIZE  rcvd: 114
[root@secondary ~]# dig secondary.rhce.local
; <<>> DiG 9.8.2rc1-RedHat-9.8.2-0.10.rc1.el6_3.6 <<>> secondary.rhce.local
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 20958
;; flags: qr aa rd ra; QUERY: 1, ANSWER: 1, AUTHORITY: 2, ADDITIONAL: 1
;; QUESTION SECTION:
;secondary.rhce.local.INA
;; ANSWER SECTION:
secondary.rhce.local. 86400 INA192.168.1.101
;; AUTHORITY SECTION:
rhce.local.86400INNSmaster.rhce.local.
rhce.local.86400INNSsecondary.rhce.local.
;; ADDITIONAL SECTION:
master.rhce.local. 86400INA192.168.1.100
;; Query time: 4 msec
;; SERVER: 192.168.1.100#53(192.168.1.100)
;; WHEN: Thu Mar  7 13:31:53 2013
;; MSG SIZE  rcvd: 114
[root@secondary ~]# nslookup rhce.local
Server:192.168.1.100
Address:192.168.1.100#53
Name:rhce.local
Address: 192.168.1.101
Name:rhce.local
Address: 192.168.1.102
Name:rhce.local
Address: 192.168.1.100

Client Side Configuration
Add the DNS server details in ‘/etc/resolv.conf’ file in all client systems
[root@client rhce]# vi /etc/resolv.conf
# Generated by NetworkManager
search rhce.local
nameserver 192.168.1.100
nameserver 192.168.1.101
nameserver 8.8.8.8

Test DNS Server

[root@client rhce]# dig master.rhce.local
; <<>> DiG 9.8.2rc1-RedHat-9.8.2-0.10.rc1.el6 <<>> master.rhce.local
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 19496
;; flags: qr aa rd ra; QUERY: 1, ANSWER: 1, AUTHORITY: 2, ADDITIONAL: 1
;; QUESTION SECTION:
;master.rhce.local.INA
;; ANSWER SECTION:
master.rhce.local. 86400INA192.168.1.100
;; AUTHORITY SECTION:
rhce.local.86400INNSmaster.rhce.local.
rhce.local.86400INNSsecondary.rhce.local.
;; ADDITIONAL SECTION:
secondary.rhce.local. 86400 INA192.168.1.101
;; Query time: 30 msec
;; SERVER: 192.168.1.100#53(192.168.1.100)
;; WHEN: Thu Mar  7 13:47:55 2013
;; MSG SIZE  rcvd: 114
[root@client rhce]# dig secondary.rhce.local
; <<>> DiG 9.8.2rc1-RedHat-9.8.2-0.10.rc1.el6 <<>> secondary.rhce.local
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 14852
;; flags: qr aa rd ra; QUERY: 1, ANSWER: 1, AUTHORITY: 2, ADDITIONAL: 1
;; QUESTION SECTION:
;secondary.rhce.local.INA
;; ANSWER SECTION:
secondary.rhce.local. 86400 INA192.168.1.101
;; AUTHORITY SECTION:
rhce.local.86400INNSsecondary.rhce.local.
rhce.local.86400INNSmaster.rhce.local.
;; ADDITIONAL SECTION:
master.rhce.local. 86400INA192.168.1.100
;; Query time: 8 msec
;; SERVER: 192.168.1.100#53(192.168.1.100)
;; WHEN: Thu Mar  7 13:48:38 2013
;; MSG SIZE  rcvd: 114
[root@client rhce]# dig client.rhce.local
; <<>> DiG 9.8.2rc1-RedHat-9.8.2-0.10.rc1.el6 <<>> client.rhce.local
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 14604
;; flags: qr aa rd ra; QUERY: 1, ANSWER: 1, AUTHORITY: 2, ADDITIONAL: 2
;; QUESTION SECTION:
;client.rhce.local.INA
;; ANSWER SECTION:
client.rhce.local.86400INA192.168.1.102
;; AUTHORITY SECTION:
rhce.local.86400INNSmaster.rhce.local.
rhce.local.86400INNSsecondary.rhce.local.
;; ADDITIONAL SECTION:
master.rhce.local. 86400INA192.168.1.100
secondary.rhce.local. 86400 INA192.168.1.101
;; Query time: 5 msec
;; SERVER: 192.168.1.100#53(192.168.1.100)
;; WHEN: Thu Mar  7 13:49:11 2013
;; MSG SIZE  rcvd: 137
[root@client rhce]# nslookup rhce.local
Server:192.168.1.100
Address:192.168.1.100#53
Name:rhce.local
Address: 192.168.1.102
Name:rhce.local
Address: 192.168.1.100
Name:rhce.local
Address: 192.168.1.101

Now the primary and secondary DNS servers are ready to use.