Linux

Qmail : Domain specific relaying

Recipe to forward e-malis destined to a particular domain in qmail
1) Edit smtproutes (usually located in /var/qmail/control) and add the following line
DOMIAN_TO_FORWARD:HOST_TO_FORWARD_TO

2) Edit rcpthosts (usually located in /var/qmail/control) and add name of the domain

3) Restart qmail

Note: Make sure that the domain is not listed in the virtualdomains files too. Or qmail will process the virtualdomains file first and ignore the smtproutes entry.

Qmail : Trick

If you are using vpopmail and qmail to host virtual domains, you can get a list of all the aliases in a domain by using valias. The syntax is
valias -s DOMAIN_YOU_WANT_TO_LIST_ALIASES

If you want to list the users (and NOT aliases) in a domain, you can use vuserinfo. The syntax is
vuserinfo -D DOMAIN_YOU_WANT_TO_LIST_USERS

Reprocess existing e-mail

Ran into an issue at work, where we had to reprocess all e-mails for a particular user on a Linux server. The email was stored in the standard mailbox format in /var/mail and all the e-mail was supposed to be sent to a different e-mail address. Here’s how we solved the issue

1) Use formail to split the mailbox into seperate messages and pipe it to sendmail. Command used was

formail -Y -n -s� sendmail -odq NAME_OF_USER < /var/mail/NAME_OF_USER

2) Force sendmail to process the queue and send the e-mail to the new address. Command used was

sendmail -v -qRNEW_EMAIL_ADDRESS

You can also edit the .forward file in the users home directory to forward e-mail to the new address and then you don’t have to specify the new e-mail address in the second command.

VMWare on Ubuntu

Quick post (more to come later on) on how to install/configure VMWare Server on Ubuntu

1) Install Ubuntu in “server” config
2) Install X-Windows on Ubuntu by using
sudo apt-get install ubuntu-desktop
3) install smbmount/mount to access windows shares
sudo apt-get install smbfs
NOTE : To map a windows share.. try the following
sudo mount -t smbfs -o username=WINDOWS_USERNAME,password=WINDOWS_PASSWORD //WINDOWS_SERVER_NAME/c$ /tmp/FOLDER_TO_MOUNT
4) Install make by
sudo apt-get install make
5) To install a smp capable kernel,
a.Search for smp kernel images by using
sudo apt-cache search smp
b. Install the appropriate smp kernel from the list. In my case, it was
sudo apt-get install linux-amd64-k8-smp
6) Install 3.4 version of GCC so that VMWare can compile the kernel modules
a. sudo apt-get install build-essential
b. Install the kernerl headers for your kernel. To do this, first get the Kernel version by
sudo uname -r
I got “2.6.12-10-amd64-k8-smp”
then get the kernel headers by
sudo apt-get install linux-headers-‘kernel version’, in my case, it would be
sudo apt-get install linux-headers-2.6.12-10-amd64-k8-smp
c. Install 3.4 version of GCC by
sudo apt-get install gcc-3.4
d. Install the right g++ version by
sudo apt-get install g++-3.4
7) Install xinetd
sudo apt-get install xinetd

Updating NFS Share permissions..

Wanted to add this for my future reference. To update the permissions on a NFS (Network File System) share, you need to edit the “/etc/exports” file and then run “/usr/sbin/exportfs -a” to update the share permissions.

Syntax of /etc/exports looks like
/dir/to/export host1.mydomain.com(ro,root_squash)

UPDATE : Looks like the NFS daemon caches DNS lookups when authenticating a client. Am not sure if this is only in older versions. After we updated the exports file, the server still kep erroring out with a “unresolvable reverse lookup” error. I finally had to restart the daemon to make it check on the DNS records for the accessing client.

UBUNTU : Quick tips

I have heard a lot about the new Linux distro Ubuntu and wanted to try it out on my test machine at home. I chose the “base” install, which apparently just installs the base packages to operate the machine as a server. Couple of things I had to do to get the system up and running

1) The root account in Ubuntu doesn’t have a password by default. This means that you cannot log in or “su” to root. This can be fixed by issuing the following command
“sudo passwd root”
while logged in as the user you create while installing Ubuntu

2) Configure the network interface (eth0, if you only have one) with a static IP address. This can be done by editing the “interfaces” file in “/etc/network“. My file looks as below after the edit

# This file describes the network interfaces available on your system
# and how to activate them. For more information, see interfaces(5).
# The loopback network interface
auto lo
iface lo inet loopback
# This is a list of hotpluggable network interfaces.
# They will be activated automatically by the hotplug subsystem.
mapping hotplug
script grep
map eth0

# The primary network interface
auto eth0
iface eth0 inet static
address 192.168.0.10
gateway 192.168.0.1
netmask 255.255.255.0
network 192.168.0.0
broadcast 192.168.0.255

The text in bold is what I edited

3) Configure apt-get (package installer) to use the Internet archives as the source. This is esp. useful if you don’t have the install CD anymore. This can be done by editing the “sources.list” file located in “/etc/apt/” and commenting out the line with cdrom as the source. In my case it looks like this
# deb cdrom:[Ubuntu 5.04 _Hoary Hedgehog_ – Release i386 (20050407)]/ hoary main restricted“. If you have a different version of Ubuntu, the description might be different, but the source should still say deb cdrom.

Troubleshooting episode

I was helping a friend with some E-mail problems he was having. Here is the scenario. He is getting a “Cannot authenticate to server” when using his Outlook 2000 to get mail from his Cobalt Qube server. According to him..”Everything was working fine, but the computer crashed. So I had to rebuild the machine and now mail doesn’t work”. Pretty easy right.. So I troubleshoot it in the following way

1) Check account settings in Outlook and make sure that he has the correct “username”, “password” and “server” properties. Everything checks okay. But client still cannot authenticate to the server.

2) Alright.. Lets see if the service is running on the client. Since I didn’t have access to the server, I had to walk my friend through the process. Again, required daemons are running, but cannot authenticate.

3) Now.. I am getting all excited frustrated. I run nmap on the server remotely and see that SMTP is filtered.. Hmm.. Is that a problem.

4) Finally.. I give up and make my friend change the rules on this firewall so that I can log into the server remotely. First thing I do is check the logs (/var/log/maillog) and Bingo!!! I instantly see the error
Feb 9 21:00:10 www in.qpopper[2269]: Karen at 192.168.1.102 (192.168.1.102): -ERR [AUTH] Password supplied for “Karen” is incorrect.“. My friend was using “Karen” instead of “karen” as the username.

If only I had asked my friend to meticulously check his settings 🙂 in the first place.

Moral of the story: Unix usernames are case sensitive. And never believe the user when they say that all the settings are correct :).

Terminal prompt – L[U]nix

While browsing through the forums at ArsTechnica, I came across this posting. One of the poster had a pretty cool prompt on his terminal login screen. Here is the command he used to get that effect

export PS1=”\n\[\e[30;1m\][\[\e[35;1m\]0\[\e[30;1m\]] \[\e[0m\]\[\e[36m\]\h\[\e[37m\]:\[\e[34;1m\]\w\[\e[30;1m\]$ \[\e[0m\e7\e[1G\e[1H\e[1K\e[30;1m[\e[33m\j\e[30;1m] [\e[32;1m\!\e[30;1m] [\e[36m\u\e[30;1m] [\e[31;1m\d\e[30;1m] [\e[35m\@\e[30;1m] [\e[0m\e[36m`uname -sr`\e[30;1m]\e8\]”

Or if you are using Redhat, you can just edit the /etc/profile file and place the above command in it. So each time you log in to the system, you get this pretty cool prompt. I keep saying that it is cool :), but don’t give any explanation. I think a picture is due here…

Terminal Prompt

For the initiated..you can come up with your own neat tricks by reading this.