Archive for October, 2009

How to Add Exim Interface IP

Tuesday, October 20th, 2009

Consider your mail server IP got blacklisted by any of the RBLs . In such situations a quick solution is to route the emails through a secondary IP address on the same server which is not black listed . While you may have given the IP unblock request , but the advantage here is we needn’t want to wait till they remove the IP .

Follow the steps:-

1) ssh to your server

2) Make a copy of current configuration .

# cp /etc/exim.conf /etc/exim.conf.backup

3)  Stop exim

# /etc/init.d/exim stop

4)  Edit your exim configuration file.

# vi /etc/exim.conf

Find remote_smtp under Transports section . It would look like :

e1

Now remove the lines interface and helo_date and add the new interface .

It should look like :

e2

5) Save your changes and exit .

6) Set an attribute to exim configuration file so that it wont get reset to default during cpanel updates ( If you are changing the IP through Exim configuration editor under whm , it won’t get reset after a cpanel update) .

# chattr +aui /etc/exim.conf

7) Restart exim

#service exim restart

or

# /etc/init.d/exim restart

How to change via Exim configuration editor under WHM.

a) Follow step 1, 2 and 3 above .

b) Login to WHM

c) Navigate to Server Configuration >> Exim Configuration >> Advanced editor

e3

d) Go to Transports section

e4

Now you can make the changes as described in step 4 .

e) Save .

Note that while selecting the IP , you should make sure that it is not black listed anywhere . It would be better not to choose an IP on the same network and choose the one which is free . You can check if

there is any free IPs from WHM >> IP Functions >> Show IP address Usage .

The first priority should be determining why you were listed on these blacklists . If your server is sending spam unbeknownst to you, changing the IPs will merely result in getting a new set of IPs blacklisted, which ultimately doesn’t resolve your problem .

How to manage Qmail queue in Linux Plesk

Tuesday, October 20th, 2009

Plesk server uses qmail as a mail server. Following are some of the qmail commands for Plesk server.

1) To check the mail queue in plesk from command line, you can use the command :

# /var/qmail/bin/qmail-qstat

messages in queue: 10

messages in queue but not yet preprocessed: 0

2) You can examine the queue with qmail-qread.

# /var/qmail/bin/qmail-qread

q1

3) From the qread command you get the message’s id . In the above example , one of the id is 524514 . Now you can find the file holding the email in/var/qmail/queue with “find “command.

# find /var/qmail/queue -iname 524514

/var/qmail/queue/remote/22/524514

/var/qmail/queue/mess/22/524514

/var/qmail/queue/info/22/524514

4) From the mail header you get the IP address.

# vi /var/qmail/queue/mess/22/524514

q2

5) If you wish to remove the emails with some patterns , you can use qmail-remove ( You can download it from http://www.linuxmagic.com/opensource/qmail/qmail-remove )

# /etc/init.d/qmail stop (Stop qmail before removing)

# /var/qmail/bin/qmail-remove -r -p “Time Passing”

(considering that “Time Passing” was the subject of the email )

The above steps can be used to track Spammers .

Do you wish to completely remove all the mails from queue? Just run the below commands.

find /var/qmail/queue/mess -type f -exec rm {} \;

find /var/qmail/queue/info -type f -exec rm {} \;

find /var/qmail/queue/local -type f -exec rm {} \;

find /var/qmail/queue/intd -type f -exec rm {} \;

find /var/qmail/queue/todo -type f -exec rm {} \;

find /var/qmail/queue/remote -type f -exec rm {} \;


SuPHP Permission Issue

Tuesday, October 20th, 2009

suPHP enhances overall server security. When migrating from a server that is not running suphp to a server running these, permission and ownership issues occur . When you access your domain you usually see

s1

Tail the Apache error logs to see what the error is

# tail -f /usr/local/apache/logs/error_logs

You can see the error

[Thu Jul 12 09:00:09 2007] [error] [client XXX.XXX.X.X] SoftException in Application.cpp:601: Directory “/home/user/public_html/test.php” is writable by group .

[Thu Jul 12 09:00:11 2007] [error] [client XXX.XXX.X.X] Premature end of script headers:

The script fail if the php file or folder is writable for anyone other that the owner. Check the permission and ownership .

# cd /home/user/public_html/

# ll | grep test.php

-rwxrwxrwx 1 nobody nobody 158 2008-05-13 04:32 test.php

That shows test.php has full permission and is not owned by the user . Change the permission and ownership.

# chmod 644 test.php

# chown user.user test.php

If it is a server wide issue , then its difficult to change it for each user . Here is a script (for cpanel servers) that fixes all the files and folder permissions that occurs when server changes to suphp.

1) Save the script to a file .

# vi /root/suphpfix.sh

     #!/bin/bash
     for user in `ls /var/cpanel/users`; do
     chown ${user}:${user} /home/${user}/public_html
     chmod 755 /home/${user}/public_html
     find /home/${user}/public_html -group nobody -print0 | xargs -0 chgrp ${user}
     find /home/${user}/public_html -type f -print0 | xargs -0 chmod 644
     find /home/${user}/public_html -type d -print0 | xargs -0 chmod 755
     done

2) Make the script executable.

# chmod u+x /root/suphpfix.sh

3) Execute the script

# bash /root/suphpfix.sh

Done!!

Fiddling with a Layeredpanel server

Wednesday, October 14th, 2009

I’ve been fiddling with a layeredpanel server this morning. It’s amazing how this little monster soaks up heavy load and traffic hosting free websites.

I wanted to quickly share some of the info which I found interesting.

(more…)