Last active
September 1, 2023 05:10
-
-
Save qzydustin/49b5d30779240c18af472a9e7399b793 to your computer and use it in GitHub Desktop.
Reset Firewall Rules
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# This script resets the firewall rules, installs iptables-persistent, and saves the rules to files. | |
# Set the default policies to accept all traffic | |
iptables -P INPUT ACCEPT | |
iptables -P FORWARD ACCEPT | |
iptables -P OUTPUT ACCEPT | |
# Flush all existing rules and chains | |
iptables -F | |
# Install iptables-persistent package to save and restore firewall rules on system reboot | |
apt install iptables-persistent -y | |
# Save the current IPv4 and IPv6 rules to files | |
iptables-save > /etc/iptables/rules.v4 | |
ip6tables-save > /etc/iptables/rules.v6 | |
# Display the current firewall rules | |
iptables -nvL |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment