Ubuntu mail server (unfinished)

 


 

Intro

 

The objective is to setup an email server for an company intranet which allows the IT admin to create email accounts for each employee/user so that such employees/users can send and receive email from each other.

 

The company in question however does not have a static IP address on the internet for the server to be the authorative server for the company domain which may or not be registered on the internet. The company pays an ISP (or any third party email provider) for an email address which is the company's email address on the net that all emails from the company will appear to be from. It is decided that several key personnel will also have their own email address on the internet so that they can receive email directly.

 

So the email server must be able to collect email from this company address and relay emails from regular employees/users to use that email address and for certain key personnel be able to send and receive emails from the email accounts from the ISP and yet still be able to email regular employees.

 

 

Using Ubuntu 7.04 Server Edition , I will be using Postfix as a MTA, Dovecot as an IMAP server with shared email folders for the email accounts using the Ubuntu server guide documentation for Email servers. This mini-guide asumes you have just completed installing the Ubuntu server OS.

 

 

The scenario is as follows :

 

- the email server will have a static IP of 192.168.0.200 and will have email accounts @computersociety.org.tt, the company's email address from the ISP is info@someisp.co.tt

 

 

Installing Ubuntu Linux with software RAID 1

 

Refer to the article : Setting Up Software Raid in Ubuntu Server on installing Ubuntu with software RAID 1. You'll need a minimum of two physical hard disks, preferably SATA drives, instead of regular PATA IDE drives.

 

Post install hardware/software issues

 

The server hardware used is as Asus M2N4-SLI motherboard. There were two hardware/software issues errors that occured when booting into Ubuntu for the first time :

 

MP-BIOS bug: 8254 timer not connected to IO-APIC

 

I followed the suggestion at https://bugs.launchpad.net/ubuntu/+source/linux-meta/+bug/76989 which was to disable ACPI :

 

  • Enter "sudo vim /boot/grub/menu.lst" to edit this file
  • add the text "noapic nolapic acpi=off pci=noacpi" to the kernel line near the end of the file /boot/grub/menu.lst similiar to this :

 

## ## End Default Options ##

 

 

title           Ubuntu, kernel 2.6.20-16-generic

root           (hd0,0)

kernel       /boot/vmlinuz-2.6.20-16-generic root=/dev/md0 ro quiet splash noapic nolapic acpi=off pci=noacpi

initrd         /boot/initrd.img-2.6.20-16-generic

quiet

savedefault

 

 

Edit : hmmm.....actually if you edit out "quiet" instead, the problem does not occur. Interesting........

 

 

mdadm: No devices listed in conf file were found

 

Unfortunately, there is a bug in software RAID in Ubuntu 7.04 that didn't exist in Ubuntu 6.0.6.1 LTS, with a error message "mdadm: No devices listed in conf file were found" found, but which does continue to boot normally. The solution is to add "sleep 10" in the initramfs init script as described in http://ubuntuforums.org/showpost.php...81&postcount=5

  • Manually edit /usr/share/initramfs-tools/init
  • put sleep 10 after line log_begin_msg "Mounting root file system..."
  • Save the file, and then run update-initramfs -k all -u

 

To check where the RAID is working, enter the command cat/proc/mdstat. The output is typically something like this :

 

Personalities : [raid1]

md1 : active raid1 sda2[0] sdb2[1]

      2056256 blocks [2/2] [UU]

 

md0 : active raid1 sda1[0] sdb1[1]

      486327616 blocks [2/2] [UU]

 

unused devices: <none>

(This shows that there are two RAID 1 partitions : sda2 which acts as a swap partition and sda1 which is the root partition)

 

 

Enable root user

 

Ubuntu doesn't allow root access by default. To enable root access, sudo passwd root and specify a password. Afterwards you can log out and login in as root. Another reason for doing this : if you maintain multiple servers and you don't log in regularly to a server, you may discover you can't remember the system user when you need to! If you don't want to do this, you will have to login as the system user and type "sudo" before each command (and be prompted for your password)

 

 

Fixing Vi text editor

 

The default text editor in vi-tiny which by default is not configured as the Vi full. In edit mode, you can't use the arrow keys, you'll get "ABCD" being entered in the text file. To correct this, either run vim instead of vi. A more permanent solution, edit the file /etc/vim/vimrc.tiny and look for the lines :

 

 

let g:debian_cp = 1

set compatible

 

 

Rem out set compatible by putting a " in front and adding the line set nocp like this :

 

 

let g:debian_cp = 1

set nocp

" set compatible

 

 

You can now use vi and be able to use vi and use the arrow keys as you would using the full version of vi included in Ubuntu 6.0.6.1 LTS. A relief since you will be editing a lot of text files :-)

 

 

 

Installing relevant packages

 

apt-get update

apt-get upgrade

apt-get install openssh-server

 

 

