How To Log DNS Server Activity?

0 comments

How to log DNS server activity?
Ans : Sometimes you require DNS server activity to be logged to a file for future reference to analyze the activity on DNS server and whether DNS server is properly resolving accurately or not. rndc is the command to use for DNS server activity logging. Let’s have a look how to log DNS server activity. In order to log DNS server entries just execute below command (you have to do this one as root user)
#rndc querylog
Note : When you execute the above command DNS server activity is logged on to server /var/log/messages file.

Example output of the clipped log file
bash-2.05b# /usr/sbin/rndc querylog
bash-2.05b# tail -f /var/log/messages
Nov 18 18:00:16 ns1.abc.in named[29413]: query logging is now on
Nov 18 18:00:18 ns1.abc.in named[29413]: client 194.158.122.34#43071: query: abc.co.in IN MX
Nov 18 18:00:18 ns1.abc.in named[29413]: client 194.158.122.6#43587: query: smtp.abc.co.in IN A
Nov 18 18:00:19 ns1.abc.in named[29413]: client 82.8.211.193#19305: query: MX2.abc.co.in IN A
Nov 18 18:00:20 ns1.abc.in named[29413]: client 200.49.130.26#4111: query: abc.co.in IN MX
Nov 18 18:00:21 ns1.abc.in named[29413]: client 212.24.128.8#46547: query: abc.co.in IN MX
Nov 18 18:00:22 ns1.abc.in named[29413]: client 200.75.51.132#26540: query: MX2.abc.co.in IN A
In order to stop DNS logging activity please execute below command
#rndc querylog
Note : If you observe this command it is same as for starting the log activity, it is similar way how walky-talky works.. You have to press same button for both on/off operations.
Example output of how it is stopped
bash-2.05b# /usr/sbin/rndc querylog
bash-2.05b# tail -f messages
Nov 18 18:08:53 ns1.abc.com named[29413]: client 200.12.232.4#60450: query: abc.co.in IN MX
Nov 18 18:08:59 ns1.abc.com named[29413]: client 212.54.35.233#39027: query: ns1.abc.co.in IN A
Nov 18 18:08:59 ns1.abc.com named[29413]: client 212.54.35.233#10163: query: ns1.abc.co.in IN A
Nov 18 18:09:00 ns1.abc.com named[29413]: client 88.156.63.9#3661: query: abc.co.in IN MX
Nov 18 18:09:00 ns1.abc.com named[29413]: client 89.2.2.146#44622: query: abc.co.in IN MX
Nov 18 18:09:05 ns1.abc.com named[29413]: client 203.199.147.5#14678: query: cmex01.clairmail.local.intranet.abc.co.in IN A
Nov 18 18:09:06 ns1.abc.com named[29413]: client 117.98.17.34#1766: query: abc.co.in IN MX
Nov 18 18:09:06 ns1.abc.com named[29413]: client 203.119.8.106#28142: query: abc.co.in IN MX
Nov 18 18:09:11 ns1.abc.com named[29413]: client 217.171.113.9#4861: query: MX2.abc.co.in IN A
Nov 18 18:09:11 ns1.abc.com named[29413]: query logging is now off
Some FAQ’s:
1.Is it advaisable to restart a production DNS server?
Ans : No, Never try to restart a production DNS server with out prior notice from your higher officials.
2.Then how can I update any changes I made to DNS server?
Ans :
You can use rndc command to update the changes to dns server.
3.I want to update DNS server zone file entries to DNS server without restarting the named/bind server?
Ans :
We can do it by using rndc command
#rndc reload
4.I want to reload named.conf file with out restarting DNS server?
#rndc refresh.
Please Comment your thoughts regarding this post:-)

  • Like the post? Please Subscribe to free RSS feed to get updates
  • How To Take The Backup Of MBR(Master Boot Recorder)

    2 comments

    1.How to take the backup and restore MBR? Why do you require to take the backup of your MBR?
    Ans :
    MBR (Master Boot Recorder) is a vital part of your hard disk which contains booting information, without it its difficult to boot the system. Suppose you have windows and Linux duel boot on your machine and as you know windows is more prone to virus attacks. So it’s always better to backup your MBR to be in safe place.


    2. How to take backup of your MBR?
    Ans :
    Using dd command (dataset definition). Here are the steps to take backup of you MBR and keep it in safe place to restore your system if it get corrupted.
    #dd if=/dev/hdx of=/safe/location bs=512 count=1


    Let me explain the above command how it will work.
    “If”
    in the command is nothing but to specify Input File, here we are specifying our input file as hard disk(if the hard disk is /dev/hda it is primary master, so for general purpose I given 'x'). “of” in the command is nothing but to specify Output File, here we are specifying our output file as /safe/location. Then “bs” this is nothing but block size to write in to hard disk. And then “count” nothing but how many times you want to write date this many block sizes. Here in this example count=1 that means first 512 bytes of the hard disk is copied to the specified location.


    3.How to restore the MBR?
    #dd if=/safe/location of=/dev/hdx bs=512 count=1


    Note : Please replace “hdx” with your hard disk name.
    This is bit complex,
    Is there any other way to restore MBR?
    Yes, if you have Linux or Windows bootable CD, we can easily restore your MBR if you forgot to take backup(And this method is very much easy to do restoration of MBR when compared to previous method).


    Method1 : With Redhat Linux bootable CD.
    For this you have to boot your system to rescue mode, then mount your file system to rescue mode and execute below command to restore your MBR
    #grub-install /dev/hdx


    Note : Please replace hdx with your hard disk name. After that you just reboot your system. Your system will be live and working.

    Method2 : With Windows XP bootable CD.
    Step1 : Boot the system with XP bootable cd
    Step2 : Press f8 to go to repair mode in Windows
    Step3 : Once you got the c drive prompt just type below command
    Fixmbr
    This command will fix the MBR record.


    Some FAQ’s
    1. What is the MBR size?
    Ans :
    MBR size is just 512 bytes.


    2.What MBR conations?
    Ans :
    Mainly MBR can be divided in two parts
    a.Boot loader information block(which is of 448 bytes)
    b. Partition table information(which is of just 64 bytes)


    3.How many partition we can create on a hard disk?
    Ans :
    Totally we can create four partitions as below
    a.Four primary parathions.
    b.Three primary and one extended partition.
    c.Two primary and one extended parathion.
    d.One primary and one extended parathion.


    Note : In extended parathion we can create logical partitions up to 24 in number.

    4.Why we cannot create more then 4 partition as mention above?
    Ans :
    In MBR, the partition table info is just stored in 64 bytes, and one parathion information to store in MBR requires 16 bytes of space. So at most you can create only 4 partitions as mention above.


    Please Comment your thoughts regarding this post:-)

  • Like the post? Please Subscribe to free RSS feed to get updates
  • EXT2 VS EXT3 File Systems

    3 comments

    The differences between Ext2 and Ext3 file systems are as follows.











    Sl.No

    EXT2

    EXT3

    Journling

    No journling

    Has journling

    Speed of file system(read-write)

    Bit faster

    Bit slower then ext2 file-system

    Data corruption

    File system may be corrupted due to unplanned reboots

    Prevents file-system corruption

    Way to recover data

    Require fsck to recover data after unplanned reboot

    Does not require(automatic file recovery is done at booting time)

    Online file system growth.

    By default there is no Online file system growth.

    Online file system growth

    Commands to format

    mkfs.ext2 or mke2fs

    mkfs.ext3 or mke2fs -j

    Max file size(if block size is 1kB)

    2GB

    16GB

    De-fragmentation

    Easy and done with e2defrag

    There is no data security when doing de-fragmentation.

    Data accommodation

    More data can be accommodated in a give space

    Less date is written when compare to ext2 in a give space due to journling.


    Some FAQ's:

    1. What is Journaling?
    Ans : In general, Journaling file systems avoid file system corruption by maintaining a journal. The journal is a special file that logs the changes destined for the file system in a circular buffer. At periodic intervals, the journal is comitted to the file system. If a crash occurs, the journal can be used as a checkpoint to recover unsaved information and avoid corrupting of file system metadata.

    2.How many file systems supported by linux? and what are they?
    Ans : As of now(09-Nov-2009)
    Linux will supports : Btrfs, cifs, davfs, ext, ext2, ext3, ext4, exofs, hpfs, JFS minix, msdos, ncpfs, NiLFS(2), ntfs, nfs, proc, smbfs, iso9660, sysv, hpfs, affs, ufs, umsdos, vfat, xia, xfs, ZFS.
    Note : Please add some more file systems which you people know in the comment section. So that i will update the post with new file systems.

    3.What is the maxium size of a paration we can create using ext2 and ext3?
    Ans : 4TB paratation
    can be created in each ext2 and ext3 file system respectively.

    4.What is the maxium size of a file we can create in ext2?
    Ans :
    The maximum size what we can create is 2GB to 2TB. It depends on the block size we taken when we are formating. If the block size is 1KB we can not create a file more than 2GB in ext2 file system.

    5.What is "ext" in ext2 and ext3?
    Ans :
    When linux first implemented the default file system is minixfs, in subsequent years it was replaced its sucesser file system called extended filesystem. So the naming convention. So ext2 is second version of extended file system. Same explanation is given to ext3 and ext4.

    6. Some points about ext4
    a.
    It supports 64 bit storage limits, where as ext, ext2, ext3 are 32Bit storage limits and minix is 16Bit storage limit.
    b.Have backward compatibility and performance is improved from lower version.
    c.Extents are introduced (An extent is a range of contiguous physical blocks, improving large file performance and reducing fragmentation. A single extent in ext4 can map up to 128MB of contiguous space with a 4KB block size).

    And there are many more advantages please see the below links for more info about all the file systems..
    http://en.wikipedia.org/wiki/Ext4
    http://en.wikipedia.org/wiki/Ext3
    http://en.wikipedia.org/wiki/Ext2
    http://en.wikipedia.org/wiki/Extended_file_system
    http://www.ibm.com/developerworks/library/l-journaling-filesystems/index.html
    http://www.oracle.com/technology/pub/articles/calish_filesys.html
    http://www.cyberciti.biz/tips/understanding-unixlinux-file-system-part-i.html Please comment your thoughts regarding this post. To give feed back click here.

  • Like the post? Please Subscribe to free RSS feed to get updates
  • Archive

    Translate this page

     

    The Linux Juggernaut | Copyright 2006-2009 Surendra Kumar Anne | Surendra's Home Page | Give us feedback how we are doing, Click here