wg-quick: specify protocol to ip(8), because of inconsistencies

Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
This commit is contained in:
Jason A. Donenfeld 2019-05-17 17:30:38 +02:00
parent ce55f857ff
commit 604b5a9fa7
1 changed files with 7 additions and 3 deletions

View File

@ -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
}