Skip to content

Instantly share code, notes, and snippets.

@palmerc
Last active October 1, 2024 06:46
Show Gist options
  • Save palmerc/db90baefc9868ce1d26cf7a175b313c5 to your computer and use it in GitHub Desktop.
Save palmerc/db90baefc9868ce1d26cf7a175b313c5 to your computer and use it in GitHub Desktop.
WireGuard LaunchD Startup
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Label</key>
<string>no.corporate.wireguard</string>
<key>RunAtLoad</key>
<true/>
<key>KeepAlive</key>
<dict>
<key>NetworkState</key>
<true/>
</dict>
<key>ProgramArguments</key>
<array>
<string>/opt/homebrew/bin/wg-quick</string>
<string>up</string>
<string>/opt/homebrew/etc/wireguard/wg0.conf</string>
</array>
<key>StandardErrorPath</key>
<string>/opt/homebrew/var/log/wireguard.err</string>
<key>EnvironmentVariables</key>
<dict>
<key>PATH</key>
<string>/opt/homebrew/sbin:/opt/homebrew/bin:/usr/bin:/bin:/usr/sbin:/sbin</string>
</dict>
</dict>
</plist>
@palmerc
Copy link
Author

palmerc commented Aug 15, 2020

# Key files
chown root:wheel /Library/LaunchDaemons/no.corporate.wireguard.plist
chmod 640 /opt/homebrew/etc/wireguard/wg0.conf

# Install wireguard
brew install wireguard-tools

# Enable launchd startup
sudo launchctl enable system/no.corporate.wireguard
sudo launchctl bootstrap system /Library/LaunchDaemons/no.corporate.wireguard.plist

# Check status
sudo wg show

# Debugging / manual operation
sudo launchctl start no.corporate.wireguard
sudo launchctl stop no.corporate.wireguard

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment