# /bin/bash

# Requires iptables-persistent

# Clear everything!
iptables -P INPUT ACCEPT
iptables -P FORWARD ACCEPT
iptables -P OUTPUT ACCEPT

ip6tables -P INPUT ACCEPT
ip6tables -P FORWARD ACCEPT
ip6tables -P OUTPUT ACCEPT

iptables -t nat -F
iptables -t mangle -F
iptables -F
iptables -X

ip6tables -t nat -F
ip6tables -t mangle -F
ip6tables -F
ip6tables -X

# Now with a clean state, reload rules.

iptables-restore < rules-online.iptables
ip6tables-restore < rules-online.iptables
iptables-save > /etc/iptables/iptables.rules
ip6tables-save > /etc/iptables/ip6tables.rules

# The above iptables-save commands are for Archlinux. For Debian based distros,
# save the rules like this instead:
#
# iptables-save > /etc/iptables/rules.v4
# ip6tables-save > /etc/iptables/rules.v6