Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Present any network "logon page" with network connect.
# I have both the interface and external ip echoed to conky, so I had a version of this script already.
# This version is for autolaunch, so it presents a nice popup browser if it can't resolve its own IP
# address (such as for places that have public wifi and "click here".
# This version is designed to start up with the GUI interface, not as a system
# service! So if you use it with WICD, do not do it as an ifup command, otherwise
# you will have issues because it can't launch the browser.
function getextip {
ext_ip=$(wget -q -O - |grep "Current IP Check"| sed -e 's/[^[:digit:]|.]//g')
# Yes, I am only testing IPv4 here.
if [ $len_ext_ip -lt 16 ]; then
if [ $len_ext_ip -gt 7 ]; then
#main function
ext_ip=$(echo "")
interface=$(netstat -nr | grep -m 1 ^ | awk -F " " '{print $8}')
# Response should be tun[0-9], wlan[0-9], eth[0-9]
# You can use a more complex case statement here if you like
if [ "$interface" != "" ]; then
if [ $status = 0 ]; then
# I use midori here because it's the lightest weight browser that can handle
# all the different forms and such that I've encountered for public wifi login
# otherwise I'd use elinks. Ah well.
midori &
sleep 60
# Alternately, get rid of the ampersand and have the script wait for you to close the browser.
if [ "$status" = "0" ]; then
ext_ip=$(echo "")
# This could also be where you insert a command to bring up your VPN if $ext_ip != :)
echo "$interface"
echo "$ext_ip"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment