From 338ca1ac4297abd41ba315097a458e1a27d866d1 Mon Sep 17 00:00:00 2001 From: Saverio Miroddi Date: Sat, 14 Nov 2020 22:47:22 +0100 Subject: [PATCH] Check if IPv6 got disabled via kernel parameter before trying to disable it --- connect_to_openvpn_with_token.sh | 7 +++++-- connect_to_wireguard_with_token.sh | 7 +++++-- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/connect_to_openvpn_with_token.sh b/connect_to_openvpn_with_token.sh index ca1ff65..a871538 100755 --- a/connect_to_openvpn_with_token.sh +++ b/connect_to_openvpn_with_token.sh @@ -66,8 +66,11 @@ fi # PIA currently does not support IPv6. In order to be sure your VPN # connection does not leak, it is best to disabled IPv6 altogether. -if [ $(sysctl -n net.ipv6.conf.all.disable_ipv6) -ne 1 ] || - [ $(sysctl -n net.ipv6.conf.default.disable_ipv6) -ne 1 ] +# IPv6 can also be disabled via kernel commandline param, so we must +# first check if this is the case. +if [[ -f /proc/net/if_inet6 ]] && + [[ $(sysctl -n net.ipv6.conf.all.disable_ipv6) -ne 1 || + $(sysctl -n net.ipv6.conf.default.disable_ipv6) -ne 1 ]] then echo 'You should consider disabling IPv6 by running:' echo 'sysctl -w net.ipv6.conf.all.disable_ipv6=1' diff --git a/connect_to_wireguard_with_token.sh b/connect_to_wireguard_with_token.sh index f09ed8c..5260cdd 100755 --- a/connect_to_wireguard_with_token.sh +++ b/connect_to_wireguard_with_token.sh @@ -37,8 +37,11 @@ check_tool jq jq # PIA currently does not support IPv6. In order to be sure your VPN # connection does not leak, it is best to disabled IPv6 altogether. -if [ $(sysctl -n net.ipv6.conf.all.disable_ipv6) -ne 1 ] || - [ $(sysctl -n net.ipv6.conf.default.disable_ipv6) -ne 1 ] +# IPv6 can also be disabled via kernel commandline param, so we must +# first check if this is the case. +if [[ -f /proc/net/if_inet6 ]] && + [[ $(sysctl -n net.ipv6.conf.all.disable_ipv6) -ne 1 || + $(sysctl -n net.ipv6.conf.default.disable_ipv6) -ne 1 ]] then echo 'You should consider disabling IPv6 by running:' echo 'sysctl -w net.ipv6.conf.all.disable_ipv6=1'