Tuesday, February 16, 2010

Sendmail: How to setup Sendmail Client?

I've central e-mail server. Other servers does not need to operate as a mail server. How do I configure Sendmail as submission-only e-mail server (mail client) under CentOS / Fedora / RHEL / Debian Linux / UNIX like operating systems?

Sendmail or any MTA can work in two different modes. It can accept incoming SMTP e-mail requests and send mail from the local machine / workstation or server (cluster node). This is called outbound MTA and it always runes in a queue-only mode.

Step # 1: Disable Sendmail Daemon In a Listing Mode


Edit the file /etc/sysconfig/sendmail using the text editor such as vi, enter:

# vi /etc/sysconfig/sendmail

Modify the line:

DAEMON=no

Save and close the file.

Setting DAEMON=no tells Sendmail to execute only the queue runner on this machine, and never to receive SMTP mail requests on port # 25.

Step #2: Configure Mail Submission

You need to tell sedmail about a central MTA which will accept mail on port # 25 for all your domains. For e.g. mail.nixcraft.net act as a central MTA. Edit /etc/mail/submit.cf, enter:

# vi /etc/mail/submit.cf

Find the line beginning with D{MTAHost}, and update it to read as follows:

D{MTAHost}mail.nixcraft.net

Save and close the file. mail.nixcraft.net is the hostname of the server to which this machine should forward its all outgoing mail. Please note that mail.nixcraft.net must be configured to accept mail from your other workstations or server. Once done reload sendmail.

Sendmail Relaying : Understanding what's the Relaying all about?

My Overall architectural setup resembles as shown below:

langille.org [NEW DOMAIN] <=== freebsddiary[MAIL SERVER] <== INTERNET <== fred.logic.com[ ANY FOREIGN CLIENT]


I use langille.org as an example domain.
Just registered this domain few days back.
My Mail server is freebsddiary.

As of now my sendmail doesnt know about that domain.
I will have to tell the server about this new domain.

My Mail server doesn't accept incoming mail for that domain(langile.org).However may mail is registered as the mail host for that domain.

Type the following command :

host langille.org

langille.org mail is handled (pri=5) by freebsddiary.yi.org

If someone tried to send mail to langille.org, it will arrive at freebsddiary.org(my mail server) but it will be refused.


Logs will report:

Oct 30 11:04:44 ducky sendmail[98224]: LAA98224: ruleset=check_rcpt,
arg1=, relay=mta1-rme.xtra.co.nz [203.96.92.1], reject=550
... Relaying denied
Oct 30 11:04:44 ducky sendmail[98224]: LAA98224: from=, SIZE=938,
class=0, pri=0, nrcpts=0, proto=ESMTP,
relay=mta1-rme.xtra.co.nz [203.96.92.1]


Note that above example represents mail being sent to langille.org from an external domain. It is incoming mail.

To allow sendmail to receive mail for langille.org, I added the following entry to

/etc/mail/sendmail.cw (after sendmail version 8.10, this file is local-host-names).

langille.org

Then I told sendmail to re-read it's configuration files by issuing the following commands.

# killall -hup sendmail

Example:

Your friend's domain is retch.org. You wish to allow your friend to use your mail server. The box he will be sending mail from is dry.retch.org.

You would add the following entries to the files on your mail server:

File: /etc/mail/relay-domains

dry.retch.org

The above tells your mail server to accept outgoing mail from the host dry.retch.org.

File: /etc/mail/sendmail.cw

retch.org

The above tells your mail server to accept incoming mail for the domain retch.org (after sendmail version 8.10, this file is local-host-names).

Final Conclusion:

/etc/mail/relay-domains contains a list of hosts which are allowed to relay mail through your mail server. This list may consist of either specific hosts or whole domains.

/etc/mail/sendmail.cw (after sendmail version 8.10, this file is local-host-names) contains a list of domains for which your mail server will accept mail. This list is usually the domains hosted by your machine.

Wednesday, February 10, 2010

NFS : Important Interveiw Questions !!

Here I would like to share few of NFS Questions generally asked in the Interview.

1. What RPM you need for NFS server?

rpm -qa nfs*
nfs-utils-1.0.9-33.el5
nfs-utils-lib-1.0.8-7.2.z2

2. What daemon is need for NFS to start?

NFS depends on the portmapper daemon, either called portmap or rpc.portmap. It will need to be started first. It should be located in /sbin but is sometimes in /usr/sbin. Most recent Linux distributions start this daemon in the boot scripts, but it is worth making sure that it is running before you begin working with NFS (just type ps aux | grep portmap)

3.What daemons takes care of NFS serving?

NFS serving is taken care of by five daemons:

rpc.nfsd, which does most of the work;

rpc.lockd and rpc.statd, which handle file locking;

rpc.mountd, which handles the initial mount requests, and

rpc.rquotad, which handles user file quotas on exported volumes.

Starting with 2.2.18, lockd is called by nfsd upon demand, so you do not need to worry about starting it yourself. statd will need to be started separately. Most recent Linux distributions will have startup scripts for these daemons.

The daemons are all part of the nfs-utils package, and may be either in the /sbin directory or the /usr/sbin directory.

If your distribution does not include them in the startup scripts, then then you should add them, configured to start in the following order:

rpc.portmap
rpc.mountd, rpc.nfsd
rpc.statd, rpc.lockd (if necessary), and rpc.rquotad

4.You made some changes in /etc/exports. Does it show effect immediately?

No.
You should run the command exportfs -ra to force nfsd to re-read the /etc/exports file. If you can't find the exportfs command, then you can kill nfsd with the -HUP flag (see the man pages for kill for details).

If that still doesn't work, don't forget to check hosts.allow to make sure you haven't forgotten to list any new client machines there

5.What software you need for NFS Client setup running? ( Very Important)

To begin using machine as an NFS client, you will need the portmapper running on that machine, and to use NFS file locking, you will also need rpc.statd and rpc.lockd running on both the client and the server.

With portmap, lockd, and statd running, you should now be able to mount the remote directory from your server just the way you mount a local hard drive
with the mount command

6.How to get NFS File Systems to Be Mounted at Boot Time?

An Entry in /etc/fstab is enough

master.foo.com:/home /mnt nfs rw 0 0

7.What is Hard Mounting and Soft Mounting in NFS terminology?

There are some options you should consider adding at once. They govern the way the NFS client handles a server crash or network outage. One of the cool things about NFS is that it can handle this gracefully. If you set up the clients right. There are two distinct failure modes:

soft

If a file request fails, the NFS client will report an error to the process on the client machine requesting the file access. Some programs can handle this with composure, most won't. We do not recommend using this setting; it is a recipe for corrupted files and lost data. You should especially not use this for mail disks --- if you value your mail, that is.
hard

The program accessing a file on a NFS mounted file system will hang when the server crashes. The process cannot be interrupted or killed (except by a "sure kill") unless you also specify intr. When the NFS server is back online the program will continue undisturbed from where it was.

8. Whats the solution for NFS then?

We recommend using hard,intr on all NFS mounted file systems.

Picking up the from previous example, the fstab entry would now look like:

# device mountpoint fs-type options dump fsckord
...
master.foo.com:/home /mnt/home nfs rw,hard,intr 0 0

9.How to do NFS performance optimization?

Follow the link http://www.linux.org/docs/ldp/howto/NFS-HOWTO/performance.html for better understanding.

Hope it helps you attending overall important interview questions.
Read this space again. I will add up more in future.

Apache: How to install Apache through source

The Contents have been moved to new website

Tuesday, February 9, 2010

Apache:How to install ANT tool under Linux

In this tutorial I will show you how you can install ant tool on your linux box. This installing ant in linux is based on the practical work.
Step 1:
Download ant from http://ant.apache.org/bindownload.cgi. I have downloaded apache-ant-1.7.1-bin.zip for this tutorial.

Step 2:

Login to your Linux box and create a directory "ant" under /usr/local.

[root@RoseIndiaLinux local]# mkdir ant
[root@RoseIndiaLinux local]# cd ant
[root@RoseIndiaLinux ant]# pwd
/usr/local/ant
[root@RoseIndiaLinux ant]#

Step 3:

Copy apache-ant-1.7.1-bin.zip onto your Linux box in /usr/local/ant directory.

Step 4:

Extract the zip file apache-ant-1.7.1-bin.zip) using unzip command.

[root@RoseIndiaLinux ant]# unzip apache-ant-1.7.1-bin.zip

above command will extract the content of the zip file and will create a new directory apache-ant-1.7.1

Step 5:

Set path in the .bash_profile

Open the file /root/.bash_profile and add the following codes:

export ANT_HOME=/usr/local/ant/apache-ant-1.7.1
export JAVA_HOME=/opt/java/jdk1.6.0_06
export PATH=${PATH}:${ANT_HOME}/bin

