Skip to content

Instantly share code, notes, and snippets.

@LuisPalacios
Created March 7, 2023 17:22
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save LuisPalacios/c218c0a3ac0fdc791f9576475620789a to your computer and use it in GitHub Desktop.
Save LuisPalacios/c218c0a3ac0fdc791f9576475620789a to your computer and use it in GitHub Desktop.
Sur: Script parte del firewall, que se ejecuta después de tener la red activa
#!/bin/bash
##
## /root/firewall/sur_firewall_2_post_network.sh
##
## Script que configura iptables en un servidor Raspbian OS
##
## Este fichero está relacionado con este apunte:
## https://www.luispa.com/linux/2014/10/19/bridge-ethernet.html
##
##
# Script para activar reglas de iptables después de activar la red.
#
# Averiguo nombres de las interfaces y rangos de mi red
#
. /root/firewall/sur_firewall_inames.sh
# Me super aseguro que tengo Routing de IPv4 activo
echo 1 > /proc/sys/net/ipv4/ip_forward
# Activo RPF selectivamente
echo 0 > /proc/sys/net/ipv4/conf/all/rp_filter
echo 1 > /proc/sys/net/ipv4/conf/default/rp_filter
echo 0 > /proc/sys/net/ipv4/conf/lo/rp_filter
# Físicas
if [ -f /proc/sys/net/ipv4/conf/${ifWan}/rp_filter ]
then
echo 1 > /proc/sys/net/ipv4/conf/${ifWan}/rp_filter
fi
if [ -f /proc/sys/net/ipv4/conf/${ifLanInternetViaNorte}/rp_filter ]
then
echo 1 > /proc/sys/net/ipv4/conf/${ifLanInternetViaNorte}/rp_filter
fi
if [ -f /proc/sys/net/ipv4/conf/${ifLanInternetViaSur}/rp_filter ]
then
echo 1 > /proc/sys/net/ipv4/conf/${ifLanInternetViaSur}/rp_filter
fi
# Virtuales
if [ -f /proc/sys/net/ipv4/conf/${ifTunelNorte}/rp_filter ]
then
echo 1 > /proc/sys/net/ipv4/conf/${ifTunelNorte}/rp_filter
fi
if [ -f /proc/sys/net/ipv4/conf/${ifBridgeIPTV}/rp_filter ]
then
echo 0 > /proc/sys/net/ipv4/conf/${ifBridgeIPTV}/rp_filter
fi
# END
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment