Friday, July 2, 2010

Set Up A Full-Featured Mail Server With iRedOS: MySQL, Postfix, Dovecot, ClamAV, SpamAssassin, Amavisd, RoundCube/SquirrelMail

Set Up A Full-Featured Mail Server With iRedOS: MySQL, Postfix, Dovecot, ClamAV, SpamAssassin, Amavisd, RoundCube/SquirrelMail

iRedMail is a shell script that lets you quickly deploy a full-featured mail solution in less than 2 minutes, since iredmail 0.5 it also supports Debian 5.0.1 (it supports both i386 and x86_64). Its object is to make a Linux mail server installation and configuration simple and easy to use. iRedMail supports both OpenLDAP and MySQL as backends for storing virtual domains and users.This tutorial shows how to use the MySQL backend.

Now iRedmail provides two webmail programs, RoundCube and SquirrelMail, and both support the MySQL and OpenLDAP backends and can change the password.

iRedOS is a customized CentOS 5.3 distribution, where e unnecessary packages were removed. It ships with the lastest version of iRedMail (iredmail0.50); it lets you install iredmail more quickly and smooth.

1 Requirements

To install such a system you will need the following:

2 Preliminary Note

In this tutorial we use:

  • Hostname mail.example.com
  • IP address 192.168.1.10
  • The first virtual domain: example.com

3 Install The Base System

Boot from iredos. Press at the boot prompt:

http://static.howtoforge.com/images/iredos/iredmail_00.png

Choose your language:

http://static.howtoforge.com/images/iredos/iredmail_01.png

Select your keyboard layout:

http://static.howtoforge.com/images/iredos/iredmail_02.png

I'm installing CentOS 5.3 on a fresh system, so I answer Yes to the question Would you like to initialize this drive, erasing ALL DATA?

http://static.howtoforge.com/images/iredos/iredmail_03.png

Now we must select a partitioning scheme for our installation. For simplicity's sake I select Remove all partitions on selected drives and create default layout.

http://static.howtoforge.com/images/iredos/iredmail_04.png

Answer the following question (Are you sure you want to do this?) with Yes:

http://static.howtoforge.com/images/iredos/iredmail_05.png

On to the network settings. The default setting here is to configure the network interfaces with DHCP, but we are installing a server, so static IP addresses are not a bad idea... Click on the Edit button at the top right.

http://static.howtoforge.com/images/iredos/iredmail_06.png

