mirror of
https://github.com/SinTan1729/random.git
synced 2024-12-24 20:38:36 -06:00
24 lines
824 B
Bash
24 lines
824 B
Bash
#!/bin/env bash
|
|
|
|
# This script allows one to log into captive portals by temporarily using the provided DNS records. Otherwise, captive portals
|
|
# don't work with custom resolvconf setups
|
|
|
|
set -e
|
|
|
|
# Get the DNS resolver provided by the network
|
|
DNS=$(nmcli -f IP4.DNS dev show wlan0 | awk '{print $2}' | head -1)
|
|
|
|
# Temporarily put the DNS resolver in place
|
|
echo "Need sudo permission to work with /etc/resolv.conf"
|
|
sudo cp /etc/resolv.conf /etc/resolv.conf.bk
|
|
echo "# Temporary resolv.conf generated by captive-portal-login.sh" | sudo tee /etc/resolv.conf
|
|
echo "nameserver $DNS" | sudo tee -a /etc/resolv.conf
|
|
|
|
echo "Put temporary DNS resolver in place. Fix the captive portal before continuing."
|
|
xdg-open 1.1.1.1
|
|
|
|
read -p "Press enter to continue..."
|
|
|
|
# Put back own resolvers
|
|
sudo mv /etc/resolv.conf.bk /etc/resolv.conf
|
|
|