Site Tools


ip_script

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
Last revisionBoth sides next revision
ip_script [2020/08/20 09:20] seanbip_script [2023/05/28 05:46] – -format hogwild
Line 1: Line 1:
-This script will discover the WAN IP of each WAN interface in a MultiWAN configuration and log them in /tmp/WAN-IPs.+====== Determine external IP for all MultiWAN interfaces and log to file ======
  
----------------------------------------------------------+\\
  
-  #!/bin/sh +This script will discover the WAN IP of all WAN interfaces in a MultiWAN configuration and log them in the file: "/tmp/WAN-IPs. \\ \\ \\
-  WAN="$(nvram get wan_ifname)" +
-  WAN2="$(nvram get wan2_ifname)" +
-  WAN3="$(nvram get wan3_ifname)" +
-  WAN4="$(nvram get wan4_ifname)"+
  
 +<code ->
 +#!/bin/sh
 +WAN="$(nvram get wan_ifname)"
 +WAN2="$(nvram get wan2_ifname)"
 +WAN3="$(nvram get wan3_ifname)"
 +WAN4="$(nvram get wan4_ifname)"
  
 if [ "$WAN" != "" ] if [ "$WAN" != "" ]
Line 14: Line 16:
    if [ "$(ifconfig $WAN | grep -q UP; echo $?)" == "0" ]    if [ "$(ifconfig $WAN | grep -q UP; echo $?)" == "0" ]
     then     then
-      echo "WAN IP address: $(curl -s --interface $WAN http://ipinfo.io/ip)" > /tmp/WAN-IPs+      echo "WAN IP address: $(curl -s --interface $WAN http://ipinfo.io/ip)"> /tmp/WAN-IPs
     else     else
-      echo "WAN IP address: DOWN" > /tmp/WAN-IPs+      echo "WAN IP address: DOWN"> /tmp/WAN-IPs
    fi    fi
 fi fi
Line 24: Line 26:
    if [ "$(ifconfig $WAN2 | grep -q UP; echo $?)" == "0" ]    if [ "$(ifconfig $WAN2 | grep -q UP; echo $?)" == "0" ]
     then     then
-      echo "WAN2 IP address: $(curl -s --interface $WAN2 http://ipinfo.io/ip)" >> /tmp/WAN-IPs+      echo "WAN2 IP address: $(curl -s --interface $WAN2 http://ipinfo.io/ip)">> /tmp/WAN-IPs
     else     else
-      echo "WAN2 IP address: DOWN" >> /tmp/WAN-IPs+      echo "WAN2 IP address: DOWN">> /tmp/WAN-IPs
    fi    fi
 fi fi
Line 34: Line 36:
    if [ "$(ifconfig $WAN3 | grep -q UP; echo $?)" == "0" ]    if [ "$(ifconfig $WAN3 | grep -q UP; echo $?)" == "0" ]
     then     then
-      echo "WAN3 IP address: $(curl -s --interface $WAN3 http://ipinfo.io/ip)" >> /tmp/WAN-IPs+      echo "WAN3 IP address: $(curl -s --interface $WAN3 http://ipinfo.io/ip)">> /tmp/WAN-IPs
     else     else
-      echo "WAN3 IP address: DOWN" >> /tmp/WAN-IPs+      echo "WAN3 IP address: DOWN">> /tmp/WAN-IPs
    fi    fi
 fi fi
Line 44: Line 46:
    if [ "$(ifconfig $WAN4 | grep -q UP; echo $?)" == "0" ]    if [ "$(ifconfig $WAN4 | grep -q UP; echo $?)" == "0" ]
     then     then
-      echo "WAN4 IP address: $(curl -s --interface $WAN4 http://ipinfo.io/ip)" >> /tmp/WAN-IPs+      echo "WAN4 IP address: $(curl -s --interface $WAN4 http://ipinfo.io/ip)">> /tmp/WAN-IPs
     else     else
-      echo "WAN4 IP address: DOWN" >> /tmp/WAN-IPs+      echo "WAN4 IP address: DOWN">> /tmp/WAN-IPs
    fi    fi
 fi fi
 +</code>
 +
 + \\
 +
 + \\
 +
 +----
 +
  
---------------------------------------------------------- 
ip_script.txt · Last modified: 2023/05/28 05:47 by hogwild