Last active
December 4, 2024 11:42
-
-
Save LuisPalacios/59ed7e4df2e232689c555cf88bfdb733 to your computer and use it in GitHub Desktop.
Sur: Script que se ejecuta al levantar el tunel OpenVPN
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 | |
# Script que se ejecuta al levantar el tunel OpenVPN | |
# | |
# /etc/openvpn/client/sur_cliente_access_de_norte_UP.sh | |
# | |
# Documentado en: | |
# https://www.luispa.com/linux/2014/10/19/bridge-ethernet.html | |
# | |
# Interfaces, rutas + IP y MACs asociaré a las interfaces tap y bridge | |
. /etc/openvpn/client/sur_cliente_access_de_norte_CONFIG.sh | |
# Activo MASQUERADE para los clientes de LAN | |
iptables -t nat -I POSTROUTING -o ${ifNorteTunel} -j MASQUERADE # Hacia Internet sale con mi IP | |
## Tabla de routing para la LAN | |
## | |
## Equipos que salen a internet vía el router de Movistar en NORTE | |
## | |
# Creo una tabla de routing dedicada | |
grep -i "^107 Norte" /etc/iproute2/rt_tables > /dev/null 2>&1 | |
if [ "$?" = 1 ]; then | |
sudo echo "107 Norte" >> /etc/iproute2/rt_tables | |
fi | |
ip route add ${ipNorteLanRango} dev ${ifNorteLan} table Norte 2>/dev/null | |
ip route add default via ${ipNorteTunelRouter} table Norte 2>/dev/null | |
# Creo una regla que indica qué equipos deben usar dicha tabla de routing | |
ip rule add from ${ipNorteLanRango} table Norte 2>/dev/null |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment