Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
### 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

This comment has been minimized.

Copy link
Owner Author

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
You can’t perform that action at this time.