如何重置所有 iptables 设置?

Lan*_*nes 16 iptables

有没有更简单的命令?(例如:oneliner?可以通过一个命令将 iptables/netfilter 设置重置为此吗?)

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
Run Code Online (Sandbox Code Playgroud)

xen*_*ide 12

如果您知道您没有更改其中一些默认链,它只会变得更简单。除此之外,不,这很简单。除了你可以把#!/bin/sh它放在顶部并放在一个文件和重击中,一个衬垫