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
-
TUXEDO Computers Unveils Linux Laptop Featuring AMD Ryzen CPU
This latest release is the first laptop to include the new CPU from Ryzen and Linux preinstalled.
-
XZ Gets the All-Clear
The back door xz vulnerability has been officially reverted for Fedora 40 and versions 38 and 39 were never affected.
-
Canonical Collaborates with Qualcomm on New Venture
This new joint effort is geared toward bringing Ubuntu and Ubuntu Core to Qualcomm-powered devices.
-
Kodi 21.0 Open-Source Entertainment Hub Released
After a year of development, the award-winning Kodi cross-platform, media center software is now available with many new additions and improvements.
-
Linux Usage Increases in Two Key Areas
If market share is your thing, you'll be happy to know that Linux is on the rise in two areas that, if they keep climbing, could have serious meaning for Linux's future.
-
Vulnerability Discovered in xz Libraries
An urgent alert for Fedora 40 has been posted and users should pay attention.
-
Canonical Bumps LTS Support to 12 years
If you're worried that your Ubuntu LTS release won't be supported long enough to last, Canonical has a surprise for you in the form of 12 years of security coverage.
-
Fedora 40 Beta Released Soon
With the official release of Fedora 40 coming in April, it's almost time to download the beta and see what's new.
-
New Pentesting Distribution to Compete with Kali Linux
SnoopGod is now available for your testing needs
-
Juno Computers Launches Another Linux Laptop
If you're looking for a powerhouse laptop that runs Ubuntu, the Juno Computers Neptune 17 v6 should be on your radar.