*BSD News Article 94305


Return to BSD News archive

Newsgroups: comp.unix.bsd.freebsd.misc
Path: euryale.cc.adfa.oz.au!newshost.carno.net.au!harbinger.cc.monash.edu.au!munnari.OZ.AU!news.ecn.uoknor.edu!news.ysu.edu!news.radio.cz!newsbastard.radio.cz!news.radio.cz!CESspool!cpk-news-hub1.bbnplanet.com!news.bbnplanet.com!worldnet.att.net!howland.erols.net!blackbush.xlink.net!pegasus.PFM-Mainz.de!forthdv.pfm-mainz.de!stephan
From: stephan@forthdv.pfm-mainz.de (Stephan Forth)
Subject: Re: sendmail for virtual hosts
X-Newsreader: TIN [UNIX 1.3 BETA-950824-color PL0]
Lines: 186
Organization: Forth EDV Beratung+Schulung
Message-ID: <E93vsA.951@forthdv.pfm-mainz.de>
References: <5jhigk$rsf@vixen.cso.uiuc.edu> <E9179p.zC@forthdv.pfm-mainz.de> <5jimsf$rio@vixen.cso.uiuc.edu>
Date: Wed, 23 Apr 1997 19:36:10 GMT
Xref: euryale.cc.adfa.oz.au comp.unix.bsd.freebsd.misc:39615

igor vladimirovich roshchin (igor@students.uiuc.edu) wrote:
: Stephan Forth (stephan@forthdv.pfm-mainz.de) wrote:
: : igor vladimirovich roshchin (igor@students.uiuc.edu) wrote:
: : 
: : did you do a makemap?
: : 
: : You should put the virtual User Info in a file like
: : /etc/virtusertable.txt then do a
: : makemap hash virtusertable < virtusertable.txt
: : 
: : Restart sendmail and it should be up 'n running.
: : 
: 
: Yes, I did...
: I wonder if the format of the virtusertable file is correct (as I mentioned above),
: and also if I had to do something else with the /etc/sendmail.cf

You could check, if your sendmail.cf contains the definitions
listed in the sendmail.faq.

I guess its a often needed feature, so I append the part of the
sendmail.faq here.

Best source of information is (IMHO) the sendmail.faq. You can get
the complete faq from:
ftp://rtfm.mit.edu/pub/usenet/news.answers/sendmail-faq/part*

Regards, Stephan

---------------part of sendmail.faq------------------------


Subject:  Q3.7 -- How do I manage several (virtual) domains?

    If you want to provide mailservice to several domains and be able
to add identical names across different domains, as in this example:

	   user@a.dom.ain	mb1@dom.ain
	   user@b.dom.ain	mb2@dom.ain
	   user@c.dom.ain	mb@outer.space

    you may accomplish this by using an external database in
