Tuesday, 19 January 2010
How to configure DNS server in linux(BIND)
Now edit /etc/named.conf file according to the example below.
//
// named.caching-nameserver.conf
//
// Provided by Red Hat caching-nameserver 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.
//
// DO NOT EDIT THIS FILE - use system-config-bind or an editor
// to create named.conf - edits to this file will be lost on
// caching-nameserver package upgrade.
//
options {
listen-on port 53 { 127.0.0.1; 192.168.1.6; };
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";
query-source port 53;
query-source-v6 port 53;
allow-query { localhost; 192.168.1.0; 192.168.1.6; };
forwarders { 192.168.1.6; };
};
// 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.
//
zone "." IN {
type hint;
file "named.ca";
};
zone "xyz.com" {
type master;
file "xyz.com.zone";
};
zone "0.168.192.in-addr.arpa" {
type master;
file "192.168.0.zone";
};
now save exit file.
Second step- Now make & configure forward & reverse zone. In following destination path.
$ cd /etc/var/named/chroot/var/named/
$ cp localhost.zone xyz.com.zone
$ cp named.local 192.168.0.zone
$ vim xyz.com.zone
$TTL 86400
xyz.com. IN SOA host.xyz.com. root.host.xyz.com. (
46
3H
15M
1W
1D )
@ IN NS host.xyz.com.
host.xyz.com. IN A 192.168.1.6
host2.xyz.com. IN A 192.168.1.7
$ vim 192.168.1.0.zone
$TTL 86400
0.168.192.in-addr.arpa. IN SOA host.xyz.com. root.host.zyz.com. (
2008082915 ; Serial
28800 ; Refresh
14400 ; Retry
3600000 ; Expire
86400 ) ; Minimum
@ IN NS host.xyz.com.
6 IN PTR host.xyz.com.
7 IN PTR host2.xyz.com.
now save both file & exit
Step -3
change group ownership in bith file
$ chgrp named xyz.com.zone
$ chgrp named 192.168.1.0.zone
now restart named service
$ /etc/init.d/named restart
Tuesday, 27 October 2009
How to Configure multi CVS repository in fedora
First of all Install xinetd package.yum -y install xinetd
Install cvs package.yum -y install cvs*
Create a group cvs.
Create a user cvsroot and assing it to cvs group.
Now make sure that following entries are present in your /etc/services file if the entries are not present then add it manually save & exit.
- Than Create 2 directory to be used for cvs repository
# mkdir /test2
# chmod 777 /test
# chmod 777 /test2
Initialize the repository for the first time
# cvs -d /test init
# cvs-d /test2 init
Now this steps are important
execute # cvs -d /test1/ init
# cvs -d /test2/ init
Assign permission chmod 771 CVSROOT
This time,all local real system users can log into CVS server with their own passwords.
If you want to disable, you can do by:
# chmod 644 /test2/CVSROOT/config
Here you need to uncomment the line where #SystemAuth = yes. And set SystemAuth = no.
Check your /etc/xinetd.d/cvs file and check that following entries are available and if now as above add it manually for multi cvs repository.
Entry will look like this:-
# default: off
# description: The CVS service can record the history of your source
# files. CVS stores all the versions of a file in a single
# file in a clever way that only stores the differences
# between versions.
service cvspserver
{
port = 2401
socket_type = stream
protocol = tcp
wait = no
user = test
server = /usr/bin/cvs
server_args = -f --allow-root=/test --allow-root=/test2 pserver
}
now save & exit this file.
Now restart your xinetd service using following command
#service xinetd restart or /etc/init.d/xinetd restart
#chkconfig xinetd on
Now Disabled firewall & selinux.Then now your system user cannot use cvs services with their own system password.
# cd /test1/CVSROOT or cd /test2/CVSROOT
# touch passwd (make passwd file manually)
If passwd file is not available then create user by executing following commands:-
# htpasswd -d -c /test1/CVSROOT/passwd user
# htpasswd -d -c /test2/CVSROOT/passwd user
To add additional user:-
# htpasswd -d /test1/CVSROOT/passwd user2
Check cvs Repository-:
# su - user1
#
There should be no error when you have successfully login to the CVS server.
Wednesday, 8 July 2009
Step by step Install & configure Nagios
Nagios is a host and service monitor designed to inform you of network problems before your clients, end-users or managers do. It has been designed to run under the Linux operating system, but works fine under most *NIX variants as well. The monitoring daemon runs intermittent checks on hosts and services you specify using external "plugins" which return status information to Nagios. When problems are encountered, the daemon can send notifications out to administrative contacts in a variety of different ways (email, instant message, SMS, etc.). Current status information, historical logs, and reports can all be accessed via a web browser.
Nagios has a lot of features, making it a very powerful monitoring tool. Some of the major features are listed below:
Monitoring of network services (SMTP, POP3, HTTP, NNTP, PING, etc.)
Monitoring of host resources (processor load, disk and memory usage, running processes, log files, etc.)
Monitoring of environmental factors such as temperature
Simple plugin design that allows users to easily develop their own host and service checks
yum install httpd
yum install gcc
Create a new nagios user account and give it a password.
/usr/sbin/useradd nagios
passwd nagios
/usr/sbin/groupadd nagcmd
/usr/sbin/usermod -G nagcmd nagios
/usr/sbin/usermod -G nagcmd apache
Create a directory for storing the downloads.
mkdir ~/downloads
cd ~/downloads
wget http://osdn.dl.sourceforge.net/sourceforge/nagios/nagios-3.0.tar.gz
wget http://osdn.dl.sourceforge.net/sourceforge/nagiosplug/nagios-plugins-1.4...
cd ~/downloads
tar xzf nagios-3.0.tar.gz
cd nagios-3.0
Run the Nagios configure script, passing the name of the group you created earlier like so:
./configure --with-command-group=nagcmd
Compile the Nagios source code.
make all
Install binaries, init script, sample config files and set permissions on the external command directory.
make install
make install-init
make install-config
make install-commandmode
Don't start Nagios yet - there's still more that needs to be done...
Sample configuration files have now been installed in the /usr/local/nagios/etc directory. These sample files should work fine for getting started with Nagios. You'll need to make just one change before you proceed...
Edit the /usr/local/nagios/etc/objects/contacts.cfg config file with your favorite editor and change the email address associated with the nagiosadmin contact definition to the address you'd like to use for receiving alerts.
vi /usr/local/nagios/etc/objects/contacts.cfg
Install the Nagios web config file in the Apache conf.d directory.
make install-webconf
Create a nagiosadmin account for logging into the Nagios web interface. Remember the password you assign to this account - you'll need it later.
htpasswd -c /usr/local/nagios/etc/htpasswd.users nagiosadmin
Restart Apache to make the new settings take effect.
service httpd restart
cd ~/downloads
tar xzf nagios-plugins-1.4.11.tar.gz
cd nagios-plugins-1.4.11
Compile and install the plugins.
./configure --with-nagios-user=nagios --with-nagios-group=nagios
make
make install
chkconfig --add nagios
chkconfig nagios on
Verify the sample Nagios configuration files.
/usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg
If there are no errors, start Nagios.
service nagios start
Wednesday, 8 April 2009
Configure RT(Ticketing system) in Fedora
service mysqld start
service httpd start
Make sure the httpd & mysqld service start at boot
chkconfig httpd on
chkconfig mysqld on
RT Installation
tar –zxvf rt-3.6.6-bundle.tar.
Set repository -set repository if you are using rhel 5
vi /etc/yum/repos.d/localrt.repo
[rhel51-rt3] name=RT 3.6.6 for Red Hat Enterprise Linux 5.1 baseurl=file:///path/to/your/extracted/files enabled=1 gpgcheck=0
Install rt3 and all dependencies with yum yum install rt3
RT Post Setup
Now that rt is installed you may want to customize your setup. Inorder to do that you will need to know where your files are located. This package changes the file locations from the fedora6 version of rt,and differs greatly from the BP default
Customize /etc/rt3/RT_SiteConfig.pm
You may find a need to change the site configuration of rt from time to time. For example to point rt to a remote database, configure external authentication, or set other configurable options. Below are several options that I like to set, but keep in mind these may differ greatly from a standard configuration.
Set($WebExternalAuth , '1');
Set($WebFallbackToInternalAuth , '1');
Set($OldestTransactionsFirst, 0);
Set($MyTicketsLength, 25);
Set($MyRequestsLength, 25);
Set($WebBaseURL , "http://rt.blogspot.com");
Set($WebPath , ""); Set($WebImagesURL , $WebPath . "/NoAuth/images");
Set($rtname, 'blogspot.com');
Set($DatabaseHost , 'db.blgspot.com');
Set($DatabaseRTHost , 'localhost');
Set($DatabaseUser, 'dbuser');
Set($DatabasePassword , 'dbpassword');
Set($DevelMode, '0');
Set($ShowTransactionImages, 0);
Set($SuppressInlineTextFiles, true);
Initialize the RT database
rt-setup-databse --action init
Configure sendmail
Symlink rt-mailgate to /etc/smrsh, and create aliases to use RT:
ln -s /opt/rt3/bin/rt-mailgate /etc/smrsh/rt-mailgate
Edit /etc/aliases and add lines:
rt: "|/etc/smrsh/rt-mailgate --queue general --action correspond --url http://blogspot.com/"
rt-comment: “|/etc/smrsh/rt-mailgate –queue general –action comment –url http://blogspot.com/”
Edit /etc/mail/sendmail.mc and change the line:
DAEMON_OPTIONS(`Port=smtp,Addr=127.0.0.1, Name=MTA')dnl
to read:
dnl DAEMON_OPTIONS(`Port=smtp,Addr=127.0.0.1, Name=MTA’)
Edit /etc/dovecot.conf and change the line:
protocols = imap,imaps,pop3,pop3s
Rebuild your sendmail.cf:
m4 /etc/mail/sendmail.mc > /etc/mail/sendmail.cf
Add rt server alias to /etc/mail/local-host-names:
rt.blogspot.com
Restart sendmail:
service sendmail restart
Test your new RT instance
Login to your new RT instance and test things out:
Default URL : http://blogspot.com/rt3/
Default User: root
Default password-password
Wednesday, 1 April 2009
How to configure ldap in fedora & rhel -5
$ yum install openldap-servers
$ yum install openldap*
$rpm -qa | grep ldap
Take backup for slapd.conf
$ /etc/openldap/slapd.conf /etc/openldap/slapd.conf.bak
Edit the file /etc/openldap/slapd.conf
we need to change some lines suffix,
rootdn and the two rootpw lines.
Suffix is the high level descriptor you selected above. The
rootdn is who (the user) that owns the server and should start with
cn=. The first root password (rootpw) line should be set to
secret. You can generate an encrypted password for the second
rootpw line using the command:
$ slappasswd
Just cut and paste the output of the slappasswd command into the
second rootpw line in slapd.conf
$ vim /etc/openldap/slapd.conf
suffix "dc=bloger,dc=com"
bloger is a your domain name
rootdn "cn=Manager,dc=bloger,dc=com"
rootpw secret
rootpw {SSHA}MRNBda83kd9f7d7did902mLA1x0AVOWMRBua
save & exit this file.
open ldap.conf file.
$ vim /etc/openldap/ldap.conf
change 2 line in this file
HOST 127.0.0.1
BASE dc=bloger,dc=com
save & exit this file.
LDAP Migration tools-:
These tools are located
in /usr/share/openldap/migration. If
you don't find them in your distribution you can download these tools
from:
http://www.padl.com/OSS/MigrationTools.html
Install is simple.
cd MigrationTools-47
You then must edit migrate_common.ph and change the following site-specific variables to reflect your installation:
Now we need to add the base entries into the LDAP. Here is an example of a new base org. units you may need and a user new user. The file we will create in out example is bloger.com.ldif.
# Default DNS domain
$DEFAULT_MAIL_DOMAIN = "bloger.com";
# Default base
$DEFAULT_BASE = "dc=blger,dc=com
Create a data file (bloger.ldif) & copy following content.
$ tuch bloger.ldif
dn: dc=bloger,dc=com
objectclass: topsave this file.
objectclass: organization
o: bloger
description: Top level LDAP for bloger.com
dn: ou=Group,dc=bloger,dc=com
ou: Group
objectClass: top
objectClass: organizationalUnit
dn: ou=People,dc=bloger,dc=com
ou: People
objectClass: top
objectClass: organizationalUnit
dn: ou=Services,dc=bloger,dc=com
ou: Services
objectClass: top
objectClass: organizationalUnit
$ /usr/share/openldap/migration/migrate_base.pl > bloger.ldif
Import first record
$ ldapadd -a -W -x -D "cn=Manager,dc=bloger,dc=com" -f bloger.ldif
$ ldapsearch -x -b 'dc=bloger,dc=com' 'objectclass=*
Create test user-:create file newrec.ldif for test user & add some content in this file.
$ touch bloger.ldif
note- You need an empty line before each line starting with "dn:"
$ vim bloger.ldif
# test1, < style="font-weight: bold;">bloger, comsave & exit this file.
dn: uid=test,ou=People,dc=bloger,dc=com
cn: test
sn: test
objectClass: top
objectClass: person
objectClass: posixAccount
objectClass: shadowAccount
userPassword: {crypt}$!Z0ksiAKjsKLAsjuwyuAK!jksX
uid: test
uidNumber: 501
gidNumber: 501
loginShell: /bin/bash
homeDirectory: /home/test
shadowLastChange: 10877
shadowMin: 0
shadowMax: 999999
shadowInactive: -1
shadowWarning: 7
shadowFlag: 0
shadowExpire: -1
The dn: record must be uniqe and should include the include your suffix.
Add the record to your LDAP
To add a record to the ldap database we use the command ldapadd
$ ldapadd -W -x -D "cn=Manager,dc=bloger,dc=com" -W -f newrec.ldif
$ ldapsearch -x -b 'cn=test,dc=bloger,dc=com' will display this record if it is added correctly.$ getent passwdClient Side Authentication-:
1. Click System, select Administration and click Authentication. This will launch the Authentication Configuration window.
2. Check Enable LDAP Support and click the Configure LDAP button
3. Fill in the LDAP Search Base DN and LDAP Server fields. Click Ok when you are done.
4. Click the Authentications tab and check Enable LDAP Support.
To test this, create a user in your LDAP directory that is not in
your machine. Then check the account by fingering the
user. For example, if you add the test record for you
should be able to essue the command:
$ finger test1
Wednesday, 18 March 2009
Enable Passwordless Authentication with SSH
Step 1:
(*note server1 is the source server and server2 will be the destination server)
server1# mkdir ~/.ssh
Step 2:
server1# cd ~/.ssh
Step 3:
server1# ssh-keygen -t rsa
Generating public/private rsa key pair.
Enter file in which to save the key (”your_local_home”/.ssh/id_rsa):
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in id_rsa.
Your public key has been saved in id_rsa.pub.
The key fingerprint is:
18:6a:e3:78:ab:2d:0c:8e:f9:67:f7:30:32:44:77:34 phil@server1
Step 4:
server1# scp ~/.ssh/id_rsa.pub phil@server2.philchen.com:/home/phil/id_rsa.server1.pub
Step 5:
server1# ssh phil@server2.philchen.com Password:
Step 6:
server2# mkdir .ssh
Step 7:
server2# chmod 700 .ssh
Step 8:
server2# cat id_rsa.server1.pub >> .ssh/authorized_keys
Step 9:
server2# chmod 644 .ssh/authorzied_keys
Step 10:
server2# exit server1# ssh phil@server2.philchen.com
Thursday, 5 March 2009
Backups With Rsync
rsync is a command line utility that is used to synchronize files between two computers over a network to synchronize files between two filesystems. It was written as a replacement for rcp but with many new features. For example it uses an algorithm that will only transfer files that have been modified. SSH will be used to authenticate between the machines and to encrypt the network traffic.
The situation: We have four machines named: server, machine1, machine2, and machine3. The server has a tape drive that is used to do nightly backups. machine1 is used as a development box and has files that need to be backed up in /src and in /home. machine2 is used for mail and needs /home and /mail to be backed up. machine3 is a web server and needs /home, /var/www, and /etc/httpd backed up.
Create a shell script for each machine. Simplify your maintenance by placing the scripts in a central location. I like to use /root/scripts. Decide on where you want to log your output. I like /root/logs but another common option is to have the script mail you the output.
Add entries to your crontab to call the scripts. Make sure you leave enough time before your normal backups of the server that the rsync jobs complete.
Each night the following will occur:
- rsync machine1 -> Server
- rsync machine2 -> Server
- rsync machine3 -> Server
- backup server to tape
rsync -ave ssh --numeric-ids --delete machine1:/home /machine1
Next generate a public private key pair with ssh. Place the public key in the ~/.ssh/authorized_keys file in an account on machine1, machine2, and machine3 that has read access to the directories that need to be backed up. It is best not to use the root account on the remote machines, but you should evaluate the risk in your environment. Test that you can login to these accounts using ssh without using a password.
Test each one of the rsync scripts. The first time you run rsync will take the longest as it will need to copy all the files from the remote machines and not just the files that have changed.
Add the /machine1, /machine2, and /machine3 (or whatever you have named them) directories to the servers backup script.
While this process does not backup the entire remote machine, it will ensure that you will not lose irreplaceable data.
Starting with the example scripts included in this tutorial there are many changes that can be made to fit your specific circumstances.
The frequency of the rsyncs can be modified to occur more often or at different times. Simply by adding additional crontab lines the backup from the remote machines could be done everyday at lunch, multiple times a day or even hourly.
The scripts could also be changed to rotate between multiple backups on the server or could be changed to do some sort of processing on the files before they are backed up. For example if the home directories you are backing up contain web browser caches, they could be removed after the rsync but before the system backup.
Using this article as a starting point you should create a backup plan that fit your needs.
Example rsync script for machine1:
#!/bin/bash rsync -ave ssh --numeric-ids --delete machine1:/home /machine1 rsync -ave ssh --numeric-ids --delete machine1:/src /machine1
Example rsync script for machine2:
#!/bin/bash rsync -ave ssh --numeric-ids --delete machine2:/home /machine2 rsync -ave ssh --numeric-ids --delete machine2:/mail /machine2
Example rsync script for machine3:
#!/bin/bash rsync -ave ssh --numeric-ids --delete machine3:/home /machine3 rsync -ave ssh --numeric-ids --delete machine3:/var/www /machine3 rsync -ave ssh --numeric-ids --delete machine3:/etc/httpd /machine3
Example crontab file logging to a directory:
# Scripts to rsync machines 59 20 * * * /root/scripts/sync-machine1.sh >/root/logs/sync-machine1.log 2>&1 59 21 * * * /root/scripts/sync-machine2.sh >/root/logs/sync-machine2.log 2>&1 59 22 * * * /root/scripts/sync-machine3.sh >/root/logs/sync-machine3.log 2>&1 # # Nightly Backup script 59 23 * * * /root/scripts/backup.sh > /root/logs/backup.log 2>&1
Example crontab file mailing the output:
# Scripts to rsync machines 59 20 * * * /root/scripts/sync-machine1.sh 59 21 * * * /root/scripts/sync-machine2.sh 59 22 * * * /root/scripts/sync-machine3.sh # # Nightly Backup script 59 23 * * * /root/scripts/backup.sh