The first two commands (apt-get update and apt-get upgrade will update your server with the latest versions). Installing openssh-server will allow you to login to the Ubuntu server via SSH over the network from a Windows machine using Putty without requiring you to be at the mail server.

 

 

Set hostname

 

We will be using mail.computersociety.org.tt as our hostname and the Ubuntu server will be set with a static IP of 192.168.0.200

 

So, vi /etc/hostname to put

 

computersociety.org.tt

 

Also, vi /etc/hosts and add this line under the 127.0.0.1 line

 

192.168.0.200 mail.computersociety.org.tt mail

 

After run hostname -F /etc/hostname to set the hostname to computersociety.org.tt.

You may need to reboot for this change to take effect

 

Also edit vi /etc/resolv.conf and add the following :

 

domain computersociety.org.tt

search computersociety.org.tt

 

 

 

Add users

 

Next, add user (email) accounts using the adduser command. In an intranet, there will be two types of email accounts :

  • those that exist on the internet ; anyone on the internet can send a email to that user. These users will be in the group "users"
  • email accounts that existly purely on this email server ; when these accounts send email to internet email accounts, the email has to be rewritten to appear to come from a single email address. These users will be in the group "vusers"

 

 

The group "users" already exists with a group id of 100. To create the group "vsuers", type

 

groupadd vusers

 

Type "cat /etc/group" to confirm the numeric group id for vusers. It would usually be 1001.

 

Next, we'll create a "allusers" user and "allusers" group for the shared email files that will be stored on the server. To create the group "allusers", type

 

groupadd allusers

 

Type "cat /etc/group" to confirm the numeric group id for allusers. It would usually be 1002.

 

To create the user "allusers" with a userid of 1002, in the allusers group 1002, and with no shell access, type

adduser --quiet -gid 1002 -uid 1002 --shell /bin/false  --disabled-password --gecos "" allusers

 

A home folder at /home/allusers will be created. This will be used for the shared folders for each email account

 

To set a password for allusers, type

 

echo "allusers:somepassword"|chpasswd -m

 

replacing somepassword with a password of your choice.

 

Note that these two commands didn't require user interaction. These will be used in script files later on.

 

 

Now, we will add the actual accounts in the users and vusers groups. These accounts have the following characteristics :

 

  • should have no shell access.
  • no home folders will be created
  • emails will be stored under a common base folder instead of using home folders. This makes it easier to script dovecot and postfix

 

 

With this in mind, it is important to make maintaining your email server as easy as possible so that adjustments/additions/deletions can be done easily and quickly, making your email adaptable to you.

 

So what are the steps for adding a user?

 

  • add the name to the appropriate user group (either user or vuser group)
  • set a user account  password which will be the email password for the user
  • create email folders under the common base folder. With dovecot, we will use the maildir format and an IMAP server. This requires several folders :
    • cur
    • new
    • tmp
    • .Sent
    • .Drafts
    • .Trash
  • set permissions of these folders to the "allusers" user and group

 

 

 

 

 

 

 

 

 

 

 

 

 

So vi /etc/adduser.conf and change the following lines :

 

DSHELL=/bin/bash to DSHELL=/bin/false

USERGROUPS=yes to USERGROUPS=no

 

Then, to add the accounts 'normalguy@computersociety.org.tt' and 'normalgal@computersociety.org.tt' to the users group :

 

 

adduser normalguy

adduser normalgal

 

and follow the prompts to set a password and optionally enter the full name and phone contact number.

 

To add the account 'virtualguy@computersociety.org.tt' to the vusers group :

 

adduser -gid 1001 virtualguy

 

 

Other useful housekeeping commands when adding/removing users :

  • use the "--force-badname" parameter to the adduser to add a user which doesn't meet usual account naming standards, e.g :"adduser --force-badname -gid 1001 vfirstname_surname" to add vfirstname_surname to the vusers group (1001)
  • to change the user account "someperson" from the user group to the vusers group, type "usermod -g vusers someperson" . You should also change the ownership of /home/someperson accordingly ; type "chgrp vusers /home/someperson"
  • to delete the user "strangeperson" type "userdel strangeperson" . To remove the /home/strangeperson folder, type "rm -r /home/strangeperson"

 

 

 

Create /etc/postfix/generic for vusers group

 

As described at http://www.postfix.org/ADDRESS_REWRITING_README.html#generic

 

we need to create a /etc/postfix/generic file that will map users in the vusers group to an actual email address say everyone@computersociety.org.tt

 

A typical /etc/postfix/generic would therefore be :

 

virtualperson@computersociety.org.tt everyone@computersociety.org.tt

anothervirtualperson@computersociety.org.tt everyone@computersociety.org.tt

yetanother@computersociety.org.tt everyone@computersociety.org.tt

 

 

After creating /etc/postfix/generic

 


Page Information

  • 1 year ago [history]
  • View page source
  • You're not logged in
  • No tags yet learn more

Wiki Information

Recent PBwiki Blog Posts