diff --git a/vpnsetup.sh b/vpnsetup.sh index cdc0f8a..ea5bb35 100755 --- a/vpnsetup.sh +++ b/vpnsetup.sh @@ -1,6 +1,6 @@ #!/bin/sh # -# Script for automatic setup of an IPsec VPN server on Ubuntu LTS and Debian 8. +# Script for automatic setup of an IPsec VPN server on Ubuntu LTS and Debian. # Works on any dedicated server or Virtual Private Server (VPS) except OpenVZ. # # DO NOT RUN THIS SCRIPT ON YOUR PC OR MAC! @@ -66,13 +66,14 @@ if [ "$(id -u)" != 0 ]; then fi NET_IFACE=${VPN_NET_IFACE:-'eth0'} -DEF_IFACE="$(route | grep '^default' | grep -o '[^ ]*$')" +DEF_IFACE="$(route 2>/dev/null | grep '^default' | grep -o '[^ ]*$')" +[ -z "$DEF_IFACE" ] && DEF_IFACE="$(ip -4 route list 0/0 2>/dev/null | grep -Po '(?<=dev )(\S+)')" if_state1=$(cat "/sys/class/net/$DEF_IFACE/operstate" 2>/dev/null) if [ -z "$VPN_NET_IFACE" ] && [ -n "$if_state1" ] && [ "$if_state1" != "down" ]; then if ! grep -qs raspbian /etc/os-release; then case "$DEF_IFACE" in - wlan*) + wl*) cat 1>&2 </dev/null) if [ -z "$VPN_NET_IFACE" ] && [ -n "$if_state1" ] && [ "$if_state1" != "down" ]; then if ! grep -qs raspbian /etc/os-release; then case "$DEF_IFACE" in - wlan*) + wl*) cat 1>&2 <