rewrite file

The rewrite file contains data used to cause SMTP to deliver to a specific location. SMTP performs a one-to-one mapping on destination addresses (the "To:" field) received and destination addresses actually used. The "To:" field text is not modified by the mapping process. If no template matches the incoming destination, the original address is used unchanged. The address resulting from rewrite process may be one of:

Each record within the rewrite file comprises a single line, containing either two or three fields separated by spaces.

  1. The template field used for match testing the incoming address. A incoming address template contains a combination of verbatim ascii text plus the special characters "?*+\". The special characters:

    • '?' matches any single character
    • '*' matches any number of consecutive characters (including zero)
    • '+' matches a sequence of one or more characters
    • '\' causes the following special character to be treated as a normal ascii character (not special)
    From left to right of the incoming address, each special character subfield is placed into a variable named "$1", "$2", "$3", ..., until either end of incoming address is reached (success), or a mismatch with the ascii characters is found (failure).
  2. The replacment field is the destination address after variable substitution. If the incoming address match succeeds, then the second field replaces address after the "$" variables are substituted. The two-character sequence, "$H", in the replacement field is replaced by the hostname of the system.

  3. The recursion field Rewrite process normally terminates after the first template match, unless there is an optional third field which contains the single letter "r". In this case, JNOS rescans the rewrite file from the beginning, attempting to match the new destination address with one of the templates.

For example:

rewrites all addresses beginning or ending with "tcpip" to the tcp area on the local system.

By way of another example, suppose that there is a line in the rewrite file which looks like:

Then, any traffic reaching the system through the mailbox or the SMTP server, which is supposed to go to a remote system, will be redirected to go to g1emm.ampr.org via SMTP.

Suppose that a user logs on, and sends a message to n0gbe@nq0i. Then the rewrite file attempts to match "n0gbe@nq0i" against the entry *@*. It matches, and assigns $1 the value n0gbe, and $2 the value nq0i. The mail file as written to the disk will no longer be to n0gbe@nq0i, but, rather, to n0gbe%nq0i@g1emm.ampr.org. [The nomenclature station1%station2@station3 means the final destination is station1@station2, and this traffic is to be routed through the gateway station3.] As soon as a template match is found, the conversion is performed and scanning is stopped, unless the third "r" field is present, in which case scanning restarts from the top of the file. Note: It is a good idea to have a line of the form:

at the beginning of your rewrite file. This will cause all amprnet traffic to be caught early in the rewrite scan, and no further scanning (and, hence, no unexpected substitutions) will take place.

The rewrite_sample.1 file is submitted by K5ARH and is commonly available as a very comprehensive example. It is the basis for document text.

RewriteFile (last edited 2008-06-12 15:17:15 by GeorgeVerDuin)