wg-quick: specify protocol to ip(8), because of inconsistencies
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
This commit is contained in:
parent
ce55f857ff
commit
604b5a9fa7
|
@ -113,7 +113,9 @@ del_if() {
|
||||||
}
|
}
|
||||||
|
|
||||||
add_addr() {
|
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() {
|
set_mtu_up() {
|
||||||
|
@ -157,14 +159,16 @@ unset_dns() {
|
||||||
}
|
}
|
||||||
|
|
||||||
add_route() {
|
add_route() {
|
||||||
|
local proto=-4
|
||||||
|
[[ $1 == *:* ]] && proto=-6
|
||||||
[[ $TABLE != off ]] || return 0
|
[[ $TABLE != off ]] || return 0
|
||||||
|
|
||||||
if [[ -n $TABLE && $TABLE != auto ]]; then
|
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
|
elif [[ $1 == */0 ]]; then
|
||||||
add_default "$1"
|
add_default "$1"
|
||||||
else
|
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
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue