Mail::Milter::Module::ConnectMatchesHostname - milter to accept/reject connecting hosts matching regex(es)
use Mail::Milter::Module::ConnectMatchesHostname; my $milter = new Mail::Milter::Module::ConnectMatchesHostname; my $milter2 = &ConnectMatchesHostname; # convenience $milter2->set_message('Connecting hostname %H looks like a dynamic address');
This milter module rejects any connecting host whose hostname contains one of a group of built-in patterns that match the IP address of the connecting host. This is normally used to detect dynamic pool addresses.
Currently the following patterns embedded in the hostname are considered matching, where 10.11.12.13 is the IPv4 address of the connecting host. In the following cases, the string must be preceded by a non-digit character or otherwise must be at the start of the hostname.
010.011.012.013. (optionally without internal dots, or with - in place of .) 013.012.011.010. (optionally with - in place of .) 10.11.12.13. (optionally without internal dots, or with - in place of .) 18.104.22.168. (optionally with - in place of .) 0A0B0C0D (hexadecimal, ignoring case)
More specific patterns are anticipated to be added in the future. Because of this, if you use ConnectMatchesHostname, pay attention to this perldoc manual page when updating to a newer version of Mail::Milter.
One final note. ISPs can and do use "dynamic-looking" reverse DNS entries for what they consider to be legitimate server addresses. This is not ideal, and may require embedding this module in a Chain set to "accept_break" with regular expressions; for example:
my $milter = new Mail::Milter::Chain( &ConnectRegex( '\.fooisp\.com$', )->accept_match(1); &ConnectMatchesHostname, )->accept_break(1);
Creates a ConnectMatchesHostname object.
Sets the message used when rejecting connections. This string may contain the substring
%H, which will be replaced by the matching hostname, and/or the substring
%A, which will be replaced by the matching IP address.
This method returns a reference to the object itself, allowing this method call to be chained.
In Sendmail 8.11 and 8.12, a milter rejection at "connect" stage does not allow the reply message to be set -- it simply becomes "not accepting messages". However, this module still attempts to set the reply code and message in the hope that this will be fixed.
The implementation of this module could be much more efficient.
Todd Vierling, <firstname.lastname@example.org> <email@example.com>