Как сбросить Ubuntu 12.04 iptables для установки по умолчанию, не блокируя себя?

К сожалению, нет такого решения для FreeBSD. Существует много решений как dummynet/ipfw или altq/pf, которые используются для ограничения использования сети на основе различных шаблонов, но не на pids.

На Linux существует способ ограничить использование сети на пользовательской основе:

iptables -t mangle -A OUTPUT -p tcp -m owner --uid-owner test -j MARK --set-mark 1

Я думаю, что нет никакого решения ограничить использование сети на основе pid.

28
задан 10 April 2013 в 15:44
3 ответа

Установите политику по умолчанию для iptables на ACCEPT:

iptables -P INPUT ACCEPT
iptables -P OUTPUT ACCEPT
iptables -P FORWARD ACCEPT

Затем очистите правила:

iptables -F INPUT
iptables -F OUTPUT
iptables -F FORWARD

Обратите внимание, это не повлияет на альтернативные таблицы, таблицы NAT, таблицы маршрутизации PRE / POST и т. Д. .

37
ответ дан 28 November 2019 в 20:02

Похоже, что все в порядке... http://insanelabs.com/linux/linux-reset-iptables-firewall-rules/

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
16
ответ дан 28 November 2019 в 20:02

Ответ крыла будет на вашей стороне, когда что-то пойдет не так с iptables . Если вы хотите сбросить все, включая альтернативные таблицы, NAT, PRE/POST ROUTING, используйте этот сценарий:

#!/bin/sh
#
# rc.flush-iptables - Resets iptables to default values.
#
# Copyright (C) 2001 Oskar Andreasson <bluefluxATkoffeinDOTnet>
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; version 2 of the License.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program or from the site that you downloaded it
# from; if not, write to the Free Software Foundation, Inc., 59 Temple
# Place, Suite 330, Boston, MA 02111-1307 USA
#
# Configurations
#
IPTABLES="/sbin/iptables"
#
# reset the default policies in the filter table.
#
$IPTABLES -P INPUT ACCEPT
$IPTABLES -P FORWARD ACCEPT
$IPTABLES -P OUTPUT ACCEPT
#
# reset the default policies in the nat table.
#
$IPTABLES -t nat -P PREROUTING ACCEPT
$IPTABLES -t nat -P POSTROUTING ACCEPT
$IPTABLES -t nat -P OUTPUT ACCEPT
#
# reset the default policies in the mangle table.
#
$IPTABLES -t mangle -P PREROUTING ACCEPT
$IPTABLES -t mangle -P POSTROUTING ACCEPT
$IPTABLES -t mangle -P INPUT ACCEPT
$IPTABLES -t mangle -P OUTPUT ACCEPT
$IPTABLES -t mangle -P FORWARD ACCEPT
#
# flush all the rules in the filter and nat tables.
#
$IPTABLES -F
$IPTABLES -t nat -F
$IPTABLES -t mangle -F
#
# erase all chains that's not default in filter and nat table.
#
$IPTABLES -X
$IPTABLES -t nat -X
$IPTABLES -t mangle -X

Source: Internet Connection Sharing - Ubuntu Help

3
ответ дан 28 November 2019 в 20:02

Теги

Похожие вопросы