From 604b5a9fa7d2d1a77f7647198ab04a54b5e04ab5 Mon Sep 17 00:00:00 2001 From: "Jason A. Donenfeld" Date: Fri, 17 May 2019 17:30:38 +0200 Subject: wg-quick: specify protocol to ip(8), because of inconsistencies Signed-off-by: Jason A. Donenfeld --- src/wg-quick/linux.bash | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/wg-quick/linux.bash b/src/wg-quick/linux.bash index 8f1812c..2f36dee 100755 --- a/src/wg-quick/linux.bash +++ b/src/wg-quick/linux.bash @@ -113,7 +113,9 @@ del_if() { } add_addr() { - cmd ip address add "$1" dev "$INTERFACE" + local proto=-4 + [[ $1 == *:* ]] && proto=-6 + cmd ip $proto address add "$1" dev "$INTERFACE" } set_mtu_up() { @@ -157,14 +159,16 @@ unset_dns() { } add_route() { + local proto=-4 + [[ $1 == *:* ]] && proto=-6 [[ $TABLE != off ]] || return 0 if [[ -n $TABLE && $TABLE != auto ]]; then - cmd ip route add "$1" dev "$INTERFACE" table "$TABLE" + cmd ip $proto route add "$1" dev "$INTERFACE" table "$TABLE" elif [[ $1 == */0 ]]; then add_default "$1" else - [[ -n $(ip route show dev "$INTERFACE" match "$1" 2>/dev/null) ]] || cmd ip route add "$1" dev "$INTERFACE" + [[ -n $(ip $proto route show dev "$INTERFACE" match "$1" 2>/dev/null) ]] || cmd ip $proto route add "$1" dev "$INTERFACE" fi } -- cgit v1.2.3-59-g8ed1b