A professional-grade IP blocklist generator for VyOS that automatically fetches, processes, and applies threat intelligence from multiple sources to your VyOS nftables firewall with full IPv4 and IPv6 support.
- Emerging Threats: Community-driven threat intelligence
- Binary Defense: Professional threat feeds
- AbuseIPDB: Crowd-sourced IP abuse database
- Smart Deduplication: Automatically removes redundant CIDR blocks
- CIDR Optimization: Merges overlapping ranges for efficiency
- Dual-Stack Support: Full IPv4 and IPv6 processing
- Whitelist Protection: Prevents blocking of your own networks (IPv4 and IPv6)
- Input Validation: All IP addresses and CIDR blocks validated
- Path Security: Protection against directory traversal attacks
- Secure API Handling: Safe management of authentication tokens
- Professional Code: Type hints, comprehensive docstrings, proper error handling
- Debian Package: Easy installation with
.debpackage - Systemd Integration: Automatic updates with timer-based scheduling
- Comprehensive Logging: Detailed logs with performance metrics
- Dry-Run Mode: Safe testing without making changes
- Native nftables: Direct integration with VyOS firewall
- Dual-Stack nftables: Separate IPv4 and IPv6 sets
- Complete Replacement: Removes old entries, adds new ones
- Atomic Updates: Safe application of blocklist changes
- Error Recovery: Graceful handling of API and network failures
Download and install the pre-built .deb package:
# Download the latest release
wget https://github.com/productsupcom/vyos-ipblock-generator/releases/latest/download/vyos-ipblock_1.0.1-1_all.deb
# Install the package
sudo dpkg -i vyos-ipblock_1.0.1-1_all.deb
# Install any missing dependencies
sudo apt-get install -f# Clone the repository
git clone https://github.com/productsupcom/vyos-ipblock-generator.git
cd vyos-ipblock-generator
# Install dependencies
pip3 install -r requirements.txt
# Make the script executable
chmod +x generate_blocklist.pyProtect your own networks from being blocked (supports both IPv4 and IPv6):
# Edit the whitelist file
sudo nano /config/scripts/whitelist.txtExample whitelist configuration:
# IPv4 Internal company networks
10.0.0.0/8
192.168.0.0/16
172.16.0.0/12
# IPv4 Critical infrastructure
203.0.113.0/24
198.51.100.0/24
# IPv4 DNS servers
8.8.8.8
8.8.4.4
# IPv6 Networks
2001:db8::/32
fd00::/8
2001:4860:4860::8888/128Important: Any IP or subnet that falls within a whitelisted CIDR block will be automatically excluded from blocking. Both IPv4 and IPv6 networks are supported.
For enhanced threat intelligence, configure an AbuseIPDB API key:
- Get a free API key from AbuseIPDB
- Configure the key:
# Option 1: Environment variable
export ABUSEIPDB_API_KEY="your-api-key-here"
# Option 2: File (recommended for automation)
echo "your-api-key-here" | sudo tee /config/scripts/abuseipdb.keyNote: The file should contain only the API key value, not ABUSEIPDB_API_KEY=value format.
After installation, you must run the script once to create the nftables sets:
# First, test the installation
vyos-ipblock --dry-run --verbose
# If the test looks good, run it for real to create the sets
vyos-ipblock --verbose
# Verify the sets were created
sudo nft list sets | grep threats-blocklistNote: The package installation only installs the files - the nftables sets are created when you first run the script.
# Test run (shows what would be done)
vyos-ipblock --dry-run --verbose
# Generate and apply blocklist once
vyos-ipblock
# Use custom whitelist file
vyos-ipblock --whitelist /path/to/custom/whitelist.txt
# Enable verbose logging
vyos-ipblock --verbose# Enable automatic updates every 6 hours
sudo systemctl enable --now vyos-ipblock.timer
# Check timer status
sudo systemctl status vyos-ipblock.timer
# View recent runs
sudo journalctl -u vyos-ipblock.service# Add to crontab for updates every 6 hours
echo "0 */6 * * * /usr/bin/vyos-ipblock" | sudo crontab -π Good news! The .deb package automatically creates the VyOS firewall groups for you during installation. You just need to configure the firewall rules.
When you install the .deb package on VyOS, it automatically creates:
threats-blocklist-ipv4IPv4 network groupthreats-blocklist-ipv6IPv6 network group
# Install the package (groups are created automatically)
sudo dpkg -i vyos-ipblock_1.0.1-1_all.debconfigure
# Create the IPv4 and IPv6 groups:
set firewall group network-group threats-blocklist-ipv4
set firewall group ipv6-network-group threats-blocklist-ipv6
# Create IPv4 rule using the auto-created network group
set firewall ipv4 forward filter rule 12 action 'drop'
set firewall ipv4 forward filter rule 12 description 'Drop IPv4 threat intelligence IPs'
set firewall ipv4 forward filter rule 12 source group network-group 'threats-blocklist-ipv4'
# Create IPv6 rule using the auto-created network group
set firewall ipv6 forward filter rule 16 action 'drop'
set firewall ipv6 forward filter rule 16 description 'Drop IPv6 threat intelligence IPs'
set firewall ipv6 forward filter rule 16 source group network-group 'threats-blocklist-ipv6'
commit
save
exit# Create the nftables sets and populate them with threat intelligence
vyos-ipblock --verbose
# Verify the sets were created
sudo nft list sets | grep threats-blocklist
# Verify the sets are active
sudo nft list sets | grep 'threat' -A 5
β Automated by .deb package:
Create VyOS network groups(done automatically)Install sync script(provided in examples)
π§ Manual steps required:
- Configure firewall rules and groups to reference the auto-created groups
- Run vyos-ipblock to create and populate nftables sets
Much simpler now! The .deb package handles the VyOS configuration automatically.
Check that everything is working:
# 1. Verify nftables sets exist and have data
sudo nft list sets | grep threats-blocklist
sudo nft list set ip vyos_filter N_threats-blocklist-ipv4 | grep elements
sudo nft list set ip6 vyos_filter N6_threats-blocklist-ipv6 | grep elements
# 2. Check firewall rules are configured
show firewall ipv4 forward filter rule 12
show firewall ipv6 forward filter rule 16
# 3. Monitor packet counters to see if blocking is working
run show firewall ipv4 forward filter rule 12
run show firewall ipv6 forward filter rule 16