Sun Java System Messaging Server 6.3 Administration Guide

11.9 Rewrite Rules Example

The following example provides sample rewrite rules and how sample addresses would be rewritten by the rules.

Suppose the configuration file for the system SC.CS.SIROE.EDU contained the rewrite rules shown in the following example:


sc                     $U@sc.cs.siroe.edu
sc1                    $U@sc1.cs.siroe.edu
sc2                    $U@sc2.cs.siroe.edu
*                      $U%$&0.cs.siroe.edu
*.cs                   $U%$&0.cs.siroe.edu
*.cs.siroe             $U%$&0.cs.siroe.edu
*.cs.siroe.edu         $U%$&0.cs.siroe.edu@ds.adm.siroe.edu
sc.cs.siroe.edu        $U@$D
sc1.cs.siroe.edu       $U@$D
sc2.cs.siroe.edu       $U@$D
sd.cs.siroe.edu        $U@sd.cs.siroe.edu
.siroe.edu             $U%$H.siroe.edu@cds.adm.siroe.edu
.edu                   $U@$H$D@gate.adm.siroe.edu
[]                     $U@[$L]@gate.adm.siroe.edu

Table 11–7 shows some sample addresses and how they would be rewritten and routed according to the rewrite rules.

Table 11–7 Sample Addresses and Rewrites

Initial address 

Rewritten as 

Routed to 

user@sc 

user@sc.cs.siroe.edu 

sc.cs.siroe.edu 

user@sc1 

user@sc1.cs.siroe.edu 

sc1.cs.siroe.edu 

user@sc2 

user@sc2.cs.siroe.edu 

sc2.cs.siroe.edu 

user@sc.cs 

user@sc.cs.siroe.edu 

sc.cs.siroe.edu 

user@sc1.cs 

user@sc1.cs.siroe.edu 

sc1.cs.siroe.edu 

user@sc2.cs 

user@sc2.cs.siroe.edu 

sc2.cs.siroe.edu 

user@sc.cs.siroe 

user@sc.cs.siroe.edu 

sc.cs.siroe.edu 

user@sc1.cs.siroe 

user@sc1.cs.siroe.edu 

sc1.cs.siroe.edu 

user@sc2.cs.siroe 

user@sc2.cs.siroe.edu 

sc2.cs.siroe.edu 

user@sc.cs.siroe.edu 

user@sc.cs.siroe.edu 

sc.cs.siroe.edu 

user@sc1.cs.siroe.edu 

user@sc1.cs.siroe.edu 

sc1.cs.siroe.edu 

user@sc2.cs.siroe.edu 

user@sc2.cs.siroe.edu 

sc2.cs.siroe.edu 

user@sd.cs.siroe.edu 

user@sd.cs.siroe.edu 

sd.cs.siroe.edu 

user@aa.cs.siroe.edu 

user@aa.cs.siroe.edu 

ds.adm.siroe.edu 

user@a.eng.siroe.edu 

user@a.eng.siroe.edu 

cds.adm.siroe.edu 

user@a.cs.sesta.edu 

user@a.cs.sesta.edu 

gate.adm.siroe.edu—route inserted 

user@b.cs.sesta.edu 

user@b.cs.sesta.edu 

gate.adm.siroe.edu— route inserted 

user@[1.2.3.4] 

user@[1.2.3.4] 

gate.adm.siroe.edu—route inserted 

Basically, what these rewrite rules say is: If the host name is one of our short-form names (sc, sc1 or sc2) or if it is one of our full names (sc.cs.siroe.edu, and so on), expand it to our full name and route it to us. Append cs.cmu.edu to one part short-form names and try again. Convert one part followed by .cs to one part followed by .cs.siroe.edu and try again. Also convert .cs.siroe to .cs.siroe.edu and try again.

If the name is sd.cs.siroe.edu (some system we connect to directly, perhaps) rewrite and route it there. If the host name is anything else in the .cs.siroe.edu subdomain, route it to ds.cs.siroe.edu (the gateway for the .cs.siroe.edu subdomain). If the host name is anything else in the .siroe.edu subdomain route it to cds.adm.siroe.edu (the gateway for the .siroe.edu subdomain). If the host name is anything else in the .edu top-level domain route it to gate.adm.siroe.edu (which is presumably capable of routing the message to its proper destination). If a domain literal is used send it to gate.adm.siroe.edu as well.

Most applications of rewrite rules (like the previous example) will not change the username (or mailbox) part of the address in any way. The ability to change the username part of the address is used when the MTA is used to interface to mailers that do not conform to RFC 822—mailers where it is necessary to stuff portions of the host/domain specification into the username part of the address. This capability should be used with great care if it is used at all.