Improve network interfaces
- Better detection of default network interface when the 'route' command is not available
This commit is contained in:
parent
c01fb79650
commit
5e3689198f
@ -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 <<EOF
|
||||
Error: Default network interface '$DEF_IFACE' detected.
|
||||
|
||||
|
@ -61,13 +61,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 <<EOF
|
||||
Error: Default network interface '$DEF_IFACE' detected.
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user