Script to block all non-US IPs
github.com·21h·
Discuss: r/selfhosted
Flag this post

US IP Whitelist Script

This repository contains a single Bash script, whitelist_us.sh, which configures the local system firewall to allow only traffic from IP ranges assigned to the United States. The script downloads IP block lists, creates ipset sets for IPv4/IPv6, and inserts iptables/ip6tables rules to drop non-US traffic.

Warning

This script modifies firewall rules and can block legitimate traffic if used incorrectly. Run it only on systems where you understand the impact. Test in a safe environment before applying to production.

Requirements

  • A Debian/Ubuntu-like Linux distribution with apt (tested on Debian/Ubuntu).
  • sudo privileges.
  • The script will install the following tools if not present: ipset, iptables, ip6tables, wget.

Usage

Mak…

Similar Posts

Loading similar posts...