DaemonForums  

Go Back   DaemonForums > Miscellaneous > General software and network

General software and network General OS-independent software and network questions, X11, MTA, routing, etc.

Reply
 
Thread Tools Display Modes
  #1   (View Single Post)  
Old 22nd November 2008
satimis satimis is offline
Port Guard
 
Join Date: May 2008
Posts: 27
Thanked 0 Times in 0 Posts
Default 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
Reply With Quote
  #2   (View Single Post)  
Old 23rd November 2008
deemon's Avatar
deemon deemon is offline
Fdisk Soldier
 
Join Date: May 2008
Location: Estonia
Posts: 50
Thanked 6 Times in 5 Posts
Default

It's difficult to understand what are you trying to achieve or how is your system currently configured.

One thing is sure though - you don't need DNS server on each mail servers.
__________________
Fhtagn nagh Yog-Sothoth
Reply With Quote
  #3   (View Single Post)  
Old 24th November 2008
satimis satimis is offline
Port Guard
 
Join Date: May 2008
Posts: 27
Thanked 0 Times in 0 Posts
Default

Quote:
Originally Posted by deemon View Post
It's difficult to understand what are you trying to achieve or how is your system currently configured.
Hi deemon,


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:
One thing is sure though - you don't need DNS server on each mail servers.
/etc/resolv.conf can do the job. But my exploration is to build my own DNS server on a guest of Xen and a slave on another guest. I have no problem setting up BIND9 on mail server and disabling /etc/resolv.conf afterwards when the former is in operation. But I have no idea what port is needed by BIND9? If the same port is also needed by the mail servers on other guests is there a glue to sort out this problem?


Thanks


B.R.
satimis
Reply With Quote
  #4   (View Single Post)  
Old 24th November 2008
deemon's Avatar
deemon deemon is offline
Fdisk Soldier
 
Join Date: May 2008
Location: Estonia
Posts: 50
Thanked 6 Times in 5 Posts
Default

bind9 is in FreeBSD base system, you don't need to install anything from ports to set it up.

So basically you have one mail gateway that has to route mail for different domains to different guest systems with IP addresses from private address space.
For that you have to set up virtual transports on the gateway. Check out transport_maps and relay_domains tables.
You'll just need to add smtp:YOURGUESTIP (or YOURGUESTHOSTNAME) as transports for your domains and mail will be routed to that IP/HOSTNAME.
__________________
Fhtagn nagh Yog-Sothoth
Reply With Quote
  #5   (View Single Post)  
Old 24th November 2008
satimis satimis is offline
Port Guard
 
Join Date: May 2008
Posts: 27
Thanked 0 Times in 0 Posts
Default

Quote:
Originally Posted by deemon View Post
bind9 is in FreeBSD base system, you don't need to install anything from ports to set it up.
Hi deemon,


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
Nothing else. Can it work?


Quote:
So basically you have one mail gateway that has to route mail for different domains to different guest systems with IP addresses from private address space.
For that you have to set up virtual transports on the gateway. Check out transport_maps and relay_domains tables.
You'll just need to add smtp:YOURGUESTIP (or YOURGUESTHOSTNAME) as transports for your domains and mail will be routed to that IP/HOSTNAME.
On the same mail server I don't have any problem.

/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
Reply With Quote
  #6   (View Single Post)  
Old 24th November 2008
deemon's Avatar
deemon deemon is offline
Fdisk Soldier
 
Join Date: May 2008
Location: Estonia
Posts: 50
Thanked 6 Times in 5 Posts
Default

Quote:
Originally Posted by satimis View Post
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 you installed FreeBSD with Standard installation procedure then everything required to run nameserver is already in system. No additional software needed.
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:
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
Nothing else. Can it work?
That should work.


Quote:
On the same mail server I don't have any problem.

/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
It seems you use old postfix mysql interface. Not that it's wrong or anything but I find the new interface (since postfix 2.2) for mysql is better (clearer & more flexible, can use joins etc..)
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:
I think I'll make MailServerA, the current running mail server, for routing ONLY.
Yes - that's exacly what you should do and that's what I had in mind when I was talking about mail gateway.
__________________
Fhtagn nagh Yog-Sothoth

Last edited by deemon; 24th November 2008 at 04:29 PM.
Reply With Quote
  #7   (View Single Post)  
Old 24th November 2008
satimis satimis is offline
Port Guard
 
Join Date: May 2008
Posts: 27
Thanked 0 Times in 0 Posts
Default

Quote:
Originally Posted by deemon View Post
If you installed FreeBSD with Standard installation procedure then everything required to run nameserver is already in system. No additional software needed.
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.
Unfortunately I can't install FreeBSD on the guest of the Xen box. I'll install Debian Etch as OS. Besides I'll remove /etc/resolv.conf. Can BIND9 do the job replacing resolv.conf ?


Quote:
It seems you use old postfix mysql interface. Not that it's wrong or anything but I find the new interface (since postfix 2.2) for mysql is better (clearer & more flexible, can use joins etc..)
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
Noted with thanks.


Quote:
Yes - that's exacly what you should do and that's what I had in mind when I was talking about mail gateway.
Still I haven't got a clear picture on the settings of MySQL users table to make the incoming mails to be routed to their mail servers according to domain. Example would be appreciated. TIA


B.R.
satimis
Reply With Quote
  #8   (View Single Post)  
Old 24th November 2008
deemon's Avatar
deemon deemon is offline
Fdisk Soldier
 
Join Date: May 2008
Location: Estonia
Posts: 50
Thanked 6 Times in 5 Posts
Default

Quote:
Originally Posted by satimis View Post
Unfortunately I can't install FreeBSD on the guest of the Xen box. I'll install Debian Etch as OS.
Heh - sorry, I didn't pay attention - I assumed you had FreeBSD installed.
I can't help you with linux packages though, I don't have much experience on that field.

Quote:
Besides I'll remove /etc/resolv.conf. Can BIND9 do the job replacing resolv.conf ?
resolv.conf is still required - that's how you show your system which nameservers to use. Just having having bind installed and configured is not enought.

Quote:
Still I haven't got a clear picture on the settings of MySQL users table to make the incoming mails to be routed to their mail servers according to domain. Example would be appreciated. TIA
I guess think you need only one table:
Code:
CREATE TABLE domains (
    domain VARCHAR(255) NOT NULL AUTO_INCREMENT,
    transport VARCHAR(255) NOT NULL,
    PRIMARY KEY (domain)
);
Then you'll add mysql maps to relay_domains and transport_maps.

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
Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

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


All times are GMT. The time now is 05:16 PM.


Powered by vBulletin® Version 3.8.4
Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
Content copyright © 2007-2010, the authors
Daemon image copyright ©1988, Marshall Kirk McKusick