Filtering traffic by DNS name and IP address
RPZ Shenanigans
Now that you have RPZ working, what can you do with it? If you want to block entire domains (e.g., ad networks and malware networks), your best bet is to reply with NXDOMAIN. However, if you want to be a bit more selective and only block certain hosts, I suggest using NODATA (e.g., to just block ads.example.org but leave the rest of example.org unaffected). You can also use a whitelist approach – using passthrough for trusted hosts and blocking everything else within that domain.
A fourth option is the "Local Data Action." This approach allows you to create "walled gardens," so you can send clients asking for evil-domain.org to your own server (e.g., you-are-infected.example.org or even to evil-domain.org.you-are-infected.example.org).
This second option lets you preserve the data the client requested. Thus, if it's a web request for a malware site, you cannot only send clients to a server you control, which presumably has links to antivirus software, you can also take a specific action based on the domain they asked for.
Because of the way most bad guys operate, you can also prevent a lot of badness by blocking known "naughty" name servers. For example, if you find a domain being used for badness, you can block the name servers hosting it. Of course, you need to be careful here because the bad guys may be using DNS servers that also serve a lot of legitimate domains. The same goes for blocking IP addresses; quite often attackers will compromise a server and use it. In that case, blocking the entire network will effectively prevent spam and malware but also block a lot of legitimate sites.
Large-Scale RPZ
Some tips and tricks are useful in regard to large-scale RPZ, the first of which is that you can have multiple RPZ zones (e.g., one for spam, one for malware), and you can also use externally provided RPZ zones. A number of antispam and reputation firms use RPZ to share their data.
Also, if you have multiple servers, you'll want to keep the RPZ zones synchronized closely; otherwise, a client may request a record that would be blocked on server A but is allowed on server B (because the RPZ zone file is not yet synchronized). To avoid this situation, use also-notify
in the RPZ zone definition to ensure any updates are propagated quickly.
RPZ Data Sources
Now that you can block DNS requests and any resulting network traffic, you'll want to add some data sources. Your two main choices are to find data and create your own RPZ files or to point at external sources directly.
I prefer creating my own RPZ, because this gives me control over what is being blocked and prevents information from leaking. Leaking, you say? By definition, for RPZ to work, you need to send the DNS query to the server hosting the RPZ zone. If you use an external RPZ server, then they will see all your DNS queries, except for those that you define in your own zones with PASSTHROUGH.
Some good sources of data include things called "list of malware host names" and "list of ad domains." Additionally, numerous law enforcement agencies have bulletins with lists of IPs being used by malware command and control systems or other malicious actors.
« Previous 1 2 3 Next »
Buy this article as PDF
(incl. VAT)
Buy Linux Magazine
Subscribe to our Linux Newsletters
Find Linux and Open Source Jobs
Subscribe to our ADMIN Newsletters
Support Our Work
Linux Magazine content is made possible with support from readers like you. Please consider contributing when you’ve found an article to be beneficial.
News
-
Wine 10 Includes Plenty to Excite Users
With its latest release, Wine has the usual crop of bug fixes and improvements, along with some exciting new features.
-
Linux Kernel 6.13 Offers Improvements for AMD/Apple Users
The latest Linux kernel is now available, and it includes plenty of improvements, especially for those who use AMD or Apple-based systems.
-
Gnome 48 Debuts New Audio Player
To date, the audio player found within the Gnome desktop has been meh at best, but with the upcoming release that all changes.
-
Plasma 6.3 Ready for Public Beta Testing
Plasma 6.3 will ship with KDE Gear 24.12.1 and KDE Frameworks 6.10, along with some new and exciting features.
-
Budgie 10.10 Scheduled for Q1 2025 with a Surprising Desktop Update
If Budgie is your desktop environment of choice, 2025 is going to be a great year for you.
-
Firefox 134 Offers Improvements for Linux Version
Fans of Linux and Firefox rejoice, as there's a new version available that includes some handy updates.
-
Serpent OS Arrives with a New Alpha Release
After months of silence, Ikey Doherty has released a new alpha for his Serpent OS.
-
HashiCorp Cofounder Unveils Ghostty, a Linux Terminal App
Ghostty is a new Linux terminal app that's fast, feature-rich, and offers a platform-native GUI while remaining cross-platform.
-
Fedora Asahi Remix 41 Available for Apple Silicon
If you have an Apple Silicon Mac and you're hoping to install Fedora, you're in luck because the latest release supports the M1 and M2 chips.
-
Systemd Fixes Bug While Facing New Challenger in GNU Shepherd
The systemd developers have fixed a really nasty bug amid the release of the new GNU Shepherd init system.