conjunction with minor Ruleset rewriting in sendmail.cf.  Many ISPs
(Internet Service Providers) have asked me and here's a general
solution (you may combine it with userdb's if you need to):

    1.  Make a textfile (I usually make one for each domain and
	concatenate them before database-compilation) with the
	following structure:

	    user@a.dom.ain	mb1@dom.ain
	    user@b.dom.ain	mb2@dom.ain
	    user@c.dom.ain	mb@outer.space

	The LHS (Left Hand Side) is the mail-adress of a particular
	user and the RHS is the corresponding mailbox.  An example
	that might apply to the real world:

	    webmaster@josnet.se		wm.list@eowyn.josnet.se
	    webmaster@client1.se	joe@client1.se
	    webmaster@client2.se	anne@another.provider.se
	    webmaster@client3.se	joe@client3.se
	    joe@client1.se		c1_joe@mail.josnet.se
	    joe@client3.se		joeuser

	Note that you have to spell out the complete email-address in
	the LHS entry.  The RHS entry may be either a local address
	(for example 'johan' if that account exists) or a complete
	email-adress on another system (or a domain that the server
	recognizes as local for that matter).

    2.  Compile the textfile into a database:

	    makemap hash mbt.db <mbt

	You may you use other lookup-methods than hash (btree for
	example).  The resulting database is mbt.db in this example
	and the input is the textfile mbt.

    3.  Add a few lines in sendmail.cf:

	A.  In the beginning (typically in the "local info" section or
	    together with the user database option in the "options"
	    section):

	    # Declare mbt as a hash-lookup database:
	    Kmbt hash /etc/mail/mbt.db

       B.  In the Ruleset 98 (local part of ruleset 0) section, add:

	    # Use mailboxtable-database:
	    R$+ < @ $+ . >	$: $1 < @ $2 > .
	    R$+ < @ $+ > $*	$: $(mbt $1@$2 $: $1 < @ $2 > $3 $)
	    R$+ < @ $+ > $*	$: $(mbt $2 $: $1 < @ $2 > $3 $)
	    RERROR $*		$#error $: $1
	    R$+ < @ $+ > .	$: $1 < @ $2 . >

	    If you have any other rewrite rules in ruleset 98, these
	    should be able to either go after or before the existing
	    rules, but you may have to do some experimenting to
	    find out which placement works best.

    4.  The next-to-last line of these rules let you have an alias
	file like:

	    joe@somedom.com	joe
	    jim@somedom.com	jim@othersite
	    somedom.com		ERROR "No such user"

	And still have mail addressed to unknown users at that domain
	bounce properly.  You can also do a form of redirects, such
	as:

	    fred@somedom.com	ERROR "This user has moved to fred@otherdom.com"

    5.  Test with sendmail -bv and/or sendmail -bt

    6.	Restart sendmail.  You must do this in order to have the
	daemon reread the sendmail.cf.


    Note: Alternate sets of instructions and/or kits
can be found at <http://www.westnet.com/providers>,
<http://hub.org/softdocs/Sendmail-VD>,
<ftp://samson.oslo.uninett.no/pub/unix/sendmail/>, and
<http://jos.net/projects/mbt/>.  None of these have been tested
by the maintainer of this FAQ, but are believed to work correctly.
Which you use is a matter of your personal aesthetics.


    If you're using version 8.8 sendmail, you can make use of the
new "virtual user table" feature (for one thing, it won't require
that you add new rewrite rules to your sendmail configuration, as
the previous example does).

	1.  Put "FEATURE(virtusertable)" in your sendmail.mc
	    file.

	2.  By default, sendmail will build tables out of
	    /etc/virtusertable.  If you want to change this, put
	    something like:

		define(`VIRTUSER_TABLE', `-o hash /usr/local/lib/virtusertable')dnl

	    in your sendmail.mc file.

	3.  Construct the virtusertable file like so:

		info@foo.com	foo-info
		info@bar.com	bar-info
		@baz.org	jane@elsewhere.net
		@somedom.com	error : 5.5.0 User unknown

	    (Contrast with steps 1 and 4 in the previous example
	    using regular mailertables).

	4.  Compile the textfile into a database:

		makemap hash /etc/virtusertable.db </etc/virtusertable

	    You may you use other lookup-methods than hash (btree
	    for example).  Make sure that this database type matches
	    what is defined for the table in step 2.

	5.  Put all the domains listed on the LHS of these aliases
	    in your sendmail.cw file, or on the Cw line in your
	    sendmail.cf.

	6.  Recompile your sendmail.cf from your sendmail.mc and
	    test it.

	7.  Once you are satisfied, move it into place and restart
	    sendmail.


    Note that the virtusertable is only referenced for inbound
mail (more accurately, only for controlling delivery).  If you
want to rewrite mail addresses from your virtual domain users as
they pass through your system, you'll also need to make comparable
modifications to the genericstable (used for rewriting).


-- 
FORTH EDV Beratung + Schulung             stephan@forthdv.pfm-mainz.de 
Martin-Luther-Str. 55                     voice: +49 6131 581072  
55131 Mainz, Germany                      fax:   +49 6131 581073