From 450e0db1a1ad900f93519c00f0ef132ec42a3728 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Isma=C3=ABl=20Bouya?= Date: Tue, 10 Oct 2023 00:54:30 +0200 Subject: Add tinc configuration --- systems/eldiron/vpn/tinc/ImmaeEu-up | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100755 systems/eldiron/vpn/tinc/ImmaeEu-up (limited to 'systems/eldiron/vpn/tinc/ImmaeEu-up') diff --git a/systems/eldiron/vpn/tinc/ImmaeEu-up b/systems/eldiron/vpn/tinc/ImmaeEu-up new file mode 100755 index 0000000..e14fd5a --- /dev/null +++ b/systems/eldiron/vpn/tinc/ImmaeEu-up @@ -0,0 +1,27 @@ +#!/bin/sh +# This file sets up the tap device. +# It gives you the freedom to do anything you want with it. +# Use the correct name for the tap device: +# The environment variable $INTERFACE is set to the right name +# on most platforms, but if it doesn't work try to set it manually. + +# Give it the right ip and netmask. Remember, the subnet of the +# tap device must be larger than that of the individual Subnets +# as defined in the host configuration file! +SCRIPT_DIR=$(dirname -- "$( readlink -f -- "$0"; )") +SUBDOMAIN=$(echo "$NAME" | sed -e "s/\([A-Z][a-z0-9]*\)/\L\1 /g;" | awk '{ for (i=NF; i>1; i--) printf("%s.",$i); print $1; }') +while [ -z "$MYIPS" -o -z "$GWIP" ]; do + MYIPS=`getent hosts ${SUBDOMAIN}.immae.eu | cut -d' ' -f1 | tr "\\n" ' '` + GWIP=`getent hosts gw.vpn.immae.eu | head -n1 | cut -d' ' -f1` + sleep 5 +done +rm -f /run/tinc_$NETNAME.vars +echo -e "MYIPS=\"$MYIPS\"\nGWIP=\"$GWIP\"" > /run/tinc_$NETNAME.vars +ip -6 link set $INTERFACE up mtu 1280 +for MYIP in $MYIPS; do + ip -6 addr add $MYIP/96 dev $INTERFACE + ip -6 rule add from $MYIP/96 table 655 + ip -6 rule add to $MYIP/96 table 655 +done +ip -6 route add default via $GWIP dev $INTERFACE table 655 +(cd "$SCRIPT_DIR" && (curl -s https://vpn.immae.eu/hosts.tar.gz | tar -xz --strip-components=1)) || true -- cgit v1.2.3