One of the transport agents that is installed on the Exchange 2013 Edge Transport server is the connection filter agent.
The connection filter agent looks at the IP address of a server that is making an SMTP connection to the Edge Transport server and decides whether to block or allow the connection. It makes the decision by looking up the IP address in a block list, allow list, or by querying a block/allow list provider.
When your Exchange organization is receiving spam you can add the IP addresses of the spammers to an IP block list on the Edge Transport server. However this is quite inefficient, as you’ll constantly be adding new IP addresses to the list.
To add Spamhaus to your connection filter agent run the follow Exchange Management Shell command on the Edge Transport server.
Add-IPBlockListProvider -Name Spamhaus -LookupDomain zen.spamhaus.org -AnyMatch $true -Enabled $true -RejectionResponse “IP address is listed by Spamhaus”
Note you can change the rejection message that it sent back to the sender.
- Set-IPBlockListProvider Spamhaus -RejectionResponse “IP address is listed by Spamhaus Zen.”
You can add multiple providers, just make sure you check their guidance on whether there are issues adding multiple lookup domains from the same provider. Also make sure you check their terms and conditions and comply with any commercial usage policies they have.
After the block list provider has been in place for a day or two you can see the results by running the Get-AntispamTopRBLProviders.ps1 script that ships with Exchange.
C:\Program Files\Microsoft\Exchange Server\V15\scripts>.\get-AntispamTopRBLProviders.ps1
Transport Agent on MBX