From Nate, 2 Weeks ago, written in Bash.
This paste will expire in 1 Week.
Embed
  1. # fetch the list of vpn servers
  2. wget -O /tmp/vpn_servers.txt https://raw.githubusercontent.com/X4BNet/lists_vpn/main/ipv4.txt
  3. wget -O /tmp/protonvpn_servers.txt https://raw.githubusercontent.com/X4BNet/lists_vpn/main/input/ips/protonvpn.txt
  4. wget -O /tmp/tor_exit.txt https://check.torproject.org/torbulkexitlist
  5.  
  6. # create a new set
  7. ipset create vpn_servers hash:ip hashsize 4096
  8.  
  9. # add the protonvpn servers to the list of vpn servers
  10. cat /tmp/protonvpn_servers.txt >> /tmp/vpn_servers.txt
  11.  
  12. # add the tor_exit servers to the list of vpn servers
  13. cat /tmp/tor_exit.txt >> /tmp/vpn_servers.txt
  14.  
  15. # remove duplicates
  16. sort /tmp/vpn_servers.txt | uniq > /tmp/vpn_servers_uniq.txt
  17.  
  18. # add all the vpn servers to the chain
  19. for ip in $(cat /tmp/vpn_servers_uniq.txt); do ipset add vpn_servers $ip; done
  20.  
  21. # save the set
  22. ipset save vpn_servers > /etc/ipset.rules
  23.  
  24. # remove the temporary files
  25. rm /tmp/vpn_servers.txt
  26. rm /tmp/protonvpn_servers.txt
  27. rm /tmp/tor_exit.txt
  28. rm /tmp/vpn_servers_uniq.txt
  29.  
  30.  
  31. # add the set to the filter chain
  32. iptables -I INPUT 1 -m set --match-set vpn_servers src -j DROP
  33.  
  34. # save the filter chain
  35. iptables-save > /etc/iptables/rules.v4