O
O
Oleg Krasnov2016-09-30 01:33:02
bash
Oleg Krasnov, 2016-09-30 01:33:02

How to find WAN IP WiFi points without using ssh/telnet?

There is this bash code:

myip() {
    local intIP=$(ssh [email protected] 'ifconfig ppp0 | grep inet | awk '"'"'{gsub("addr:", "", $2); print $2}'"'"'')
    local extIP=$(curl -s icanhazip.com)
    local pattern='[0-9][0-9]*\.[0-9][0-9]*\.[0-9][0-9]*\.[0-9][0-9]*$'

    if expr "$intIP" : "$pattern" >/dev/null; then
      if expr "$extIP" : "$pattern" >/dev/null; then
        if [ "$extIP" != "$intIP" ]; then
          echo "$intIP - grey IP"
        else
          echo "$intIP - white IP"
        fi
      fi
    fi
  }

intIP - gets WAN IP from WiFi via ssh, extIP - from the site.
Is there a way to find out the WiFi WAN IP without using ssh/telnet? I don’t want to enter a password every time, but something doesn’t work with the dropbear key.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
V
Vladimir, 2016-09-30
@MechanID

If the router allows, try polling it via snmp, it's easy to get the information you need via snmpwalk or snmpget

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question