
If you frequently switch between trusted and untrusted networks, manually toggling your VPN becomes...
If you frequently switch between trusted and untrusted networks, manually toggling your VPN becomes tedious fast.
This guide shows how to automatically connect or disconnect Cloudflare WARP based on your WiFi network name (SSID) using NetworkManager on Linux.
Not all networks are equal:
Instead of manually toggling WARP every time, we can hook into network state changes and automate it.
Linux systems using NetworkManager support dispatcher scripts—these are triggered automatically when network events occur (e.g., connecting to WiFi).
We leverage this to:
Make sure warp-cli is available. Then register and test:
warp-cli register
warp-cli connect
warp-cli status
Dispatcher scripts live here:
/etc/NetworkManager/dispatcher.d/
Create a new script:
sudo nano /etc/NetworkManager/dispatcher.d/99-warp-toggle
#!/bin/bash
INTERFACE="$1"
STATUS="$2"
# Trigger only when a connection is established
if [ "$STATUS" = "up" ]; then
SSID=$(iwgetid -r)
if [ "$SSID" = "home_wifi" ]; then
echo "Connecting WARP for $SSID"
warp-cli connect
elif [ "$SSID" = "office_wifi" ]; then
echo "Disconnecting WARP for $SSID"
warp-cli disconnect
else
echo "Unknown network: $SSID — no action taken"
fi
fi
sudo chmod +x /etc/NetworkManager/dispatcher.d/99-warp-toggle
Restart NetworkManager:
sudo systemctl restart NetworkManager
Or simply reconnect your WiFi.
Switch between your networks:
home_wifi → WARP should connectoffice_wifi → WARP should disconnectVerify with:
warp-cli status
iwgetid (usually part of wireless-tools)🔹 Add Logging
echo "$(date): Connected to $SSID" >> /var/log/warp-toggle.log
case "$SSID" in
"home_wifi")
warp-cli connect
;;
"office_wifi")
warp-cli disconnect
;;
*)
echo "No rule for $SSID"
;;
esac
You can invert the logic:
This approach is:
You’re essentially turning your machine into a context-aware system—reacting intelligently to its environment.
Once you get comfortable with dispatcher scripts, you can extend this pattern to:
Happy hacking 🚀
aiMost of us have seen a coding agent fail to complete a task we know it can do. We just don't...
googlecloudWhen building Generative AI applications, developers often encounter a massive bottleneck: sequential...
discussI’ve been thinking about sharing some electronic circuit posts on Dev.to — small circuits, DIY...
agentsWhat nobody tells you about exporting your multi-agent prototype to a local workspace. Every...
agenticarchitectAutonomous agents are genuinely good at answering messy business questions. Give one an LLM and a set...
aiPR volume went up, ticket quality didn't, and the gap got filled with LLMs on both sides of the review: bots reviewing, bots replying, bots occasionally arguing with bots about priorities that only existed in a teammate's head. Our CEO named the actual problem, and it's bigger than code review.
Workflows from the Neura Market marketplace related to this Stable Diffusion resource