In the window that pops up uncheck Use dynamic IP configuration (DHCP) and Enable IPv6 support and give your network card a static IP address (in this tutorial I'm using the IP address 192.168.1.10 for demonstration purposes) and a suitable netmask (e.g. 255.255.255.0; )

http://static.howtoforge.com/images/iredos/iredmail_07.png

Set the hostname manually, e.g. mail.example.com, and enter a gateway (e.g. 192.168.1.1) and a DNS server (e.g. 4.2.2.1 ):

http://static.howtoforge.com/images/iredos/iredmail_08.png

Choose your time zone, don't select System clock uses UTC:

http://static.howtoforge.com/images/iredos/iredmail_09.png

Give root a password:

http://static.howtoforge.com/images/iredos/iredmail_10.png

The installation begins. This will take a few minutes:

http://static.howtoforge.com/images/iredos/iredmail_11.png

Now the CentOS installation has finished, start to install iredmail; if you selected No, the system would reboot and would not install iredmail.

http://static.howtoforge.com/images/iredos/iredmail_12.png

Choose the directory that will be used to store users' mailboxes.

http://static.howtoforge.com/images/iredos/iredmail_13.png

Choose the backend to store virtual domains and virtual users. Here we use MySQL.

http://static.howtoforge.com/images/iredos/iredmail_14.png

Set the MySQL root password:

http://static.howtoforge.com/images/iredos/iredmail_15.png

Set the password for the MySQL account vmailadmin:

http://static.howtoforge.com/images/iredos/iredmail_16.png

Set first virtual domain: example.com

http://static.howtoforge.com/images/iredos/iredmail_17.png

Set the admin user for the first virtual domain you set above. e.g. postmaster.

http://static.howtoforge.com/images/iredos/iredmail_18.png

Set a password for the admin user you set above.

http://static.howtoforge.com/images/iredos/iredmail_19.png

Create the first normal user. e.g. www.

http://static.howtoforge.com/images/iredos/iredmail_20.png

Create a password for the normal user you set above.

http://static.howtoforge.com/images/iredos/iredmail_21.png

Now you have the choice whether you want to enable SPF validation and DKIM signing/verification or not.

http://static.howtoforge.com/images/iredos/iredmail_22.png

Select optional components, you can choose between RoundCube or SquirrelMail as webmail programs.
Awstat user account: postmaster@example.com, for more details read the file /root/iRedMail/iRedMail.tips.

http://static.howtoforge.com/images/iredos/iredmail_23.png

Select the default language for your webmail application:

http://static.howtoforge.com/images/iredos/iredmail_24.png

Set a global admin user. It can manage all virtual domains and users in postfixadmin:

http://static.howtoforge.com/images/iredos/iredmail_25.png

Set a mail alias address for the root user:

http://static.howtoforge.com/images/iredos/iredmail_26.png

The installation is now finished, please reboot the machine:

http://static.howtoforge.com/images/iredos/iredmail_27.png

4 Important Things You Should Know After Installation

5 Access Webmail And Other Web-Based Programs

After the installation is complete, you can access web-based programs if you've chosen to install them:

Component

URL

Access via HTTP

Access via HTTPS

Comment

RoundCubeMail-0.2.1

http://your_server/mail/ (or /webmail, /roundcube)

YES

YES

Recommand webmail

SquirrelMail-1.4.19

http://your_server/squirrelmail/ (or /squirrel)

YES

YES

webmail

PostfixAdmin-2.2.1.1

https://your_server/postfixadmin/

No

YES

Only Mysql Backend

phpMyAdmin-2.11.9.5

https://your_server/phpmyadmin/ (or /mysql)

NO

YES


phpLDAPadmin-1.1.0.7

https://your_server/ldap/ (or /phpldapadmin)

NO

YES

Only LDAP Backend

Awstats-6.9

https://your_server/awstats/awstats.pl (or /awstats.pl?config=mail)

NO

YES


Note: Replace your_server with your server hostname or IP address.

Reference Website:
http://www.howtoforge.com/set-up-a-full-featured-mail-server-with-iredos-mysql-postfix-dovecot-clamav-spamassassin-roundcube-squirrelmail

BIND Installation On CentOS


What is bind?

BIND is alternative software for translating domain names into IP addresses. Because domain names are alphabetic, they are easier to remember. So if we will browse the Internet we don’t need to remember IP addresses. For example, the domain name www.yourdomain.com might translate to 192.168.0.1.

1. You Can Check BIND Packet

[root@server named]# rpm -qa bind*

bind-libs-9.2.4-2
bind-utils-9.2.4-2
bind-9.2.4-2

2. Setting Computer NS1 With IP 192.168.0.1 As Nameserver And Domain Name yourdomain.com

[root@server ~]# cat /etc/resolv.conf

nameserver 192.168.0.1

3. Setting File /etc/named.conf

[root@server ~]# nano /etc/named.conf

//

// named.conf for Red Hat caching-nameserver

//

options {

directory "/var/named";

dump-file "/var/named/data/cache_dump.db";

statistics-file "/var/named/data/named_stats.txt";

/*

* If there is a firewall between you and nameservers you want

* to talk to, you might need to uncomment the query-source

* directive below. Previous versions of BIND always asked

* questions using port 53, but BIND 8.1 uses an unprivileged

* port by default.

*/

// query-source address * port 53;

};

//

// a caching only nameserver config

//

controls {

inet 127.0.0.1 allow { localhost; } keys { rndckey; };

};

zone "localhost" IN {

type master;

file "localhost.zone";

allow-update { none; };

};

zone "yourdomain.com" IN {

type master;

file "/var/named/yourdomain.com.zone";

allow-update { none; };

};

zone "0.168.192.in-addr.arpa" IN {

type master;

file "/var/named/0.168.192.rev";

allow-update { none; };

};

include "/etc/rndc.key";

4. Setting File /var/named/yourdomain.com.zone

First you must create the file yourdomain.com.zone; you can use this syntax:

[root@server ~]# nano /var/named/yourdomain.com.zone

$TTL 86400

@ IN SOA yourdomain.com. root.yourdomain.com. (

100 ; serial

1H ; refresh

1M ; retry

1W ; expiry

1D ) ; minimum

@ IN NS ns1.yourdomain.com.

@ IN A 192.168.0.1

ns1 IN A 192.168.0.1

@ IN MX 10 mail.yourdomain.com.

mail IN A 192.168.0.1

WWW IN A 192.168.0.1

5. Setting File /var/named/0.168.192.rev

First you must create the file 0.168.192.rev; you can use this syntax:

[root@server ~]# nano /var/named/0.168.192.rev

$TTL 86400

@ IN SOA yourdomain.com. root.yourdomain.com. (

100 ; serial

1H ; refresh

1M ; retry

1W ; expiry

1D) ; minimum

@ IN NS ns1.yourdomain.com.

1 IN PTR binggo.yourdomain.com.

6. nslookup yourdomain.com

[root@server ~]# nslookup yourdomain.com

Server: 192.168.0.1
Address: 192.168.0.1#53

Name: yourdomain.com
Address: 192.168.0.1

7. dig yourdomain.com

[root@server ~]# dig yourdomain.com

; DiG 9.2.4 yourdomain.com
;; global options: printcmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 10576 ;; flags: qr aa rd ra; QUERY: 1, ANSWER: 1, AUTHORITY: 1, ADDITIONAL: 1

;; QUESTION SECTION:
;yourdomain.com. IN A

;; ANSWER SECTION:
yourdomain.com. 86400 IN A 192.168.0.1

;; AUTHORITY SECTION:
yourdomain.com. 86400 IN NS ns1.yourdomain.com.

;; ADDITIONAL SECTION:
ns1.yourdomain.com. 86400 IN A 192.168.0.1
;; Query time: 8 msec
;; SERVER: 192.168.0.1#53(192.168.0.1)
;; WHEN: Sat Aug 2 10:56:16 2008
;; MSG SIZE rcvd: 85

8. Configuration For NS 1 Is Finished

If you see errors, you can try to change the permissions of the folder /var/named.

[root@server ~]# chmod 777 -Rvf /var/named/

mode of `/var/named/’ changed to 0777 (rwxrwxrwx)
mode of `/var/named/named.zero’ changed to 0777 (rwxrwxrwx)
mode of `/var/named/localhost.zone’ changed to 0777 (rwxrwxrwx)
mode of `/var/named/198.99.208.rev’ changed to 0777 (rwxrwxrwx)
mode of `/var/named/data’ changed to 0777 (rwxrwxrwx)
mode of `/var/named/named.local’ changed to 0777 (rwxrwxrwx)
mode of `/var/named/named.ca’ changed to 0777 (rwxrwxrwx)
mode of `/var/named/named.ip6.local’ changed to 0777 (rwxrwxrwx)
mode of `/var/named/localdomain.zone’ changed to 0777 (rwxrwxrwx)
mode of `/var/named/yourdomain.com.zone’ changed to 0777 (rwxrwxrwx)
mode of `/var/named/named.broadcast’ changed to 0777 (rwxrwxrwx)
mode of `/var/named/slaves’ changed to 0777 (rwxrwxrwx)

9. Check The /var/log/messages Log To Find Out If There Are Errors

[root@server ~]# tail /var/log/messages

Aug 2 10:53:57 server named[20094]: listening on IPv4 interface venet0:0, 192.168.0.1#53
Aug 2 10:53:57 server named[20094]: command channel listening on 127.0.0.1#953
Aug 2 10:53:57 server named[20094]: zone 0.168.192.in-addr.arpa/IN: loaded serial 100
Aug 2 10:53:57 server named[20094]: zone yourdomain.com/IN: loaded serial 100
Aug 2 10:53:57 server named[20094]: zone localhost/IN: loaded serial 42
Aug 2 10:53:57 server named[20094]: running
Aug 2 10:53:57 server named[20094]: zone yourdomain.com/IN: sending notifies (serial 100)
Aug 2 10:53:57 server named[20094]: zone 0.168.192.in-addr.arpa/IN: sending notifies (serial 100)
Aug 2 10:53:57 server named[20094]: received notify for zone ‘yourdomain.com’
Aug 2 10:53:57 server named[20094]: received notify for zone ‘0.168.192.in-addr.arpa’

Reflectance Website:
http://www.howtoforge.com/installing-nictool-on-centos-5.2