This script will discover the WAN IP of all WAN interfaces in a MultiWAN configuration and log them in the file: “/tmp/WAN-IPs” :
#!/bin/sh WAN="$(nvram get wan_ifname)" WAN2="$(nvram get wan2_ifname)" WAN3="$(nvram get wan3_ifname)" WAN4="$(nvram get wan4_ifname)" if [ "$WAN" != "" ] then if [ "$(ifconfig $WAN | grep -q UP; echo $?)" == "0" ] then echo "WAN IP address: $(curl -s --interface $WAN http://ipinfo.io/ip)"> /tmp/WAN-IPs else echo "WAN IP address: DOWN"> /tmp/WAN-IPs fi fi if [ "$WAN2" != "" ] then if [ "$(ifconfig $WAN2 | grep -q UP; echo $?)" == "0" ] then echo "WAN2 IP address: $(curl -s --interface $WAN2 http://ipinfo.io/ip)">> /tmp/WAN-IPs else echo "WAN2 IP address: DOWN">> /tmp/WAN-IPs fi fi if [ "$WAN3" != "" ] then if [ "$(ifconfig $WAN3 | grep -q UP; echo $?)" == "0" ] then echo "WAN3 IP address: $(curl -s --interface $WAN3 http://ipinfo.io/ip)">> /tmp/WAN-IPs else echo "WAN3 IP address: DOWN">> /tmp/WAN-IPs fi fi if [ "$WAN4" != "" ] then if [ "$(ifconfig $WAN4 | grep -q UP; echo $?)" == "0" ] then echo "WAN4 IP address: $(curl -s --interface $WAN4 http://ipinfo.io/ip)">> /tmp/WAN-IPs else echo "WAN4 IP address: DOWN">> /tmp/WAN-IPs fi fi