Skip to content

Instantly share code, notes, and snippets.

@gustavorv86
Last active September 7, 2022 12:05
Show Gist options
  • Save gustavorv86/70145c63953256ea82c89a254f948428 to your computer and use it in GitHub Desktop.
Save gustavorv86/70145c63953256ea82c89a254f948428 to your computer and use it in GitHub Desktop.
Default iptables configuration.
#!/bin/bash
iptables -A INPUT -m state --state RELATED,ESTABLISHED -j ACCEPT
iptables -A INPUT -i lo -s 127.0.0.1 -d 127.0.0.1 -j ACCEPT
iptables -P INPUT DROP
iptables -P FORWARD DROP
iptables -P OUTPUT ACCEPT
@gustavorv86
Copy link
Author

Apply configuration

$ sudo source iptables.conf

Persistent

Install iptables-persistent:

$ sudo apt install iptables-persistent

Save rules:

$ sudo iptables-save > /etc/iptables/rules.v4

Show log real-time

tail -f /var/log/messages | grep -F "FW:"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment