PMDF System Manager's Guide


Previous Contents Index

2.2.4 Patterns and Tags

Most rewrite rule patterns consist either of a specific host name that will match only and exactly that host, e.g.,


host.domain.com 
or consist of a subdomain pattern that will match any host/domain in the entire subdomain, e.g.,


.domain.com 
A rewrite rule pattern such as the above would match any host.domain.com or host.subnet.domain.com sort of host/domain name. Note, however, that it will not match the exact host name domain.com; to match the exact host name domain.com, a separate domain.com pattern would be needed.

Since as discussed in Section 2.2.3.2 PMDF attempts to rewrite host/domain names starting from the specific host name and then incrementally generalizing the name to make it less specific, this means that a more specific rewrite rule pattern will be preferentially used over more general rewrite rule patterns. For instance, if the rewrite rule patterns


hosta.subnet.domain.com 
.subnet.domain.com 
.domain.com 
are present in the configuration file,a then an address of jdoe@hosta.subnet.domain.com will match the specific hosta.subnet.domain.com rewrite rule pattern, while an address of jdoe@hostb.subnet.domain.com will match the more general .subnet.domain.com rewrite rule pattern, and an address of jdoe@hostc.domain.com will match the .domain.com rewrite rule pattern.

In particular, the use of rewrite rules incorporating subdomain rewrite rule patterns is common for sites on the Internet. Such a site will typically have a number of rewrite rules for their own internal hosts and subnets, and then will include rewrite rules for the top-level Internet subdomains into their configuration from the file internet.rules stored in the PMDF table directory. The presence of such


!    Ascension Island 
.AC                                     $U%$H$D@TCP-DAEMON 
. [text
.    removed for
.             brevity]
!    Zimbabwe 
.ZW                                     $U%$H$D@TCP-DAEMON 
rewrite rules, with rewrite rule patterns that match the top level Internet domains and rewrite rule templates that rewrite addresses matching such patterns to an outgoing TCP/IP channel, ensure that messages to Internet destinations (other than to the internal host destinations handled via more specific rewrite rules) will be properly rewritten and routed out an outgoing TCP/IP channel.

IP domain literals follow a similar hierarchical matching pattern, though with right-to-left (rather than left-to-right) matching. For instance, the pattern


[1.2.3.4] 
matches only and exactly the IP literal [1.2.3.4], while


[1.2.3.] 
matches anything in the 1.2.3.0 subnet.

In addition to the more common sorts of host or subdomain rewrite rule patterns discussed above, rewrite rules may also make use of several special patterns, summarized in Table 2-1, and discussed in the following subsections.

Table 2-1 Summary of Special Patterns for Rewrite Rules
Pattern Name Section Usage
$% Percent hack rule 2.2.4.1 Matches any host/domain specification of the form A%B.
$! Bang-style rule 2.2.4.2 Matches any host/domain specification of the form B!A.
[] IP literal match-all rule 2.2.3.7 Match any IP domain literal.
. Match-all rule 2.2.4.3 Matches any host/domain specification.

In addition to these special patterns, PMDF also has the concept of "tags" which may appear in rewrite rule patterns. These tags are used in situations where an address may be rewritten several times and, based upon previous rewritings, distinctions must be made in subsequent rewritings by controlling which rewrite rules match the address.

2.2.4.1 A Rule to Match Percent Hacks

If PMDF tries to rewrite an address of the form A%B and fails, it tries one extra rule before falling through and treating this address form as A%B@localhost. This extra rule is the percent hack rule. The pattern is $%. The pattern never changes. This rule is only activated when a local part containing a percent sign has failed to rewrite any other way (including the match all rule described below).

The percent hack rule is useful for assigning some special, internal meaning to percent hack addresses.

2.2.4.2 A Rule to Match Bang-style (UUCP) Addresses

If PMDF tries to rewrite an address of the form B!A and fails, it tries one extra rule before falling through and treating this address form as B!A@localhost. This extra rule is the bang-style rule. The pattern is $!. The pattern never changes. This rule is only activated when a local part containing an exclamation point has failed to rewrite any other way (including the default rule described below).

The bang-style rule can be used to force UUCP style addresses to be routed to a system with comprehensive knowledge of UUCP systems and routing.

2.2.4.3 A Rule to Match Any Address

The special pattern "." (a single period) will match any host/domain specification if no other rule matches and the host/domain specification cannot be found anywhere in the channel table. In other words, the "." rule is used as a last resort when address rewriting would fail otherwise.

Using this very general rule can simplify some PMDF installations at the expense of propagating possibly bogus addresses. This special default rule should only be used when PMDF does not have complete routing information available and has to defer judgment of address validity to another system or systems. Care should be taken to insure that such unchecked addresses are only sent to systems that are capable of handling them.

Note

When the match-all rule matches and its template is expanded, $H expands to the full host name and $D expands to a single dot ".". Thus, $D is of limited use in a match-all rule template!

2.2.4.4 Tagged Rewrite Rule Sets

As the rewrite process proceeds it may be appropriate to bring different sets of rules into play. This is accomplished by the use of the rewrite rule tag. The current tag is prepended to each pattern before looking it up in the configuration file or domain database. The tag can be changed by any rewrite rule that matches by using the $T substitution string in the rewrite rule template (described below).

Tags are somewhat sticky; once set they will continue to apply to all hosts that are extracted from a single address. This means that care must be taken to provide alternate rules that begin with the proper tag values once any tags are used. In practice this is rarely a problem since tags are usually used in only very specialized applications. Once the rewriting of the address is finished the tag is reset to the default tag --- an empty string.

By convention all tag values end in a vertical bar |. This character is not used in normal addresses and thus is free to delineate tags from the rest of the pattern.

See Section 2.2.6.14 for an example of using tagged rewrite rules.

Note

a Note that the order of these rewrite rule patterns does not strictly matter, though a more specific to less specific ordering is commonly used for efficiency and esthetic reasons.


Previous Next Contents Index