You need a UniFi gateway with UniFi Network 11.0.83 or later on UniFi OS 6.0.10 or later, admin access to the Network application and a Q-Feeds API token. See Get your threat feeds. There is nothing to install: the gateway downloads the lists itself.
Prerequisites
- UniFi Network: 11.0.83 or later
- UniFi OS: 6.0.10 or later
- Firewall: zone-based firewall policies
- Feed: malware IPs (
feed_type=malware_ip) - Network: outbound HTTPS from the gateway to
api.qfeeds.com
Step 1: Copy your API token
Log in to the Threat Intelligence Portal, open Manage API Keys and copy your token. Each Network List gets its own URL with that token in it.
Do not open the feed URLs in a browser to test them first. The API allows one download per URL and per key within the update window of your license (24 hours on Community), so a browser test can make the first download by UniFi fail with HTTP 429. If that happens anyway, see Troubleshooting below.
A UniFi IP list holds either IPv4 or IPv6 addresses, not both, and at most 100,000 entries. All Network Lists on a gateway together hold at most 500,000 entries. That is why the malware IP feed is split into pages of 100,000: up to four IPv4 lists (step 2) and one IPv6 list (step 3).
How many IPv4 lists you need depends on your license. The Malware IPs tile on the portal dashboard shows the number of IP indicators in your license, IPv4 and IPv6 together. Divide that number by 100,000 and round up: 130,000 indicators, for example, fill at most two IPv4 lists. You never need more than four.
Step 2: Create the IPv4 lists
- In UniFi Network, go to Networks, Network Lists and select Create New.
- Name the list, for example
Q-Feeds malware IPv4 1. - Set Type to IP and Source to Dynamic.
- Paste this URL with your own token in place of
YOUR_TOKEN:
https://api.qfeeds.com/api?feed_type=malware_ip&ipv6=0&limit=100000&page=1&api_token=YOUR_TOKEN
- Set the refresh interval to 24 hours and save.
If your license fills more than one page, create a list for each further page in the same way: Q-Feeds malware IPv4 2, then 3 and 4.
The number on the dashboard includes IPv6 addresses, so your highest IPv4 page can turn out to be empty. If UniFi rejects page 2, 3 or 4 with “Unreachable URL or no compatible entries found” while the pages before it work, that is the reason. Leave that list out: the lists before it already hold the complete IPv4 feed for your license.
Only the page number in the URL changes:
https://api.qfeeds.com/api?feed_type=malware_ip&ipv6=0&limit=100000&page=2&api_token=YOUR_TOKEN
https://api.qfeeds.com/api?feed_type=malware_ip&ipv6=0&limit=100000&page=3&api_token=YOUR_TOKEN
https://api.qfeeds.com/api?feed_type=malware_ip&ipv6=0&limit=100000&page=4&api_token=YOUR_TOKEN
ipv6=0 keeps the lists to IPv4 addresses and IPv4 ranges in CIDR notation. limit=100000 splits the feed into pages of 100,000, newest first: page 1 holds the newest 100,000 entries, page 2 the next 100,000, and so on.
Step 3: Create the IPv6 list
Create one more list in the same way, with Type set to IP, a name such as Q-Feeds malware IPv6, and this URL:
https://api.qfeeds.com/api?feed_type=malware_ip&ipv6=only&limit=100000&page=1&api_token=YOUR_TOKEN
Choose 24 hours again. ipv6=only returns only the IPv6 addresses and ranges from the same feed. Each list downloads its own IP version and page, so the lists do not count against each other.
Step 4: Block the traffic
The lists only hold the data. A firewall policy takes one list, so each list gets its own policies. Create these three with the action Block, once for each list: IP version IPv4 for the IPv4 lists, and IP version IPv6 for Q-Feeds malware IPv6.
- Outbound to malicious IPs: source zone Internal, destination zone External, with the list as destination. This stops devices on your network from connecting to known malicious servers.
- Inbound to your network: source zone External with the list as source, destination zone Internal. This covers devices you make reachable from the internet with a port forward.
- Inbound to the gateway: source zone External with the list as source, destination zone Gateway. UniFi treats traffic to the gateway itself as a separate zone, so the policy above does not cover it. This protects services on the gateway, such as a VPN server.
That is three block policies per list: 9 with two IPv4 lists and the IPv6 list, 15 with all five. Make sure no policy higher in the list allows the same traffic first, because the first match wins.
UniFi already blocks new connections from the internet by default. The two inbound policies cover what you open yourself, such as port forwards or a VPN server. The outbound policies do most of the work.
These policies assume all your devices are in the Internal zone. If you also use a Hotspot zone, a DMZ or a custom zone such as IoT, add the outbound policies with that zone as the source zone as well. If you forward ports to devices in such a zone, also add the inbound policies with that zone as the destination zone.
Malicious domains
This guide does not put the malware domain feed in UniFi. A firewall policy with a Domain list does not match on the name: the gateway looks up the IP addresses the domains resolve to and blocks those addresses. Malicious domains often sit on shared hosting or behind a CDN such as Cloudflare, where the same IP also serves legitimate sites, and those sites would be blocked as well. The UniFi Content Filter does block at DNS level, but its Block List cannot import a list from a URL.
Use the domain feed in a DNS filter instead, for example Pi-hole, AdGuard Home or Technitium. It is a different feed from the IP lists, so it does not count against them, and you can use the same API token.
How it works
- Refresh: UniFi downloads each list again every 24, 48 or 72 hours. Q-Feeds updates its indicators more often, so a 24-hour refresh gets you the newest data your license covers once a day.
- Up to 500,000 indicators: every download brings one page of the feed for your license, and your lists together hold up to 500,000 entries, the most UniFi allows. There are no scripts or differential updates involved.
- Newest first: the API sorts indicators by age, newest first. If the IPv4 feed for your license has more than 400,000 entries, the four lists keep the most recent threats.
- Other Network Lists: lists you already use count toward the 500,000 as well. Leave out the
page=4list first to make room. - Adding a page: the feed grows and shrinks. When the Malware IPs number on the portal dashboard crosses the next multiple of 100,000, for example from 190,000 to 210,000, or after you upgrade your license, add the list for the next page as in step 2.
- Alerts: since 11.0.83, UniFi Network alerts you when a Dynamic Network List fails to update.
- One download per feed, IP version and page: the rate limit applies per API key, per feed and, for the IP feed, per IP version and page. Each list gets its own download. Do not point two lists at the same URL with the same key.
Verify
After saving, open your lists under Networks, Network Lists and check that they hold entries and show no update alert. A full page holds exactly 100,000 entries. Turn on logging for the block policies for a few days if you want to see what they catch.
Troubleshooting
- Update failed alert or HTTP 429: the feed was already downloaded with the same key within the update window, often by a browser test or a second list with the same URL. In the portal, open the key under Manage API Keys and select Activate Override under Rate Limit Override. That lifts the limit for five minutes; refresh the list in UniFi within that time.
- The list stays empty: check the token in the URL, confirm your license is active and that the gateway can reach
https://api.qfeeds.com. - “Unreachable URL or no compatible entries found” on page 2, 3 or 4: the IPv4 feed for your license ends before that page. Leave that list out. If the list worked before and now shows an update alert, the feed has shrunk: delete the list and its policies. The Malware IPs tile on the portal dashboard shows the current size of your feed, IPv4 and IPv6 together.
- “Unreachable URL or no compatible entries found” on page 1: check the token in the URL and confirm your license is active. If you opened the URL in a browser first, see the HTTP 429 item above.
- The lists will not import or the gateway slows down: remove the highest page lists and their policies, starting with
page=4. You keep the newest indicators. - A policy seems to do nothing: a policy higher in the list matches the traffic first. Move the block policies up.
- Devices in another zone are not protected: a policy only matches the zones set in it. Add the same block policies for Hotspot, DMZ or custom zones, see Step 4.
- Legitimate sites are blocked: check for a firewall policy that uses a Domain list. Remove it and block domains in a DNS filter instead, see Malicious domains above.
- Support: support@qfeeds.com or the support page.
Q-Feeds malicious URL feeds are not supported on UniFi Network Lists. A full URL path can only be inspected by a proxy or a web filter. Use the IP feed here, and the domain feed in a DNS filter.