Site Tools


ip_script

Differences

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

Link to this comparison view

Next revision
Previous revision
ip_script [2020/08/20 09:19] – created seanbip_script [2023/05/28 05:47] (current) 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 ======
  
----------------------------------------------------------+\\
  
 +This script will discover the WAN IP of all WAN interfaces in a MultiWAN configuration and log them in the file: "/tmp/WAN-IPs" :\\ \\ \\
 +
 +<code ->
 #!/bin/sh #!/bin/sh
 WAN="$(nvram get wan_ifname)" WAN="$(nvram get wan_ifname)"
Line 8: Line 11:
 WAN3="$(nvram get wan3_ifname)" WAN3="$(nvram get wan3_ifname)"
 WAN4="$(nvram get wan4_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.1597911549.txt.gz · Last modified: 2020/08/20 09:19 by seanb