Last active
March 18, 2023 16:53
-
-
Save LuisPalacios/375aa2faa215e22a6a48f8cb3047e882 to your computer and use it in GitHub Desktop.
Norte: parte del firewall, limpia iptables
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# | |
## Servidor ‘norte’ | |
## | |
## Este fichero está relacionado con este apunte: | |
## https://www.luispa.com/linux/2014/10/19/bridge-ethernet.html | |
## | |
# | |
# Quita las iptables por completo, lo permite todo. | |
# | |
# Averiguo nombres de las interfaces | |
. /root/firewall/norte_firewall_inames.sh | |
# Funciones | |
set_table_policy() { | |
local chains table=$1 policy=$2 | |
case ${table} in | |
nat) chains="PREROUTING POSTROUTING OUTPUT";; | |
mangle) chains="PREROUTING INPUT FORWARD OUTPUT POSTROUTING";; | |
filter) chains="INPUT FORWARD OUTPUT";; | |
*) chains="";; | |
esac | |
local chain | |
for chain in ${chains} ; do | |
iptables -t ${table} -P ${chain} ${policy} | |
#echo "iptables -t ${table} -P ${chain} ${policy}" | |
done | |
} | |
# Limpiar las tablas de routing | |
# | |
export iptables_proc="/proc/net/ip_tables_names" | |
for a in $(cat ${iptables_proc}) ; do | |
set_table_policy $a ACCEPT | |
iptables -F -t $a | |
iptables -X -t $a | |
done | |
# Limpiar iptables por completo | |
iptables -P INPUT ACCEPT | |
iptables -P FORWARD ACCEPT | |
iptables -P OUTPUT ACCEPT | |
iptables -t nat -F | |
iptables -t mangle -F | |
iptables -F | |
iptables -X |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment