Linux: Reset iptables firewall rules
by Ali on Oct.29, 2008, under Linux
Create a shell script (iptables_flush.sh) and copy paste the following lines:
#!/bin/sh
echo "Flushing iptables rules..."
sleep 1
iptables -F
iptables -X
iptables -t nat -F
iptables -t nat -X
iptables -t mangle -F
iptables -t mangle -X
iptables -P INPUT ACCEPT
iptables -P FORWARD ACCEPT
iptables -P OUTPUT ACCEPT
Make the file executable
chmod +x iptables_flush.sh
and run the script:
./iptables_flush.sh
To the extent possible under law, the creator has waived all copyright and related or neighboring rights to this work.
2 Comments for this entry
4 Trackbacks / Pingbacks for this entry
-
Reset iptables Rules – shkschneider's Blog
May 18th, 2012 on 5:25 AM[…] http://insanelabs.com/linux/linux-reset-iptables-firewall-rules/ 0 Share this:Related Posts:No Related Posts Read more from Code, GNU/Linux Click here to cancel reply. […]
-
Notizbox » Blog Archiv » iptables Regeln zurücksetzen
November 1st, 2012 on 1:40 PM[…] nach einer Möglichkeit die iptables Regeln zurückzusetzen, bin ich über die Seite http://insanelabs.com/linux/linux-reset-iptables-firewall-rules/ gestolpert. Dort gibt es ein kleines Skript welches genau für diesen Einsatzzweck […]
-
安装v2ray后wordpress无法访问 - Christopher
September 22nd, 2019 on 4:29 AM[…] Linux: Reset iptables firewall rules […]
August 10th, 2011 on 10:27 AM
There rules will lock down the machine and if you are connecting from a remote ssh session you wont connect.
I’d recommend these rules
# iptables -P INPUT ACCEPT
# iptables -F
# iptables -A INPUT -i lo -j ACCEPT
# iptables -A INPUT -m state –state ESTABLISHED,RELATED -j ACCEPT
# iptables -A INPUT -p tcp –dport 22 -j ACCEPT
# iptables -P INPUT DROP
# iptables -P FORWARD DROP
# iptables -P OUTPUT ACCEPT
# iptables -L -v
April 2nd, 2018 on 6:23 AM
Flushing iptables rules when I get lost which rule runs first 🙂