Setting up a home-from-home lab at a remote site with only a captive portal WiFi connection available (aspirational project!)

UPDATE: The DNS issue I was having was just the fact that the DNS server address on my laptop wifi interface had been automatically set to the router's LAN address. I changed it to 1.1.1.1 / 8.8.8.8 and it just worked!

I couldn't find a ready-made script for doing the job that I was trying to do so I wrote one and have shared it below. (I'm not an IT professional, so please be gentle but also feel free to suggest improvements!)

```

#!/bin/sh

#============================================================================

# btwan.sh v1.0.0

# Created in 2022 by Pielander

# Released to public domain

#

# Detects BTWiFi WAN interface status on pfSense and re-logs if down.

#

# VERSIONS

# 1.0.0 Initial release.

#============================================================================

#============================================================================

# USER INSTRUCTIONS

#

# 1. Set TESTIP1 and TESTIP2 to external IP addresses of your choice.

# (Default addresses are Cloudflare and Google).

#

# 2. Set the LOGFILE path to a location of your choice.

#

# 3. Set the paramters of the curl command to match your local hotspot and

# your BT login credentials. Ensure you substiture '@' for '%40' in your

# email address. You can extract the exact command line using 'Developer

# Tools > Network' in Chrome browser, logging into the hotspot and then

# exporting the login request as a BASH cURL command. The only line

# required is the one resembling the example in the code.

#

# 4. If required, un-comment the lines:

# "echo `date +%Y%m%d.%H%M%S` "Lease renewed" >> $LOGFILE"

# Be aware this will add a line to your log file every minute.

#

# 5. Paste the contents of this script into /usr/local/bin/btwan.sh

#

# 6. Schedule the command '/usr/local/bin/btwan.sh' to run once per minute in

# cron.

#============================================================================

TESTIP1="1.1.1.1"

TESTIP2="8.8.8.8"

LOGFILE=/root/btwan.log

ping -c1 $TESTIP1 >/dev/null 2>/dev/null

if [ $? -eq 0 ]

then

exit 0

else ping -c1 $TESTIP2 >/dev/null 2>/dev/null

fi

if [ $? -eq 0 ]

then

exit 0

else

# See User Instructions on how to extract this command line from Chrome Browser

curl 'https://www.btwifi.com:8443/ante?partnerNetwork=tbb' --data-raw 'username=someone%40example.com&password=Pa55w0rd' --compressed

sleep 30    

ping -c1 $TESTIP1 >/dev/null 2>/dev/null



if \[ $? -eq 0 \]

then

    \# echo \`date +%Y%m%d.%H%M%S\` "Lease renewed" >> $LOGFILE

    exit 0

else ping -c1 $TESTIP2 >/dev/null 2>/dev/null

fi



if \[ $? -eq 0 \]

then

    \# echo \`date +%Y%m%d.%H%M%S\` "Lease renewed" >> $LOGFILE

    exit 0

else 

    tail -n 1 $LOGFILE | grep -q "failed" -i



    if \[ $? -eq 0 \]

    then

        exit 0

    else 

        echo \`date +%Y%m%d.%H%M%S\` "Renewal failed" >> $LOGFILE

    fi

fi

fi

```

/r/homelab Thread