Mail::SpamAssassin::Plugin::ASN(3) SpamAssassin plugin to look up the


loadplugin Mail::SpamAssassin::Plugin::ASN
asn_lookup _ASN_ _ASNCIDR_
add_header all ASN _ASN_ _ASNCIDR_


This plugin uses DNS lookups to the services of an external DNS zone such as at "" to do the actual work. Please make sure that your use of the plugin does not overload their infrastructure - this generally means that you should not use this plugin in a high-volume environment or that you should use a local mirror of the zone (see ""). Other similar zones may also be used.


This plugin allows you to create template tags containing the connecting IP's AS number and route info for that AS number.

The default config will add a header field that looks like this:

 X-Spam-ASN: AS24940

where ``24940'' is the ASN and ``'' is the route announced by that ASN where the connecting IP address came from. If the AS announces multiple networks (more/less specific), they will all be added to the "_ASNCIDR_" tag, separated by spaces, eg:

 X-Spam-ASN: AS1680

Note that the literal ``AS'' before the ASN in the _ASN_ tag is configurable through the asn_prefix directive and may be set to an empty string.


The standard ruleset contains a configuration that will add a header field containing ASN data to scanned messages. The bayes tokenizer will use the added header field for bayes calculations, and thus affect which BAYES_* rule will trigger for a particular message.

Note that in most cases you should not score on the ASN data directly. Bayes learning will probably trigger on the _ASNCIDR_ tag, but probably not very well on the _ASN_ tag alone.


No in-depth analysis of the usefulness of bayes tokenization of ASN data has been performed.


asn_lookup [ _ASNTAG_ _ASNCIDRTAG_ ]
Use this to lookup the ASN info in the specified zone for the first external IP address and add the AS number to the first specified tag and routing info to the second specified tag.

If no tags are specified the AS number will be added to the _ASN_ tag and the routing info will be added to the _ASNCIDR_ tag. You must specify either none or both of the tag names. Tag names must start and end with an underscore.

If two or more asn_lookups use the same set of template tags, the results of their lookups will be appended to each other in the template tag values in no particular order. Duplicate results will be omitted when combining results. In a similar fashion, you can also use the same template tag for both the AS number tag and the routing info tag.


  asn_lookup _ASN_ _ASNCIDR_
  asn_lookup _MYASN_ _MYASNCIDR_
  asn_lookup _ASNDATA_ _ASNDATA_

Removes any previously declared asn_lookup entries from a list of queries.

asn_prefix 'prefix_string' (default: 'AS')
The string specified in the argument is prepended to each ASN when storing it as a tag. This prefix is rather redundant, but its default value 'AS' is kept for backward compatibility with versions of SpamAssassin earlier than 3.4.0. A sensible setting is an empty string. The argument may be (but need not be) enclosed in single or double quotes for clarity.