-# 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!
-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
+# Cannot expect awk to be present
+SUBDOMAIN=$(echo "$NAME" | sed -e "s/\([A-Z][a-z0-9]*\)\([A-Z][a-z0-9]*\)/\L\2.\L\1/;")
+
+MYIPS=$(nslookup $SUBDOMAIN.immae.eu |sed -n "/$SUBDOMAIN.immae.eu/"',$p' | grep ^Address | 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