Submit Hint Search The Forums LinksStatsPollsHeadlinesRSS
14,000 hints and counting!

Yet another way to get a remote IP address Network
I have a machine at work and one at home (common problem, yes?) and I want to access the one at work from home via VNC. Well, to properly use that I need to login to the VPN and then login to the remote machine -- but I need to know the IP address, and since we use dynamic addressing, you know the rest.

I saw a whole bunch of scripts here for how to have your PowerBook phone home, but they didn't cut it -- too complex and ultimately not what I needed. So I made this simple script:
#Script name: writeip
# Get my Ethernet Adapter IP Address
# And write it to a file
ipconfig getifaddr en0 > ~/Desktop/IP.txt
# Copy that file to my iDisk
cp ~/Desktop/IP.txt /Volumes/<idiskname>/Documents/IP.txt
If I make sure that my iDisk is set to automatically mount on login (using login items you can select a volume to automatically mount), then this script will get my IP address, write it to a file, then copy that file to my iDisk. Simple enough for what I needed. I then set up cron (using Cronnix) to run the script hourly to make sure my IP is current.

[robg adds: Note that this method will return the machine's internal IP address, which won't be its public IP address if you're using a router, for example. Since the author is first connecting to a VPN, this works, as he can then access the machine via its internal IP. If you need the remote machine's public IP (if you're connecting from work to home, for instance, and you have a router at the house), then you'll need to use one of these hints.]
  • Currently 1.00 / 5
  You rated: 1 / 5 (2 votes cast)

Yet another way to get a remote IP address | 2 comments | Create New Account
Click here to return to the 'Yet another way to get a remote IP address' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
Yet another way to get a remote IP address
Authored by: tallest on Sep 13, '06 11:31:23AM
I have a linux box at home (with a dynamic IP) and some webspace at school so I just put this script in /etc/cron.hourly/ (this may be different depending on what variety of cron you use):

wget -O /root/ip -q

if [[ -e /root/ip ]]; then
        scp /root/ip  
Note that you will need to have root be able to scp to the other machine without requiring a password (rsa or dsa authentication). I also set it up so that the site at school is password protected so not just anyone can look at my home IP.

[ Reply to This | # ]
Yet another way to get a remote IP address
Authored by: tallest on Sep 13, '06 11:35:02AM
Also, note that this hint will not give you your external IP if you are behind a router of any kind, that's why I have to use the site to find my external IP (I have my router forward port 22 (ssh) to my linux box).

[ Reply to This | # ]