wireguard: DNS stop to work after wg-quick down xxx on macOS #2

Closed
opened 2025-12-29 04:20:33 +01:00 by adam · 0 comments
Owner

Originally created by @ryan4yin on GitHub (Jul 17, 2023).

Run this command after disable VPN fix this problem:

sudo /usr/sbin/networksetup -setdnsservers Wi-Fi "Empty"

or add it into wireguard config:

[Interface]
# emit configs ......

# Commands to clear DNS on macOS, otherwise DNS will not work after disable VPN!
# https://ivans.io/wireguard-on-macos/
POSTDOWN = if [ -x /usr/sbin/networksetup ]; then /usr/sbin/networksetup -setdnsservers Wi-Fi "Empty"; fi

[Peer]
# emit other configuration....

Related:

Originally created by @ryan4yin on GitHub (Jul 17, 2023). Run this command after disable VPN fix this problem: ```shell sudo /usr/sbin/networksetup -setdnsservers Wi-Fi "Empty" ``` or add it into wireguard config: ```conf [Interface] # emit configs ...... # Commands to clear DNS on macOS, otherwise DNS will not work after disable VPN! # https://ivans.io/wireguard-on-macos/ POSTDOWN = if [ -x /usr/sbin/networksetup ]; then /usr/sbin/networksetup -setdnsservers Wi-Fi "Empty"; fi [Peer] # emit other configuration.... ``` Related: - [Fixing DNS for Wireguard on MacOS](https://ivans.io/wireguard-on-macos/)
adam added the bug label 2025-12-29 04:20:33 +01:00
adam closed this issue 2025-12-29 04:20:33 +01:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/nix-config-ryan4yin#2