]> git.immae.eu Git - perso/Immae/Config/tinc/hosts.git/blobdiff - ImmaeEu-up
Merge branch 'master' into android
[perso/Immae/Config/tinc/hosts.git] / ImmaeEu-up
index 95004f34bcf053d87527470e2b7ec07f5a9a0532..09210464827a5440419242c13f54bac921fc7eba 100644 (file)
@@ -3,11 +3,16 @@
 SUBDOMAIN=$(cat /sdcard/.tinc/tinc_domaine | tr -c -d "[a-zA-Z0-9.]")
 
 MYIPS=$(nslookup $SUBDOMAIN.immae.eu |sed -n "/$SUBDOMAIN.immae.eu/"',$p' | grep ^Address | sed -e "s/^[^:]*:[^0-9]*//" | tr '\n' ' ')
-GWIP=$(nslookup vpn.immae.eu |sed -n "/vpn.immae.eu/"',$p' | grep ^Address | head -n1 | sed -e "s/^[^:]*:[^0-9]*//" | tr '\n' ' ')
+GWIP=$(nslookup gw.vpn.immae.eu |sed -n "/gw.vpn.immae.eu/"',$p' | grep ^Address | head -n1 | sed -e "s/^[^:]*:[^0-9]*//" | tr '\n' ' ')
 
 echo -e "MYIPS=\"$MYIPS\"\nGWIP=\"$GWIP\"" > /sdcard/.tinc/vars
 ip -6 link set vpn6 up mtu 1280
 for MYIP in $MYIPS; do
        ip -6 addr add $MYIP/96 dev vpn6
 done
-ip -6 route add default via $GWIP
+ORIGINAL_GATEWAY=$(for a in $(ip rule show | grep lookup | sed -r 's/.* lookup ([^ ]+).*/\1/'); do ip route show table $a | grep ^default | cut -d ' ' -f 2-5; done | head -1)
+
+ip -6 rule add prio 100 from all lookup 100
+ip route add table 100 $REMOTEADDRESS $ORIGINAL_GATEWAY 
+ip -6 route add table 100 $GWIP dev vpn6
+ip -6 route add table 100 ::/1 via $GWIP dev vpn6