16

Are there any simpler commands to these? (e.g.: a oneliner? can one command reset iptables/netfilter settings to this?)

IPTABLES="$(which iptables)"

# RESET DEFAULT POLICIES
$IPTABLES -P INPUT ACCEPT
$IPTABLES -P FORWARD ACCEPT
$IPTABLES -P OUTPUT ACCEPT
$IPTABLES -t nat -P PREROUTING ACCEPT
$IPTABLES -t nat -P POSTROUTING ACCEPT
$IPTABLES -t nat -P OUTPUT ACCEPT
$IPTABLES -t mangle -P PREROUTING ACCEPT
$IPTABLES -t mangle -P OUTPUT ACCEPT

# FLUSH ALL RULES, ERASE NON-DEFAULT CHAINS
$IPTABLES -F
$IPTABLES -X
$IPTABLES -t nat -F
$IPTABLES -t nat -X
$IPTABLES -t mangle -F
$IPTABLES -t mangle -X
Braiam
  • 35,991
LanceBaynes
  • 40,135
  • 97
  • 255
  • 351

1 Answers1

13

It only gets simpler if you know that you haven't changed some of these default chains. Other than that, no, this is as simple as it gets. except for the fact that you can put #!/bin/sh at the top and put it in a file and wham, one liner

xenoterracide
  • 59,188
  • 74
  • 187
  • 252