Friday, June 27, 2014



DNS server installation and configuration on Redhat 6 64 bi
Example Configuration

DNS Server Details:
Operating System                            : Redhat 6.5 64 bit
Hostname                                        : tn.example.gov.in
IP Address                                      : 192.168.1.161/24
Client Details:
Operating System                            : Redhat 6.5 64 bit
Hostname                                        : tn2.example.gov.in
IP Address                                      : 192.168.1.221/24
DNS installation Steps:
1.       Install Bind Chroot DNS server :
# yum install bind-chroot bind -y

2.       Copy all bind related files to prepare bind chrooted environments :
# cp -R /usr/share/doc/bind-*/sample/var/named/* 
  /var/named/chroot/var/named/

3.       Create bind related files into chrooted directory :
# touch /var/named/chroot/var/named/data/cache_dump.db
# touch /var/named/chroot/var/named/data/named_stats.txt
# touch /var/named/chroot/var/named/data/named_mem_stats.txt
# touch /var/named/chroot/var/named/data/named.run
# mkdir /var/named/chroot/var/named/dynamic
# touch /var/named/chroot/var/named/dynamic/managed-keys.bind

4.       Bind lock file should be writeable, therefore set the permission to make it writable as below :
# chmod -R 777 /var/named/chroot/var/named/data
# chmod -R 777 /var/named/chroot/var/named/dynamic

5.       Set if you do not use IPv6 :
# echo 'OPTIONS="-4"' >> /etc/sysconfig/named

6.       Copy /etc/named.conf chrooted bind config folder :
# cp -p /etc/named.conf /var/named/chroot/etc/named.conf

7.       Configure main bind configuration in /etc/named.conf. Append the example.gov.in information to the file :
# vi /var/named/chroot/etc/named.conf

a.       Add bind DNS IP addresses :
..
listen-on port 53 { 127.0.0.1;192.168.1.161;192.168.1.0; };
..

b.      Create forward and reverse zone :
..
..
zone "example.gov.in" {
    type master;
    file "example.gov.in.zone";
};
 
zone "1.168.192.in-addr.arpa" IN {
        type master;
        file "192.168.1.zone";
};
..
..
 
Full configuration for 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.161;192.168.1.0; };
        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 "example.gov.in" {
    type master;
    file "example.gov.in.zone";
};
 
zone "1.168.192.in-addr.arpa" IN {
        type master;
        file "192.168.1.zone";
};
include "/etc/named.rfc1912.zones";
include "/etc/named.root.key";

8.       Create Forward and Reverse zone files for domain example.gov.in.
a.       Create Forward Zone :
# vi /var/named/chroot/var/named/example.gov.in.zone

;
;       Addresses and other host information.
;
$TTL 86400
@       IN      SOA     ns1.example.gov.in. root.example.gov.in. (
                               2013042201      ; Serial
                               43200      ; Refresh
                               3600       ; Retry
                               3600000    ; Expire
                               2592000 )  ; Minimum

;       Define the nameservers and the mail servers

               IN      NS      ns1.example.gov.in.
               IN      A       192.168.1.161
               IN      MX      10 mail.example.gov.in.

tn           IN      A       192.168.1.161
mail            IN      A       192.168.1.161
ns1              IN      A       192.168.1.161
tn2             IN      A       192.168.1.221

b.      Create Reverse Zone :
# vi /var/named/chroot/var/named/192.168.1.zone
 
;
;       Addresses and other host information.
;
$TTL 86400
@       IN      SOA     ns1.example.gov.in. root.example.gov.in. (
                               2013042201      ; Serial
                               43200      ; Refresh
                               3600       ; Retry
                               3600000    ; Expire
                               2592000 )  ; Minimum
 
@        IN      NS      ns1.example.gov.in.
@        IN      PTR     example.gov.in.
ns1     IN      A       192.168.1.161
161      IN     PTR     mail.example.gov.in.
161      IN     PTR     ns1.example.gov.in.
161     IN      PTR     tn.example.gov.in.
221     IN      PTR     tn2.example.gov.in.

9.       Start Bind service :
# /etc/init.d/named start
Generating /etc/rndc.key:                                  [  OK  ]
Starting named:                                            [  OK  ]

10.   Configure Bind auto start at boot :
# chkconfig --levels 235 named on

11.   Test and verify Bind DNS setup :
a.       Test and verify using host command :
# host -t ns example.gov.in
# host -t mx example.gov.in
b.      Test and verify using nslookup command :
# nslookup
Ø  Set  type=any
Ø  Example.gov.in

Ø  Exit

c.       Test and verify using dig command :
# dig example.gov.in

Wednesday, January 13, 2010

How to install sun virtualbox in debian/ubuntu

To install sun virtualbox in linux debian/ubuntu follow the steps:

1.Add the following lines according to the distribution to the /etc/apt/sources.list file
#vim /etc/apt/sources.list
deb http://download.virtualbox.org/virtualbox/debian lenny non-free
deb http://download.virtualbox.org/virtualbox/debian etch non-free
deb http://download.virtualbox.org/virtualbox/debian sarge non-free
deb http://download.virtualbox.org/virtualbox/debian hardy non-free
deb http://download.virtualbox.org/virtualbox/debian gutsy non-free


2.The Sun public key for apt-secure can add with
#apt-key add sun_vbox.asc
or combine downloading and registering:
#wget -q http://download.virtualbox.org/virtualbox/debian/sun_vbox.asc -O- | sudo apt-key add -

3.Update the repository
#apt-get update

4.search the package virtualbox
#aptitude search virtualbox

5.Install the virtualbox 3.0 or 3.1
#apt-get install virtualbox-3.0

Note: Ubuntu users might want to install the dkms package (not available on Debian) to ensure that the VirtualBox host kernel modules (vboxdrv, vboxnetflt and vboxnetadp) are properly updated if the linux kernel version changes during the next apt-get upgrade.

Wednesday, January 6, 2010

How to recover Mysql root password

You can recover the mysql root password just following the procedure:
1. Stop the mysql server
#/etc/init.d/mysql stop

output:
Stopping MySQL database server: mysqld.

2. Start the mysql server without the password such as:
#mysqld_safe --skip-grant-tables &

output:
[1] 5988
Starting mysqld daemon with databases from /var/lib/mysql
mysqld_safe[6025]: started

3.Connect to mysql server using mysql client
#mysql -u root

output:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 1 to server version: 4.1.15-Debian_1-log

Type 'help;' or '\h' for help. Type '\c' to clear the buffer.

mysql>

4.Now setup new mysql root user password
mysql> use mysql;
mysql> update user set password=PASSWORD("NEW-ROOT-PASSWORD") where User='root';
mysql> flush privileges;
mysql> quit

5.After it stop the mysql server
#/etc/init.d/mysql stop

output:
Stopping MySQL database server: mysqld
STOPPING server from pid file /var/run/mysqld/mysqld.pid
mysqld_safe[6186]: ended

[1]+ Done mysqld_safe --skip-grant-tables

6.Start the mysql server and test its working?
#/etc/init.d/mysql start
#mysql -u root -p

Sunday, January 3, 2010

Install postgresql-8.1 in debian

Before installing postgresql-8.1 you have to know any other version of postgresql in installed or not.Because debian etch allready have the postgresql-7.4. So first of all you run the command:

#aptitude search postgresql-7.4

If yes, then you remove it
#apt-get --purge remove postgresql-7.4

Now Install the new version 8.1
#apt-get install postgresql-8.1

After installation of postgresql, configure the files /etc/postgresql/8.1/main/pg_hba.conf and /etc/postgresql/8.1/main/postgresql.conf

#vim /etc/postgresql/8.1/main/pg_hba.conf
add
host all all 0.0.0.0/0 md5

for connecting the database out site from the network.

Now #vim /etc/postgresql/8.1/main/
ssl=false

listenaddress = '*'

save and close the files.
now restart the server as:
#/etc/init.d/postgresql-8.1 restart

Install pgadmin3 for GUI integration
#apt-get install pgadmin3

Making script run at boot time in debian

Debian uses the sys-V like init system for executing commands when system run level changes such as bootup and shutdown time.

If you want to add a new script to start at a machine boot.
You should copy a script to the directory /etc/init.d/.
make sure that is executable by running #chmod 755 /etc/init.d/example.sh
The simplest way to doing this is to use the command update-rc.d

#update-rc.d example.sh defaults

If you want to remove the script from the startup sequence in future run the command like this:
#update-rc.d -f example.sh remove

You can find the more information of that command on manuals.Run #man update-rc.d