|
General software and network General OS-independent software and network questions, X11, MTA, routing, etc. |
|
Thread Tools | Display Modes |
|
|||
Virtual domains on multiple mail servers running Exim4 as MTA
Hi folks,
Exim as MTA What I'm exploring is as follow; - building multiple mail servers on guests of a Xen box running Debian Etch (I can make it without problem) - all mail servers running Exim4 as MTA. Each guest being a mail server has its own servername and local IP. - the most important goal is how to run multiple domains on one external IP. Each incoming mail can be delivered to its own mail server. It is similar to virtual domain. I made it on one mail server before without problem running other MTA. But I have no idea how to build virtual domain on multiple mail servers. Could you please shed me some light? Pointer would be appreciated. Regarding DNS server, bind9, do I need building it on each mail server? Can I build only DNS on one mail server to be shared by others? TIA B.R. satimis |
|
|||
Quote:
Xen - virtualization package host - Debian Etch, basic workstation guest - Debian Etch MTA - Postfix virtual Database - MySQL I just finished setting up a mail server on the guest of a Xen box running Postfix virtual. The said server serves multiple domains but connected to ONE external IP. On each domain there are multiple users. The mail server is now working. Incoming mails are routed to respective domain directory by MySQL. Users can login the server with their own login and password to send/receive mails on their mail client, Evolution. Or they can send/read mails direct on Webmail, SquirrelMail. Now my further exploration is instead of making MySQL route all incoming mails to respective domain directories created for this purpose can MySQL route the mails to other mail servers also running as guest on the same Xen box? Each mail server has its own hostname (the domain) and local IP. The working mail server together with MySQL do the routing. Quote:
Thanks B.R. satimis |
|
|||
Quote:
Thanks for your advice. Still I can't resolve if I install BIND9 on a guest of Xen box, only a base OS, BIND9 and some other required packages. Do I need to forward any port to it? If the local IP of this guest is 192.168.0.201 then on other guests (mail server) I'll edit /etc/resolv.conf Code:
nameserver 192.168.0.201 Quote:
/etc/postfix/mysql_transport.cf Code:
user=mail password=apassword dbname=maildb table=backups select_field=transport where_field=domain hosts=127.0.0.1 additional_conditions = and enabled = 1 mysql> SHOW tables; Code:
+------------------+ | Tables_in_maildb | +------------------+ | aliases | | domains | | users | ... ... mysql> SELECT * from domains; Code:
+------+-----------------------+-----------+---------+ | pkid | domain | transport | enabled | +------+-----------------------+-----------+---------+ | 1 | localhost | virtual: | 1 | | 2 | localhost.localdomain | virtual: | 1 | | 3 | satimis.com | virtual: | 1 | | 4 | satimis.dnsalias.com | virtual: | 1 | | 5 | satimis.changeip.net | virtual: | 1 | ..... .... mysql> SELECT * from users; Code:
+------------------------------+---------------+------+------+-------------------------+-------------------+---------+-----------------+----------------+---------------+-------+------------+----------------+ | id | name | uid | gid | home | maildir | enabled | change_password | clear | crypt | quota | procmailrc | spamassassinrc | +------------------------------+---------------+------+------+-------------------------+-------------------+---------+-----------------+----------------+---------------+-------+------------+----------------+ | root@localhost | root | 5000 | 5000 | /var/spool/mail/virtual | root/ | 1 | 1 | passwd1 | sdtrusfX0Jj66 | | | | | satimis@satimis.com | Satimis | 5000 | 5000 | /var/spool/mail/virtual | Satimis/ | 1 | 1 | passwd2 | sdtrusfX0Jj66 | | | | | lms@satimis.com | lmsoomn | 5000 | 5000 | /var/spool/mail/virtual | LMS/ | 1 | 1 |passwd3 | sdtrusfX0Jj66 | | | | | albert@satimis.com | Albert Conong | 5000 | 5000 | /var/spool/mail/virtual | Albert/ | 1 | 1 | passwd4 | sdtrusfX0Jj66 | | | | | lms@satimis.dnsalias.com | lmsoomn | 5000 | 5000 | /var/spool/mail/virtual | dnsalias/LMS/ | 1 | 1 | passwd5 | sdtrusfX0Jj66 | | | | | satimis@satimis.dnsalias.com | Satimis | 5000 | 5000 | /var/spool/mail/virtual | dnsalias/Satimis/ | 1 | 1 | passwd6 | sdtrusfX0Jj66 | | | | | satimis@satimis.changeip.net | Satimis | 5000 | 5000 | /var/spool/mail/virtual | changeip/Satimis/ | 1 | 1 | passwd7 | sdtrusfX0Jj66 | | | | | lms@satimis.changeip.net | lmsoomn | 5000 | 5000 | /var/spool/mail/virtual | changeip/LMS/ | 1 | 1 | passwd8 | sdtrusfX0Jj66 | | | | ....... IF; 1) domain "satimis.dnsalias.com" is on MailServerB local IP=192.168.111.301 directory of user "satimis@satimis.dnsalias.com" = /home/Satimis directory fo user "lms@satimis.dnsalias.com" = /home/LMS etc. 2) domain "satimis.changeip.net" is on MailServerC local IP=192,168.111.302 directory of user "satimis@satimis.changeip.net" = /home/Satimis directory of user "lms@satimis.changeip.net" = /home LMS etc. 3) etc. Then how to edit those 2 MySQL files? Any further file needs to create? TIA I think I'll make MailServerA, the current running mail server, for routing ONLY. B.R. satimis |
|
||||
Quote:
If you only use it only locally* then I don't think any port forwarding is necessary. * locally - in host system or in any of the guest systems. Quote:
Quote:
Check mysql_table man page. New interface would be with the example above like this: Code:
hosts = 127.0.0.1 user = mail password = apassword dbname = maildb query = SELECT transport FROM backups WHERE domain='%s' AND enabled=1 Quote:
__________________
Fhtagn nagh Yog-Sothoth Last edited by deemon; 24th November 2008 at 04:29 PM. |
|
|||
Quote:
Quote:
Quote:
B.R. satimis |
|
||||
Quote:
I can't help you with linux packages though, I don't have much experience on that field. Quote:
Quote:
Code:
CREATE TABLE domains ( domain VARCHAR(255) NOT NULL AUTO_INCREMENT, transport VARCHAR(255) NOT NULL, PRIMARY KEY (domain) ); query for relay_domains map would be: SELECT 't' FROM domains WHERE domain='%s'; and for transport_maps: SELECT transport FROM domains WHERE domain='%s'; .. where transport is smtp:HOSTNAME. For example: domain: satimis.dnsalias.com, transport: smtp:MailServerB domain: satimis.changeip.net, transport: smtp:MailServerC
__________________
Fhtagn nagh Yog-Sothoth |
|
|||
Quote:
Linux is the same not necessary installing BIND9. /etc/resolv.conf Code:
nameservers ISP dns1 nameservers ISP dns2 What I'm trying to do installing BIND9 is ONLY for learning building my own DNS server. Quote:
Quote:
On the running mail server /etc/postfix/main.cf the entries re virtual domains are as follows; Code:
alias_maps = hash:/etc/postfix/aliases alias_database = hash:/etc/postfix/aliases virtual_alias_maps = mysql:/etc/postfix/mysql_alias.cf virtual_gid_maps = mysql:/etc/postfix/mysql_gid.cf virtual_mailbox_base = /var/spool/mail/virtual virtual_mailbox_domains = mysql:/etc/postfix/mysql_domains.cf virtual_mailbox_maps = mysql:/etc/postfix/mysql_mailbox.cf virtual_uid_maps = mysql:/etc/postfix/mysql_uid.cf then I have to add another line Code:
transport_maps=mysql:/etc/postfix/mysql_transport_maps.cf I have 3 tables on maildb, the database mysql> show tables; Code:
+------------------+ | Tables_in_maildb | +------------------+ | aliases | | domains | | users | +------------------+ I ran following commands creating domains; Code:
mysql> CREATE TABLE `domains` ( -> `pkid` smallint(6) NOT NULL auto_increment, -> `domain` varchar(120) NOT NULL default '', -> `transport` varchar(120) NOT NULL default 'virtual:', -> `enabled` tinyint(1) NOT NULL default '1', -> PRIMARY KEY (`pkid`) -> ) ; mysql> SELECT * from domains; Code:
+------+-----------------------+-----------+---------+ | pkid | domain | transport | enabled | +------+-----------------------+-----------+---------+ | 1 | localhost | virtual: | 1 | | 2 | localhost.localdomain | virtual: | 1 | | 3 | satimis.com | virtual: | 1 | | 4 | satimis.dnsalias.com | virtual: | 1 | | 5 | satimis.changeip.net | virtual: | 1 | +------+-----------------------+-----------+---------+ Do I need to make any change here? According to your advice I'll add another table "transport" I'll run following command to create it; Code:
CREATE TABLE `transport` ( `pkid` smallint(6) NOT NULL auto_increment, `domain` varchar(128) NOT NULL default '', `hostname` varchar(128) NOT NULL default '', `transport` varchar(128) NOT NULL default ':[]', `enabled` smallint(6) NOT NULL default '1', PRIMARY KEY (`pkid`), UNIQUE KEY `domain` (`domain`) ); Code:
INSERT INTO transport (domain,hostname) VALUES ('satimis.dnsalias.com','MailServerB'); INSERT INTO transport (domain,hostname) VALUES ('satimis.changeip.net','MailServerC'); If I'm wrong please correct me. Thanks Can I replay the hostname "MailServerB" with its local IP? Create this file /etc/postfix/mysql_relay_domains Code:
user=mail password=apassword dbname=maildb table='t' select_field=domains where_field=domains hosts=127.0.0.1 additional_conditions = and enabled = 1 and then create this file /etc/postfix/mysql_transport_maps.cf Code:
user=mail password=apassword dbname=maildb table=transport select_field=hostname where_field=domain hosts=127.0.0.1 additional_conditions = and enabled = 1 Remark: I have following 5 files created already. Do I need to make any change on them? /etc/postfix/mysql_mailbox.cf Code:
user=mail password=apassword dbname=maildb table=users select_field=maildir where_field=id hosts=127.0.0.1 additional_conditions = and enabled = 1 /etc/postfix/mysql_uid.cf Code:
user=mail password=apassword dbname=maildb table=users select_field=uid where_field=id hosts=127.0.0.1 /etc/postfix/mysql_gid.cf Code:
user=mail password=apassword dbname=maildb table=users select_field=gid where_field=id hosts=127.0.0.1 /etc/postfix/mysql_alias.cf Code:
user=mail password=apassword dbname=maildb table=aliases select_field=destination where_field=mail hosts=127.0.0.1 additional_conditions = and enabled = 1 /etc/postfix/mysql_domains.cf Code:
user=mail password=apassword dbname=maildb table=domains select_field=domain where_field=domain hosts=127.0.0.1 additional_conditions = and enabled = 1 B.R. satimis Last edited by satimis; 25th November 2008 at 07:31 AM. Reason: correction |
|
||||
Quote:
Quote:
__________________
Fhtagn nagh Yog-Sothoth |
|
|||
Quote:
Your advice works here. Steps performed as follows; All 3 mail servers are running on the same Xen box as guests. One external IP with all ports forwarded to 192.168.0.207 Server-1 Local IP - 192.168.0.207 for routing Server-2 Local IP - 192.168.0.208 domain - satimis.changip.net Server-3 Local IP -192.168.0.209 domain - satimis.dnsalias.com On Server-1 # grep transport_maps /etc/postfix/main.cf Code:
# transport_maps = mysql:/etc/postfix/mysql_transport.cf uncomment above line and change it as; Code:
transport_maps = mysql:/etc/postfix/mysql_transport_maps.cf # mysql -p maildb mysql> SHOW tables; Code:
+------------------+ | Tables_in_maildb | +------------------+ | aliases | | domains | | users | +------------------+ 3 rows in set (0.00 sec) Code:
mysql> CREATE TABLE `transport` -> `pkid` smallint(6) NOT NULL auto_increment, -> `domain` varchar(128) NOT NULL default '', -> `hostname` varchar(128) NOT NULL default '', -> `transport` varchar(128) NOT NULL default ':[]', -> `enabled` smallint(6) NOT NULL default '1', -> PRIMARY KEY (`pkid`), -> UNIQUE KEY `domain` (`domain`) -> ); Query OK, 0 rows affected (0.01 sec) mysql> SHOW tables; Code:
+------------------+ | Tables_in_maildb | +------------------+ | aliases | | domains | | transport | | users | +------------------+ 4 rows in set (0.00 sec) mysql> DESCRIBE transport; Code:
+-----------+--------------+------+-----+---------+----------------+ | Field | Type | Null | Key | Default | Extra | +-----------+--------------+------+-----+---------+----------------+ | pkid | smallint(6) | NO | PRI | NULL | auto_increment | | domain | varchar(128) | NO | UNI | | | | hostname | varchar(128) | NO | | | | | transport | varchar(128) | NO | | :[] | | | enabled | smallint(6) | NO | | 1 | | +-----------+--------------+------+-----+---------+----------------+ 5 rows in set (0.01 sec) Code:
mysql> INSERT INTO transport (domain,hostname) VALUES -> ('satimis.dnsalias.com','smtp:192.168.0.209'); Query OK, 1 row affected (0.00 sec) Code:
mysql> INSERT INTO transport (domain,hostname) VALUES -> ('satimis.changeip.net','smtp:192.168.0.208'); Query OK, 1 row affected (0.00 sec) mysql> SELECT * from transport; Code:
+------+----------------------+--------------------+-----------+---------+ | pkid | domain | hostname | transport | enabled | +------+----------------------+--------------------+-----------+---------+ | 1 | satimis.dnsalias.com | smtp:192.168.0.209 | :[] | 1 | | 2 | satimis.changeip.net | smtp:192.168.0.208 | :[] | 1 | +------+----------------------+--------------------+-----------+---------+ 2 rows in set (0.00 sec) Bye # nano /etc/postfix/mysql_relay_domains.cf Code:
user=mail password=apassword dbname=maildb table='t' select_field=domains where_field=domains hosts=127.0.0.1 additional_conditions = and enabled = 1 Remark: What is 't' here for ? # /etc/init.d/mysql reload Code:
Reloading MySQL database server: mysqld. # tail /var/log/mysql.err both without complaint # postfix reload Code:
postfix/postfix-script: refreshing the Postfix mail system No complaint # tail /var/log/mail.log Code:
Nov 27 13:09:36 xen07 spamd[2704]: spamd: server successfully spawned child process, pid 2735 Nov 27 13:09:36 xen07 spamd[2704]: spamd: server successfully spawned child process, pid 2736 Nov 27 13:09:36 xen07 spamd[2704]: prefork: child states: IS Nov 27 13:09:36 xen07 spamd[2704]: prefork: child states: II Nov 27 13:09:37 xen07 authdaemond: modules="authmysql", daemons=5 Nov 27 13:09:37 xen07 authdaemond: Installing libauthmysql Nov 27 13:09:37 xen07 authdaemond: Installation complete: authmysql Nov 27 13:09:38 xen07 postfix/master[2923]: daemon started -- version 2.3.8, configuration /etc/postfix Nov 27 13:39:48 xen07 postfix/postfix-script: refreshing the Postfix mail system Nov 27 13:39:48 xen07 postfix/master[2923]: reload configuration /etc/postfix Mails sent to satimis@satimis.changeip.net were delivered to Server-2. Mails sent to satimis@satimis.dnsalias.net were deliverd to Server-3 Lot of thanks for your advice. There is one drawback here. First I started Server-1 followed by Server-2 and finally Server-3. Keystokes on Server-3 were slow to response. I have to sit back and wait for keystroke to respond. If only running either Server-2 or Server-3 there was no such problem. I have 4G RAM on board. Have you had any idea where to check the cause? TIA B.R. satimis Last edited by satimis; 27th November 2008 at 02:44 PM. |
Thread Tools | |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Best way to manage multiple freebsd servers? | WaBBiT | FreeBSD General | 1 | 4th April 2009 10:37 PM |
Problems with Postfix virtual domains | juris98 | General software and network | 2 | 11th February 2009 12:14 AM |
About Dedicated Servers | qmemo | Off-Topic | 7 | 4th September 2008 02:15 PM |
SquidGuard fails when building the Berkeley DB files for domains | costy | OpenBSD Packages and Ports | 1 | 31st July 2008 09:22 PM |
Serving 2 domains through firewall using a Jail? | krreagan | General software and network | 1 | 4th May 2008 09:38 PM |