Last active
April 28, 2023 10:11
-
-
Save LuisPalacios/c7ed6d89343e9238770db550b5dc6718 to your computer and use it in GitHub Desktop.
Se ejecuta tras activar la red y termina de instalar las reglas de 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
#!/usr/bin/env bash | |
# | |
# /root/firewall/firewall_2_post_network.sh | |
# | |
# Script que se ejecuta tras activar la red y termina de instalar las reglas de iptables | |
# y realiza las últimas confirmaciones... | |
# | |
# Está relacionado con este apunte: | |
# https://www.luispa.com/administración/2023/04/08/networking-avanzado.html | |
# | |
## ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- | |
## Variables de trabajo | |
## | |
netSetupVars="/etc/default/netSetupVars" | |
basename=`basename "$0"` | |
uso() { | |
echo "${basename}. Copyright (c) 2023 Luis Palacios" | |
exit -1 # Salimos | |
} | |
if [ ! -f ${netSetupVars} ]; then echo "Error! el fichero ${netSetupVars} no existe"; uso; fi | |
. ${netSetupVars} | |
## | |
## ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- | |
## Main | |
## | |
# Me aseguro de quitar IPv6 (porque no lo uso) | |
sysctl -w net.ipv6.conf.all.disable_ipv6=1 | |
sysctl -w net.ipv6.conf.default.disable_ipv6=1 | |
# Me aseguro de ternet Activo el Routing en IPv4 | |
echo 1 > /proc/sys/net/ipv4/ip_forward | |
# Quito (0) o Activo (1) RPF (Reverse Path Forwarding) 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 | |
if [ -f /proc/sys/net/ipv4/conf/${ifLAN}/rp_filter ] | |
then | |
echo 1 > /proc/sys/net/ipv4/conf/${ifLAN}/rp_filter | |
fi | |
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/${ifMovistarDatos}/rp_filter ] | |
then | |
echo 1 > /proc/sys/net/ipv4/conf/${ifMovistarDatos}/rp_filter | |
fi | |
# Activo RPF selectivamente | |
echo 1 > /proc/sys/net/ipv4/conf/${ifVLAN33}/rp_filter |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment