Skip to content

Instantly share code, notes, and snippets.

@XnipS
Created November 10, 2022 23:25
Show Gist options
  • Save XnipS/56e465f43c5a5ae97b815a7dde3ab400 to your computer and use it in GitHub Desktop.
Save XnipS/56e465f43c5a5ae97b815a7dde3ab400 to your computer and use it in GitHub Desktop.
Bash script to enable/disable swap vpn and dns server.
#!/bin/bash
echo Welcome!
echo Starting VPN...
notify-send "VPN Enabled!"
if sudo openvpn --config $VPN Script Location$ --script-security 2 --up ./enablevpndns.sh ; then
echo "Vpn Succeeded!"
notify-send "VPN Disabled!"
else
echo "Vpn Failed!"
notify-send "VPN Failed!"
fi
echo Swapping to default iptables...
sudo iptables-legacy -t nat -D OUTPUT -p udp --dport 53 -j DNAT --to-destination $DNS Server$
sudo iptables-legacy -t nat -D OUTPUT -p tcp --dport 53 -j DNAT --to-destination $DNS Server$
echo Done!
exit
#Where ./enablevpndns contains:
##!/bin/bash
#iptables-legacy -t nat -A OUTPUT -p udp --dport 53 -j DNAT --to-destination $DNS Server$
#iptables-legacy -t nat -A OUTPUT -p tcp --dport 53 -j DNAT --to-destination $DNS Server$
#echo Done!
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment