On some macOS setups, wg-quick up
does not work correctly if the Wireguard configuration includes a DNS server address.
When this error occurs, wg-quick up
exits with the following lines, and the Wireguard tunnel will not work:
$ sudo wg-quick up wg0
...
[#] rm -f /var/run/wireguard/utun3.sock
[#] rm -f /var/run/wireguard/wg0.name
$ _
This error can be caused by an EXIT
signal that occurs in the cmd_up
function.
As a workaround, the signal handler for the EXIT
signal can be removed.
To do this, edit the cmd_up
function in line 451 of /usr/local/bin/wg-quick
. You have to remove EXIT
from the two trap
statements like this:
Before:
cmd_up() {
local i
get_real_interface && die "\`$INTERFACE' already exists as \`$REAL_INTERFACE'"
trap 'del_if; del_routes; exit' INT TERM EXIT
execute_hooks "${PRE_UP[@]}"
add_if
set_config
for i in "${ADDRESSES[@]}"; do
add_addr "$i"
done
set_mtu
up_if
for i in $(while read -r _ i; do for i in $i; do [[ $i =~ ^[0-9a-z:.]+/[0-9]+$ ]] && echo "$i"; done; done < <(>
add_route "$i"
done
[[ $AUTO_ROUTE4 -eq 1 || $AUTO_ROUTE6 -eq 1 ]] && set_endpoint_direct_route
[[ ${#DNS[@]} -gt 0 ]] && set_dns
monitor_daemon
execute_hooks "${POST_UP[@]}"
trap - INT TERM EXIT
}
After:
cmd_up() {
local i
get_real_interface && die "\`$INTERFACE' already exists as \`$REAL_INTERFACE'"
trap 'del_if; del_routes; exit' INT TERM
execute_hooks "${PRE_UP[@]}"
add_if
set_config
for i in "${ADDRESSES[@]}"; do
add_addr "$i"
done
set_mtu
up_if
for i in $(while read -r _ i; do for i in $i; do [[ $i =~ ^[0-9a-z:.]+/[0-9]+$ ]] && echo "$i"; done; done < <(>
add_route "$i"
done
[[ $AUTO_ROUTE4 -eq 1 || $AUTO_ROUTE6 -eq 1 ]] && set_endpoint_direct_route
[[ ${#DNS[@]} -gt 0 ]] && set_dns
monitor_daemon
execute_hooks "${POST_UP[@]}"
trap - INT TERM
}
Note: This error was observed in wg-quick
version 1.0.20210914
. You can check which version you're using with the following command:
brew info wireguard-tools | grep stable