Skip to content

Instantly share code, notes, and snippets.

@vpnwall-services
Last active May 8, 2018 11:45
Show Gist options
  • Save vpnwall-services/d0831d468d8aa482612ead7c2c41dbe6 to your computer and use it in GitHub Desktop.
Save vpnwall-services/d0831d468d8aa482612ead7c2c41dbe6 to your computer and use it in GitHub Desktop.
[Block non-Tor traffic] Block all traffic except on port 9050 to avoid leaks #linux #iptables #tor #security #leak
#!/bin/bash
touch /tmp/reset.iptables
iptables-restore < reset.iptables
#Reset OUTPUT table
iptables -F OUTPUT
#Enable related traffic to go through
iptables -A INPUT -m state --state ESTABLISHED, RELATED -j ACCEPT
#Enable traffic related to debian-tor user
iptables -A OUTPUT -j ACCEPT -m owner --uid-owner debian-tor
#Enable traffic from loopback
iptables -A OUTPUT -j ACCEPT -o lo
#Enable traffic through 9050
iptables -A OUTPUT -j ACCEPT -p tcp --dport 9050
#Drop everything else
iptables -P OUTPUT DROP
#Print current iptables rules
iptables -L -v
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment