the default tunnel MTU is 1024, and if the local DNS server
restricts to 512 byte packets you might need to use an MTU of 220.
+skip_raw_udp_mode
+ Set "-r" option in iodine command line. With this option, iodine
+ does not try to establish a direct UDP socket to the iodine server
+ on port 53. (default: true).
+
continue_on_error
Set if the script should continue even if a command fails.
Use to test script when running as non-root. Defaults to false
function version
{
- echo iodine-client-start 1.0.2
+ echo iodine-client-start 1.0.5
}
case $# in
## - if local DNS server restricts to 512 byte packets then use MTU 220
echo "${mtu}" > /dev/null
+## Set it if you want try RAW udp mode
+echo "${skip_raw_udp_mode:=true}" > /dev/null
+
## Set if the script should continue even if a command fails.
## Used to test script when running as non-root.
if [ $(whoami) = root ]; then
## ipcalc (for /usr/bin/ipcalc)
## dnsutils (for /usr/bin/dig)
## fping (for /usr/bin/fping)
+## or oping (for /usr/bin/oping)
## gawk (for /usr/bin/gawk, to use gensub())
+if type -P fping > /dev/null; then
+ ping_cmd="fping -C1"
+elif type -P oping > /dev/null; then
+ ping_cmd="oping -c1"
+else
+ ping_cmd="echo would ping"
+fi
+
## TO DO
## - avoid double ping when DNS server and local router are the same
## - option to not kill existing iodine DNS tunnels, in case there
## Find a network interface
if [ -z ${interface} ]; then
- interface=$(tail --lines=+3 /proc/net/wireless \
- | head -1 | tr -d : | awk '{print $1}')
+ interfaces=$(tail --lines=+3 /proc/net/wireless \
+ | tr -d : | awk '{print $1}')
+ for dev in ${interfaces}; do
+ if ip -4 addr show dev ${dev} | grep -q inet; then
+ interface=${dev}
+ fi
+ done
fi
if [ -z ${interface} ]; then
if ${test_ping_localnet}; then
echo ==== Ping test of local network router and DNS servers...
- fping -C1 ${router} ${nameservers} \
+ ${ping_cmd} ${router} ${nameservers} \
|| echo WARNING: Ping test failed.
fi
for n in ${nameservers}; do
n_net=$(ipcalc --nobinary ${n}/${prefix_len} | awk '$1=="Network:" {print $2}')
+ n_net8=$(ipcalc --nobinary ${n}/8 | awk '$1=="Network:" {print $2}')
if [ "${n_net}" != "${local_net}" ]; then
- echo ==== Adding point-to-point route for DNS server ${n}
- ## remove point-to-point route first, in case it is already present
- ip -4 route del ${n}/32 || true
- ip -4 route add ${n}/32 via ${router} || ${continue_on_error}
+ if [ "${n_net8}" != "127.0.0.0/8" ]; then
+ echo ==== Adding point-to-point route for DNS server ${n}
+ ## remove point-to-point route first, in case it is already present
+ ip -4 route del ${n}/32 || true
+ ip -4 route add ${n}/32 via ${router} || ${continue_on_error}
+ fi
fi
done
## Bring up DNS tunnel
echo ==== Creating IP-over-DNS tunnel...
-iodine -P "${passwd}" "${subdomain}" || ${continue_on_error}
+if ${skip_raw_udp_mode}; then
+ iodine_opts="${iodine_opts} -r"
+fi
+
+iodine ${iodine_opts} -P "${passwd}" "${subdomain}" || ${continue_on_error}
## Find DNS tunnel interface
if ${test_ping_tunnel}; then
echo ==== Ping test of local router, nameserver, and DNS tunnel...
- fping -C1 ${router} ${nameservers} ${tunnel_remote} \
+ ${ping_cmd} ${router} ${nameservers} ${tunnel_remote} \
|| echo WARNING: Ping test failed.
fi
echo ==== Setting default route through DNS tunnel...
## Remove default route via local router
-ip -4 route del default via ${router} || ${continue_on_error}
+ip -4 route del default via ${router} || echo WARNING: No default route to delete
## Add default via tunnel
ip -4 route add default via ${tunnel_remote} || ${continue_on_error}
if ${test_ping_final}; then
echo ==== Ping test of local router, nameserver, DNS tunnel, external test host...
- fping -C1 ${router} ${nameservers} ${tunnel_remote} ${testhost_ip:-${testhost}} \
+ ${ping_cmd} ${router} ${nameservers} ${tunnel_remote} ${testhost_ip:-${testhost}} \
|| echo WARNING: Ping test failed.
fi