Skip to content

Instantly share code, notes, and snippets.

Last active February 19, 2019 08:12
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save alpsayin/97321866816bc097fca9b185920c0fed to your computer and use it in GitHub Desktop.
Save alpsayin/97321866816bc097fca9b185920c0fed to your computer and use it in GitHub Desktop.
### Setup Instructions
#you need root, need I say it?
#disable DNSMASQ by commenting out the below line in /etc/NetworkManager/NetworkManager.conf
# dns=dnsmasq
#if it's different for any reason, establish the usual resolvconf link with
# ln -s /run/resolvconf/resolv.conf /etc/resolv.conf
#so that ls -l /etc/resolv.conf is as below
# /etc/resolv.conf -> /run/resolvconf/resolv.conf
#probably a good idea to run `resolvconf -u` at this point
#for this script to work you need to have below 2 lines in your /etc/dhcp/dhclient.conf
# prepend domain-name-servers
# supersede domain-name-servers
### Usage instructions
#run this script as su if CaptivePortal is giving you trouble
#dnscrypt is disabled, get into captiveportal, log in, and try
#once you have internet, run this script as su again
#that said if you're on a public hotspot with captivePortal, it's probably a good idea to have a VPN
enabled=`grep '^prepend domain-name-servers' /etc/dhcp/dhclient.conf | grep`
enabled=`grep '^supersede domain-name-servers' /etc/dhcp/dhclient.conf | grep`
disabled=`grep '#prepend domain-name-servers' /etc/dhcp/dhclient.conf | grep`
disabled=`grep '#supersede domain-name-servers' /etc/dhcp/dhclient.conf | grep`
if [ $enabled_result -eq 0 ]
echo "was enabled"
sed -i 's/^prepend domain-name-servers/#&/' /etc/dhcp/dhclient.conf
sed -i 's/^supersede domain-name-servers/#&/' /etc/dhcp/dhclient.conf
echo "disabled now"
elif [ $disabled_result -eq 0 ]
echo "was disabled"
sed -i 's/#*prepend domain-name-servers/prepend domain-name-servers/' /etc/dhcp/dhclient.conf
sed -i 's/#*supersede domain-name-servers/supersede domain-name-servers/' /etc/dhcp/dhclient.conf
echo "enabled now"
echo "not included"
#echo $enabled
#echo $disabled
#systemctl restart NetworkManager
dhclient wlan0
dnscrypt-proxy --resolve
Copy link

alpsayin commented Dec 19, 2018

Annoyed by CaptivePortalLogin giving you a hard time when you're set for Dnscyrpt-Proxy ?

Quick toggle script to default things to the original dns server to get through the captive-portal and re-enable

This script is useful if you're using dnscrypt proxy and CaptivePortalLogins are giving you a hard time. Bit shit though because this makes you disconnect and reconnect again. There should be a better way of updating DNS servers. Potentially through resolv.conf but I also dont wanna touch that. Seems dhclient wlan0 does just that.
-Assumes that dnsmasq is disabled in /etc/NetworkManager/NetworkManager.conf as #dns=dnsmasq
-Assumes dnscrypt-proxy2 configured with no listen-addresses and so running on
-Assumes resolv.conf is updated automatically by dhclient

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