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 }