Sample configs?

Tyler Aviss tjaviss-Re5JQEeQqe8AvxtiuMwx3w at public.gmane.org
Tue Nov 6 19:19:32 UTC 2007


Sometime ago I wrote a bunch of reference notes on this in my wiki
(because sometimes I forget exactly what I did or why).I think I had
some notes on apache2 virtual domains too but I'll have to search
around for those. Here's a copy of the postfix notes (sorry for the
wiki formatting), it discusses various virtual mailbox/domain formats
in postfix:

--------------------------------------



 # First, specify the file that is going to tell you what virtual
domains we support
 virtual_mailbox_domains = /etc/postfix/virtual_domains
 #########################################
 # And the base directory for the virtual mailboxes
 virtual_mailbox_base = /var/spool/virtmail
 ########################################
 #
 # Specify a user and group for the virtual domains. In this case
we're using 404
 virtual_uid_maps = static:404
 virtual_gid_maps = static:404
 #########################################
 #
 # You'll need a virtual mailbox map
 virtual_mailbox_maps = hash:/etc/postfix/maps/virtual_mailbox
 #########################################
 #
 # And finally a virtual alias map
 virtual_alias_maps = hash:/etc/postfix/maps/virtual_mailbox_alias
 #########################################

Alternately, if you wanted to have multiple users/groups for varying
virtual domains or even vdomain mailboxes, you might want there

 # Virtual UID/GID mapping
 virtual_uid_maps = hash:/etc/postfix/maps/virtual_uids
 virtual_gid_maps = hash:/etc/postfix/maps/virtual_gids

That's it for main.cf... save it

Next, create the user and group associate with the virtual domain
mailboxes (if you're going to use multiple UID's/GID's, best to create
those too)

 groupadd -g 404 postfix-vmail
 useradd -u 404 -g 404 postfix-vmail

Create the virtual mailbox directory

 mkdir /var/spool/virtmail

And now, you will want to create directories for each virtual domain

 mkdir /var/spool/virtmail/mail2.foo.com

And set ownership

 chmod 770 /var/spool/virtmail
 chown -R postfix-vmail:postfix-vmail /var/spool/virtmail
 chmod g+s /var/spool/virtmail

Edit the virtual domains file, just one per line. In this case, we're
going with a few subdomains off our foo.com domain. Note this is NOT a
hash DB, so no need to use postmap on it

 mail2.foo.com

If you're using multiple users/groups, best create the following too:

    * /etc/postfix/maps/virtual_uids

 user1-xXXzbIVZUpigSpxsJD1C4w at public.gmane.org 405
 @mail2.foo.com      404

    * /etc/postfix/maps/virtual_gids

 user1-xXXzbIVZUpigSpxsJD1C4w at public.gmane.org 405
 @mail2.foo.com      404

And don't forget to run postmap on them

 postmap /etc/postfix/maps/virtual_uids
 postmap /etc/postfix/maps/virtual_gids

Edit your virtual mailbox map "/etc/postfix/maps/virtual_mailbox"

 sales-xXXzbIVZUpigSpxsJD1C4w at public.gmane.org    mail2.foo.com/sales
 staff-xXXzbIVZUpigSpxsJD1C4w at public.gmane.org    mail2.foo.com/staff/
 # Last is a catch-all if you want it, for all other emails (beware
massive spam to random names)
 @mail2.foo.com         mail2.foo.com/other

And run postmap on it

 postmap /etc/postfix/maps/virtual_mailbox

Finally, edit your virtual alias map "/etc/postfix/maps/virtual_mailbox_alias"

 postmaster-xXXzbIVZUpigSpxsJD1C4w at public.gmane.org postmaster

And run postmap on it

 postmap /etc/postfix/maps/virtual_mailbox_alias

[edit]
Mail forwarding domains

These are used for a domain that has a local MX record/IP, but
forwards off mail to another server/domain. No local accounts are
necessary

Make the following edits to main.cf

 #First, specify a file which will list virtual alias domains that we support
 virtual_alias_domains = /etc/postfix/virtual_alias_domains
 #
 #And a virtual alias map
 virtual_alias_maps = hash:/etc/postfix/maps/virtual_domain_alias


That's it for main.cf... save it

Add any domains we support into "/etc/postfix/virtual_alias_domains"

 mail3.foo.com

And the only other thing to do is edit the map
"/etc/postfix/maps/virtual_domain_alias"

 # This one seconds to the local account
 postmaster-ysa9mPl4LHugSpxsJD1C4w at public.gmane.org postmaster
 # This one forwards on elsewhere
 jsmith-ysa9mPl4LHugSpxsJD1C4w at public.gmane.org        joe.smith-/sYnA5X8N+ZOyhpSdbRjpEEOCMrvLtNR at public.gmane.org

Save it, and then run postalias on it

 postalias /etc/postfix/maps/virtual_domain_alias

[edit]
Domain Forwarding (transports)

In this example, our local host will be foo.com, and we will be
transporting mail for the subdomain mail4.foo.com to a server on the
internet network (this works just as well for transporting entire
domains or to non-local networks)

First, update your "mydestination" so it looks something like this,
this allows the server to initially accept/process mail for both
domains

 mydestination = localhost localhost.localdomain foo.com mail4.foo.com


Next, specify that you will be defining transport maps in a hash DB
(if you use a bunch of transports it's ultimately a bit more
efficient)

 transport_maps = hash:/etc/postfix/maps/transport


Now, edit the file /etc/postfix/maps/transport, it should look
something like the following (gives these assumptions)

    * Note that it will be sending on the SMTP port (25), to a server
at 10.7.7.200
    * The square brackets denote that it should not look up an MX
record for the given destination from the DNS servers
    * Using the IP is important. If you don't, then you still need to
have a valid A record for the domain on the DNS servers (since it's
backnet, we don't have one, even if a valid hosts entry exists)

 mail4.foo.com                   smtp:[10.7.7.200]


Save your changes. Whenever you update a map, you have to rebuild the
associated database, so run the postmap command

 postmap /etc/postfix/maps/transport


This will create the file "/etc/postfix/maps/transport.db" so make
sure that whenever you update the transport file you re-run postmap on
it to rebuild the db


Now on the server at 10.7.7.200, make sure you have a working, running
mailserver (aka another copy of postfix). You should the following
config directives on it (given these assumptions)

    * The transporting server is sending mail from 10.7.7.1
    * You should probably have an /etc/hosts or DNS entry for
mail4.foo.com posting at 10.7.7.200

 mydestination = localhost, localhost.localdomain, mail4.foo.com
 mynetworks = 127.0.0.0/8 10.7.7.1
--
The Toronto Linux Users Group.      Meetings: http://gtalug.org/
TLUG requests: Linux topics, No HTML, wrap text below 80 columns
How to UNSUBSCRIBE: http://gtalug.org/wiki/Mailing_lists





More information about the Legacy mailing list