Step 6:

Logout and login again to your Linux box. Now ant available on your box.

Port Redirection: Howto?

You can easily redirect incoming traffic by inserting rules into PREROUTING chain of the nat table. You can set destination port using the REDIRECT target.
Syntax

The syntax is as follows to redirect tcp $srcPortNumber port to $dstPortNumber:

iptables -t nat -A PREROUTING -i eth0 -p tcp --dport $srcPortNumber -j REDIRECT --to-port $dstPortNumbe

The syntax is as follows to redirect udp $srcPortNumber port to $dstPortNumber:

iptables -t nat -A PREROUTING -i eth0 -p udp --dport $srcPortNumber -j REDIRECT --to-port $dstPortNumbe

Replace eth0 with your actual interface name. The following syntax match for source and destination ips:

iptables -t nat -I PREROUTING --src $SRC_IP_MASK --dst $DST_IP -p tcp --dport $portNumber -j REDIRECT --to-ports $rediectPort

Examples:

The following example redirects TCP port 25 to port 2525:

iptables -t nat -A PREROUTING -i eth0 -p tcp --dport 25 -j REDIRECT --to-port 2525

In this example all incoming traffic on port 80 redirect to port 8123

iptables -t nat -I PREROUTING --src 0/0 --dst 192.168.1.5 -p tcp --dport 80 -j REDIRECT --to-ports 8123

Quoting from the iptables man page:

This target is only valid in the nat table, in the PREROUTING and OUTPUT
chains, and user-defined chains which are only called from those
chains. It redirects the packet to the machine itself by changing the
destination IP to the primary address of the incoming interface
(locally-generated packets are mapped to the 127.0.0.1 address). It
takes one option:

--to-ports port[-port]
This specifies a destination port or range of ports to use:
without this, the destination port is never altered. This is
only valid if the rule also specifies -p tcp or -p udp.

The OUTPUT chain example:

iptables -t nat -I OUTPUT --src 0/0 --dst 192.168.1.5 -p tcp --dport 80 -j REDIRECT --to-ports 8123

How Do I View NAT Rules?

Type the following command:

iptables -t nat -L -n -v

How Do I Save NAT Redirect Rules?

Type the following command:

iptables-save

Connecting RHEL to Active Directory Server through Winbind

You have a RHEL system and you want to authenticate it against your active directory. The good news is that Red Hat has made it easy for you to do this. The bad news is that they only get the most basic structure working for you.

Here I will show you how to get WinBind authentication working using Authconfig, and how make it a little more seamless than this utility leaves it off.

It should be noted that while this works perfectly well, it is really not the best way to authenticate users against a UNIX host. Given the option, having your users in OpenLDAP and PAM authenticating them against that would be a much better option. However, we don’t live in a perfect world, and sometimes we just have to make things work.

Let’s start by using authconfig to join your machine to the domain. This should all be done as the root user.

# authconfig

* Select “Use Winbind” and Use “Winbind Authentication”. Remember to leave “Cache Information”, “Use MD5 Passwords” and “Use Shadow Passwords” selected.
* Select “Next”
* Under “Security Model” select “ads”
* “Domains:” examplead (substatute with the name of your Active Directory)
* “Domain Controllers:” adserver.domain.com (Again, substitute with the name of your Active Directory server)
* “ADS Realm:” ADSERVER.DOMAIN.COM
* “Template Shell:” /bin/bash
* Select “Join Domain”
* Select “OK”

Now your machine should be be on the domain. Test it to make sure you can see your AD users:

# wbinfo -u

You should see your users in the list.

The only problem is that to do anything with them, you have to express their user name in that annoying way Windows likes you to. Something like this:

“EXAMPLEAD\\username”

Not very usefull. To get around this, simply edit “/etc/samba/smb.conf” and change this line:

winbind use default domain = no

to this:

winbind use default domain = yes

You should now be able to express AD usernames without the domain nonsense before it. Try it:

# finger username
Login: username Name: Username
Directory: /home/EXAMPLEAD/username Shell: /bin/bash
Never logged in.
No mail.
No Plan.

Finally check your “/etc/nsswhich.conf” file to make sure RHEL knows to use WinBind. Authconfig should have set this up for you, and it should have lines that look like this:

passwd: files winbind
shadow: files winbind
group: files winbind

Note:Follow these instructions to have your users directories automatically created….

http://kbase.redhat.com/faq/FAQ_43_5367.shtm