Last active
April 26, 2019 13:16
-
-
Save radium226/9332897bab5d884cd48090af0b3b5592 to your computer and use it in GitHub Desktop.
This file contains hidden or 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 | |
set -e | |
# Je récupère l'adresse IP que ma filé Avahi | |
LOCAL_AVAHI_AUTO_IP="$( ip addr show | grep "tun0" | grep -o "inet [0-9]*\.[0-9]*\.[0-9]*\.[0-9]*" | grep -o "[0-9]*\.[0-9]*\.[0-9]*\.[0-9]*" )" | |
# Idem, mais celle de raspberrypi-01 | |
REMOTE_AVAHI_AUTO_IP="$( avahi-resolve -4 -n raspberrypi-01.local | cut -d" " -f2 )" | |
DEFAULT_GATEWAY="92.92.92.254" | |
ip route add X.X.X.X via "${DEFAULT_GATEWAY}" dev eth0 # Je fais passer l'adresse externe de kimsufi-01 par eth0 | |
ip route add 8.8.8.8 via "${DEFAULT_GATEWAY}" dev eth0 # Idem pour le DNS, sinon pas de résolution... | |
ip route del default via "${DEFAULT_GATEWAY}" dev eth0 # Je supprime la route par défaut qui me fait normalement passer par mon routeur | |
ip route add default via "${REMOTE_AVAHI_AUTO_IP}" src ${LOCAL_AVAHI_AUTO_IP} # Et je la remplace en faisant passer par raspberrypi-01 |
This file contains hidden or 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 | |
set -e | |
echo 1 >"/proc/sys/net/ipv4/ip_forward" | |
iptables -A "FORWARD" -i "tun0" -j "ACCEPT" | |
iptables -A "FORWARD" -i "tun0" -o "eth0" -m "state" --state "RELATED,ESTABLISHED" -j "ACCEPT" | |
iptables -A "FORWARD" -i "eth0" -o tun0 -m state --state "RELATED,ESTABLISHED" -j "ACCEPT" | |
iptables -t "nat" -A "POSTROUTING" -s "169.254.0.0/16" -o "eth0" -j "MASQUERADE" | |
iptables -A "OUTPUT" -o "tun0" -j ACCEPT |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment