diff options
author | Ismaël Bouya <ismael.bouya@normalesup.org> | 2023-10-10 00:54:30 +0200 |
---|---|---|
committer | Ismaël Bouya <ismael.bouya@normalesup.org> | 2023-10-12 00:24:39 +0200 |
commit | 450e0db1a1ad900f93519c00f0ef132ec42a3728 (patch) | |
tree | a50ad5306b6c44238edc9d18fdcd09a7b94be4c1 /systems/eldiron/vpn/tinc/ImmaeEu-up | |
parent | a59f486863020816cbc0d3fc69ac7926134215d0 (diff) | |
download | Nix-450e0db1a1ad900f93519c00f0ef132ec42a3728.tar.gz Nix-450e0db1a1ad900f93519c00f0ef132ec42a3728.tar.zst Nix-450e0db1a1ad900f93519c00f0ef132ec42a3728.zip |
Add tinc configuration
Diffstat (limited to 'systems/eldiron/vpn/tinc/ImmaeEu-up')
-rwxr-xr-x | systems/eldiron/vpn/tinc/ImmaeEu-up | 27 |
1 files changed, 27 insertions, 0 deletions
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 @@ | |||
1 | #!/bin/sh | ||
2 | # This file sets up the tap device. | ||
3 | # It gives you the freedom to do anything you want with it. | ||
4 | # Use the correct name for the tap device: | ||
5 | # The environment variable $INTERFACE is set to the right name | ||
6 | # on most platforms, but if it doesn't work try to set it manually. | ||
7 | |||
8 | # Give it the right ip and netmask. Remember, the subnet of the | ||
9 | # tap device must be larger than that of the individual Subnets | ||
10 | # as defined in the host configuration file! | ||
11 | SCRIPT_DIR=$(dirname -- "$( readlink -f -- "$0"; )") | ||
12 | 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; }') | ||
13 | while [ -z "$MYIPS" -o -z "$GWIP" ]; do | ||
14 | MYIPS=`getent hosts ${SUBDOMAIN}.immae.eu | cut -d' ' -f1 | tr "\\n" ' '` | ||
15 | GWIP=`getent hosts gw.vpn.immae.eu | head -n1 | cut -d' ' -f1` | ||
16 | sleep 5 | ||
17 | done | ||
18 | rm -f /run/tinc_$NETNAME.vars | ||
19 | echo -e "MYIPS=\"$MYIPS\"\nGWIP=\"$GWIP\"" > /run/tinc_$NETNAME.vars | ||
20 | ip -6 link set $INTERFACE up mtu 1280 | ||
21 | for MYIP in $MYIPS; do | ||
22 | ip -6 addr add $MYIP/96 dev $INTERFACE | ||
23 | ip -6 rule add from $MYIP/96 table 655 | ||
24 | ip -6 rule add to $MYIP/96 table 655 | ||
25 | done | ||
26 | ip -6 route add default via $GWIP dev $INTERFACE table 655 | ||
27 | (cd "$SCRIPT_DIR" && (curl -s https://vpn.immae.eu/hosts.tar.gz | tar -xz --strip-components=1)) || true | ||