Warning: Undefined array key "force_rev" in /home/fresoehv/wiki/lib/plugins/publish/action/start.php on line 37
Warning: Cannot modify header information - headers already sent by (output started at /home/fresoehv/wiki/lib/plugins/publish/action/start.php:37) in /home/fresoehv/wiki/inc/actions.php on line 42
Warning: Cannot modify header information - headers already sent by (output started at /home/fresoehv/wiki/lib/plugins/publish/action/start.php:37) in /home/fresoehv/wiki/lib/tpl/mindthedark/main.php on line 12 ip_script [FreshTomato Wiki]
Determine external IP for all MultiWAN interfaces and log to file
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
ip_script.txt · Last modified: 2024/10/31 21:36 by hogwild