User Tools

Site Tools


wiki:save_iptables_rules_clear_firewall

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Next revision
Previous revision
wiki:save_iptables_rules_clear_firewall [2025/09/18 08:26] – created antisawiki:save_iptables_rules_clear_firewall [2025/10/08 11:14] (current) – [Save iptables rules and clear firewall] add bash one-liners antisa
Line 10: Line 10:
  
 Then, flush and open all the firewall rules using the following commands: Then, flush and open all the firewall rules using the following commands:
 +<WRAP center round important 60%>
 +Order you execute the commands below matters!
 +Otherwise you might lock yourself out of the machine.
 +</WRAP>
  
 +
 +  iptables -P INPUT ACCEPT
 +  iptables -P OUTPUT ACCEPT
 +  iptables -P FORWARD ACCEPT
   iptables -F   iptables -F
   iptables -X   iptables -X
Line 17: Line 25:
   iptables -t mangle -F   iptables -t mangle -F
   iptables -t mangle -X   iptables -t mangle -X
-  iptables -P INPUT ACCEPT + 
-  iptables -P OUTPUT ACCEPT +
-  iptables -P FORWARD ACCEPT+
  
 For IPv6 rules, substitute ip6tables instead of iptables. For IPv6 rules, substitute ip6tables instead of iptables.
  
 +One-liner for **ipv4**:
 +
 +  iptables -P INPUT ACCEPT && iptables -P OUTPUT ACCEPT && iptables -P FORWARD ACCEPT && iptables -F && iptables -X && iptables -t nat -F && iptables -t nat -X && iptables -t mangle -F && iptables -t mangle -X
 +
 +One-liner for **ipv6**:
 +
 +  ip6tables -P INPUT ACCEPT && ip6tables -P OUTPUT ACCEPT && ip6tables -P FORWARD ACCEPT && ip6tables -F && ip6tables -X && ip6tables -t nat -F && ip6tables -t nat -X && ip6tables -t mangle -F && ip6tables -t mangle -X
 +
 +One-liner all:
 +
 +  iptables -P INPUT ACCEPT && iptables -P OUTPUT ACCEPT && iptables -P FORWARD ACCEPT && iptables -F && iptables -X && iptables -t nat -F && iptables -t nat -X && iptables -t mangle -F && iptables -t mangle -X && ip6tables -P INPUT ACCEPT && ip6tables -P OUTPUT ACCEPT && ip6tables -P FORWARD ACCEPT && ip6tables -F && ip6tables -X && ip6tables -t nat -F && ip6tables -t nat -X && ip6tables -t mangle -F && ip6tables -t mangle -X
 + 
 After testing, you can re-enable your firewall rules by running the following: After testing, you can re-enable your firewall rules by running the following:
  
wiki/save_iptables_rules_clear_firewall.1758184013.txt.gz · Last modified: by antisa

Except where otherwise noted, content on this wiki is licensed under the following license: CC0 1.0 Universal
CC0 1.0 Universal Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki