Linux: Compare DD-WRTs WAN IP to a host’s WAN IP

1 min read

For my homelab on a particular VM that runs Ubuntu Server, I’m interested to know the public IP of my LAN’s gateway and the VM’s gateway (as it’s always connected to VPN). Below is a script I wrote to pull the WAN IP from my DD-WRT router and compare that to VM’s gateway public IP.

My copy does other things like start/stop services, configure local applications in my homelab as well as use Pushbullet to notify me if certain conditions are met. This should get you going, hopefully it helps someone.


x=$(wget "" --user="USERNAME" --password="PASSWORD" -q -O - | sed -e 's/}/\n/g' -e 's/{//g')
declare -A results
while read line; do
        IFS='::' read -ra array <<< "$line"

vmip=$(wget -q -O -

echo $0': WAN IP: '$wanip
echo $0': VM IP: '$vmip
Last Updated on