IP Address Script

I’m finishing up a new box for my parents. Neither of them know much about computers, and they love to call me the second they see a pop-up on the web they’ve never seen before, let alone real problems.

I use VNC at work and love it. I’ve never actually tried to use VNC outside of a domain, where I can use hostnames and such. In theory, I assume I can use VNC across the internet to my folk’s PC with their IP address. They don’t use a router. They connect directly to a DSL modem.

The thing is their ISP gives them a dynamic IP address. Can someone suggest a rather simple script that I can trigger from a shortcut on their desktop that will pop-up with their current IP address?

That way they can call me, give me their IP, and then I can VNC into their box?

Why not register their machine with a dynamic IP registrar? Then you don’t have to ask them.

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

I wrote one of these a while ago that would poll my cable/dsl/whatever
device for whatever it thought its IP address was. Doing something
simple like this depends a little on your setup but there are a couple
ways. First keep in mind that having a box right on the Internet is
risky even with a decent OS like Linux. Opening a VNC port directly is
also risky as they are scanned-for often. If possible I would setup a
router that had the IP address and no open ports and then forward some
random high port to your parents’ box’s VNC port. With that in mind…

How to get an IP address. Have a cron job run regularly and:

  1. Poll the system’s IP address (ifconfig, ip addr sh, etc.).

  2. Access a webpage such as ‘whatismyip.com’ or your router/modem’s
    webpage and parse the page for the IP address which is trivial to do in
    most scripting languages.

Once you have this information you can either have it e-mail to you
automatically, write to a file on the hard drive that can be opened as
needed to see what the last iteration found for the IP address, or
possibly process more. If you plan to have it e-mail you regularly you
may want the interval between runs to be lower so you don’t get 1440
e-mails per day with an IP address. On the other hand I wrote a script
once that write the last iteration’s IP address to a file made for that
purpose and compared the IP in that file to the current IP and sent me
an e-mail only when the IP changed. I ended up getting an e-mail every
week or so but sometimes more often. I was able to run the script once
per minute so I was always up to date just in case I needed access right
after a change and the overhead for this is really low.

You could also write a script with an icon on the desktop that they can
run when they need to so they can read the output to you as needed. For
that matter you could have them browse to whatismyip.com which prints it
in huge letters on the screen (assuming their browser is working, their
connection is up, etc.). Bookmarking the page or just reading them the
website URL may also work if your parents are up to that.

The simplest version to have run by cron could look like:

ip addr sh | mail -s ‘Parent Computer IP Address’ you@yourdomain.tld

Good luck.

enderandrew wrote:
| I’m finishing up a new box for my parents. Neither of them know much
| about computers, and they love to call me the second they see a pop-up
| on the web they’ve never seen before, let alone real problems.
|
| I use VNC at work and love it. I’ve never actually tried to use VNC
| outside of a domain, where I can use hostnames and such. In theory, I
| assume I can use VNC across the internet to my folk’s PC with their IP
| address. They don’t use a router. They connect directly to a DSL
| modem.
|
| The thing is their ISP gives them a dynamic IP address. Can someone
| suggest a rather simple script that I can trigger from a shortcut on
| their desktop that will pop-up with their current IP address?
|
| That way they can call me, give me their IP, and then I can VNC into
| their box?
|
|
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.2 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iD8DBQFIVHvR3s42bA80+9kRAiapAKCLLAaXSHnJsRByd9zHeZMOQwWBZgCfUo79
6k1bh55LjfEUyHzn4CDYlZ0=
=o3rj
-----END PGP SIGNATURE-----

If you want to do it without dyndns, another way is if you run some public service, perhaps not on your machine, but on a hosted one, and then get their machine to regularly fetch a URL from your service, using wget, curl, what have you. This URL could be a cgi-bin that records the source IP. This will be their gateway, not their internal IP.

The cgi-bin doesn’t even have to exit without error, it could exit with a server error, looking like a broken page to anybody else.

I think the simplest solution will be to just put a shortcut to What Is My IP Address? - IP Address Lookup, Info, Speed Test, and more on the desktop. I don’t know what I didn’t just think of that first. But thanks for all the suggestions!

enderandrew wrote:
>
> I think the simplest solution will be to just put a shortcut to ‘What Is
> My IP Address? - IP Address Lookup, Info, Speed Test, and more’
> (http://whatismyip.com) on the desktop. I don’t know what I didn’t
> just think of that first. But thanks for all the suggestions!

I asume you want to let your parents tell you what the IP is when they
have a problem.
If this is all you want and can’t be botherd with anything else, use
http://whatismyip.org/ instead of http://whatismyip.com Then all you get
is the IP adress.

You could easily put that in a script if need be:
lynx -dump whatismyip.org
That way if you run GNOME, you can link to the following:
zenity --info --text=lynx -dump whatismyip.org
For KDE there is kdialog

Now if you need that IP to access the PC, a better way would be to use
DynDNS. That way you can just contact e.g. ssh [email]user@example.ath.cx[/email].
http://www.dyndns.com/services/dns/dyndns/

Look at the modem. There are modems that have the ability build in to
connect to DynDNS directly. That would save you some time. Otherwise use
one of the programs available in openSUSE to do that configuration for
you.

In the end this will take away some irritation.

houghi

This was written under the influence of the following:
| Artist : Jimi Hendrix
| Song : I Don’t Lilve Today Takes 1-4
| Album : Astro Man - Studio Outtakes