]> git.immae.eu Git - perso/Immae/Config/tinc/hosts.git/blob - ImmaeEu-up
Android
[perso/Immae/Config/tinc/hosts.git] / ImmaeEu-up
1 #!/system/xbin/sh
2
3 SUBDOMAIN=$(cat /sdcard/.tinc/tinc_domaine | tr -c -d "[a-zA-Z0-9.]")
4
5 MYIPS=$(nslookup $SUBDOMAIN.immae.eu |sed -n "/$SUBDOMAIN.immae.eu/"',$p' | grep ^Address | sed -e "s/^[^:]*:[^0-9]*//" | tr '\n' ' ')
6 GWIP=$(nslookup vpn.immae.eu |sed -n "/vpn.immae.eu/"',$p' | grep ^Address | head -n1 | sed -e "s/^[^:]*:[^0-9]*//" | tr '\n' ' ')
7
8 echo -e "MYIPS=\"$MYIPS\"\nGWIP=\"$GWIP\"" > /sdcard/.tinc/vars
9 ip -6 link set vpn6 up mtu 1280
10 for MYIP in $MYIPS; do
11 ip -6 addr add $MYIP/96 dev vpn6
12 done
13 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)
14
15 ip -6 rule add prio 100 from all lookup 100
16 ip route add table 100 $REMOTEADDRESS $ORIGINAL_GATEWAY
17 ip -6 route add table 100 $GWIP dev vpn6
18 ip -6 route add table 100 ::/1 via $GWIP dev vpn6