Firewall integrations

Connect Q-Feeds to UniFi Network Lists

UniFi Network 11 can import IP and domain lists from a URL. This guide sets up five Dynamic Network Lists that pull Q-Feeds threat intelligence once a day, four for IPv4 and one for IPv6, plus the firewall policies that block the traffic. Malicious domains belong in a DNS filter, as explained below.

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: four IPv4 lists (step 2) and one IPv6 list (step 3), 500,000 entries in total.

Step 2: Create the four IPv4 lists

  1. In UniFi Network, go to Networks, Network Lists and select Create New.
  2. Name the list, for example Q-Feeds malware IPv4 1.
  3. Set Type to IP and Source to Dynamic.
  4. 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
  1. Set the refresh interval to 24 hours and save.

Repeat this for Q-Feeds malware IPv4 2, 3 and 4. 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 a fifth 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 five 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 of the five lists gets its own policies. Create these three with the action Block, once for each list: IP version IPv4 for Q-Feeds malware IPv4 1 to 4, 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.

Five lists with three policies each makes 15 block policies. 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.

The 15 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 the five 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=4 list first to make room.
  • 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 of the five lists gets its own download. Do not point two lists at the same URL with the same key.

Verify

After saving, open all five 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.
  • Update failed alert or HTTP 404 on a higher page: the feed for your license has no entries left for that page, for example 300,000 IPv4 entries or fewer for page=4. Delete that list and its policies.
  • 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.

Get your feed URLs About the UniFi integration

Already a Q-Feeds user?

Open the portal to copy your feed URLs and API key, or compare the packages if you need more.