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