Created
November 10, 2022 23:25
-
-
Save XnipS/56e465f43c5a5ae97b815a7dde3ab400 to your computer and use it in GitHub Desktop.
Bash script to enable/disable swap vpn and dns server.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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