Getting my external IP

About a week ago I lost port forwarding on my home network. I didn’t change anything but my webcam suddenly became invisible from outside.

I checked the settings and discovered that services like canyouseeme.org and portchecker.co report a different external IP than the one shown in my router’s status page. If I try to connect to my machines with the IP reported by the router forwarding works again.

For webcam I use an externally hosted page which I update with my current external IP every time the cam starts. To get this IP I use


ip=$(dig +short myip.opendns.com @resolver1.opendns.com)

in bash and it reports a different IP from the router (and same as canyouseeme.org). My provider must have changed something in their setup and there’s zero chance that they’ll reverse their policy simply because I call them.

How can I find my actual external IP without manually going to the router’s page and getting it from there? I don’t think it accepts SSH connections, there’s only

"Remote Config Management Enable"

in options without specifying what to do with it next.

If I run traceroute my actual IP doesn’t appear anywhere in the output.

IMHO this all depends very much on the make/type of your router and the policy/features of your ISP.

I e.g. can see the IPv4 and IPv6 addresses on the Internet side of my router by simply logging in in the HTTP mangament interface of it.

Also, my ISP allows me to have a hostname (with their domainname) registered in DNS. Thus

host myhost.myprovidersdomain

wil give me the IP address.

As I said earlier, i don’t think my router allows for ssh connections and I have no influence over ISP’s policies. Is there a way to find my external IP from the “inside” and without manually logging into the router?

I’ve seen a python script logging into the router, getting the page with assigned IP and then parsing it to extract the address. I can try to make that work in my case but I’m no good at python. There’s also “ip neighbor” command that shows correct external IP among other information and I can parse that in bash, but, confusingly, the machine with webcam attached does not contain that line even if it’s connected via ethernet just the same.

if you do


wget whatsmyip.com

you’ll get a file index.html. It has a SetCookie line which contains your external IP.

Am Wed, 26 Oct 2016 11:36:01 GMT
schrieb Knurpht <Knurpht@no-mx.forums.microfocus.com>:

> if you do
>
> Code:
> --------------------
>
> wget whatsmyip.com
>
> --------------------
> you’ll get a file index.html. It has a SetCookie line which contains
> your external IP.
>
>

Well, then let me drop a little bash script I use:

#!/bin/bash

echo External IP: $(curl -s http://checkip.dyndns.org/ | sed ‘s/[a-zA-Z<>/ :]//g’)

case $1 in
-ip|-i|–ip)
echo $(wget -q -O - http://checkip.dyndns.org/ | sed ‘s/[a-zA-Z<>/ :]//g’)
;;
-h|-help|–help)
echo “${0##/} -i|-ip|–ip - show external IP only"
echo
echo "${0##
/} -h|-help|–help - show this help message”
echo
echo “If called without any extra arguments, ${0##*/} will show”
echo “external IP and actual date+time”
;;
*)
echo $(date) |tr ’
’ ’ ’
echo External IP: $(wget -q -O - http://checkip.dyndns.org/ | sed ‘s/[a-zA-Z<>/ :]//g’)
;;
esac

exit 0

The commented line at the top is a drop-in replacement if you want to use
curl instead of wget.

AK


Never attribute to malice that which can be adequately explained by stupidity.
(R.J. Hanlon)

Nice, adding that to my collection.

Earlier I said that external IP shown on my router’s page works. I was wrong - it works only when used by devices on the same network. That IP is not in the 192.168.2… range so I thought it was “external” but it isn’t. I tried accessing it from mobile phone (with wifi turned off) and got nothing.

The IP reported by canyouseeme and the likes, including the last two suggestions in this thread, does not work either. No ports get forwarded and no ports are reported as open.

Everything was fine just a week ago…

On Wed, 26 Oct 2016 15:46:01 +0000, Stan Ice wrote:

> Earlier I said that external IP shown on my router’s page works. I was
> wrong - it works only when used by devices on the same network. That IP
> is not in the 192.168.2… range so I thought it was “external” but it
> isn’t. I tried accessing it from mobile phone (with wifi turned off) and
> got nothing.
>
> The IP reported by canyouseeme and the likes, including the last two
> suggestions in this thread, does not work either. No ports get forwarded
> and no ports are reported as open.
>
> Everything was fine just a week ago…

Even though you don’t have control over your ISP, you might contact them
to see what changed - it’s possible that something changed in their
network and they for some reason aren’t aware of it.

As for pulling it from the router, a python script using mechanize could
do this, but creating such a script would require someone with knowledge
of python and access to your router (or a router with the same firmware)
in order to test it.

You might also check with the router manufacturer to see if they have a
way to programmatically get the external address from the router.

Another option would be to see if your router is supported by OpenWRT, DD-
WRT, or Tomato, which would let you ssh in to extract the address.

Jim


Jim Henderson
openSUSE Forums Administrator
Forum Use Terms & Conditions at http://tinyurl.com/openSUSE-T-C

Hi,

Just a note on the script about getting the external ip, here is my awk version :slight_smile:

curl -s http://checkip.dyndns.org/ | awk -F'[a-zA-Z<>/ :]+' '{printf "External IP: %s
", $2}'
wget -q -O - http://checkip.dyndns.org/ | awk -F'[a-zA-Z<>/ :]+' '{printf "External IP: %s
", $2}'

Hi,

Also if i remember correctly there was DDOs that targeted large tech companies last Friday that involves webcams so there might be some new security protocols that are being implemented.

http://thehackernews.com/2016/10/ddos-attack-mirai-iot.html

The matter was resolved on ISP end, their technician said something about them running out of IP addresses to give and so customers who want port forwarding have to request their router’s IP being moved from behind their “proxy” or whatever they used. After doing that the IP reported by the router now matches the IP reported by outside services.

Jetchisel, I don’t think recent DDOS attack had anything to do with it but it’s a nice reminder that the world outside is dangerous. Also curl and wget scripts only get the IP of the “proxy”, not my router’s. It’s the same IP I get with dig command mentioned in the OP.