-1

I have a OS X Server behind an airport extreme, serving services via opened ports on the airport.

The server has a 10.0.x.x local address, always the same one. The airport extreme gets it's external IP address via PPPoE, and sometimes... once a week it changes.

For security reasons WE ACTUALLY like this behavior. But i need a way to know the external IP address just in case i need to connect and do something to the server while on the outside.

What can i do?

unom
  • 281
  • 5
  • 13
  • This "airport extreme" is in a role of a WLAN-router, right? So your OS-X-Server is connected via WLAN and gets his IP from just this router? – Nils Oct 27 '12 at 20:16
  • Can you use an SNMP client to fetch the current addresses from the router? 1.3.6.1.2.1.4.20.1.1 is the OID for ipAdEntAddr: if you walk it using `snmpwalk` or a similar tool it should give you all addresses assigned to the router. You can pick out the dynamic address by removing the known static addresses. – aecolley Oct 27 '12 at 21:00
  • @Nils yes... it's a wlan router and has a reservation with a fixed internal ip for the server. – unom Oct 27 '12 at 21:09
  • 1
    See http://serverfault.com/questions/89114/finding-the-public-ip-address-in-a-shell-script – Zoredache Oct 28 '12 at 00:30

4 Answers4

6

Get a Dynamic DNS service. There are many such services available from various places on the Internet...

Michael Hampton
  • 237,123
  • 42
  • 477
  • 940
  • It is the router that changes - not the server. Strange scenario, though. And they seem to make security by obscurity. – Nils Oct 27 '12 at 20:17
  • That's completely irrelevant. – Michael Hampton Oct 27 '12 at 20:22
  • @Nils "security by obscurity" is one of the best one-liners in a long time, but yes our company has used this in the past... server is under enemy fire... reconnect... can't attack something that's not there. My thoughts on the method is to run a cron job or something every 2 hours or so... with a trace route to say google and have this sent via e-mail to the admin. From time to time when he wants to check in he just looks at the most recent mail. – unom Oct 27 '12 at 21:12
  • In the end i ended up using easydns.com they have a native mac update client and everything works... nice. – unom Nov 08 '12 at 12:26
4

The site I use for exactly this behaviour is ifconfig.me. This can return data in any format you might want to use. E.g. In a bash script where you just want the ip:

IP=`curl http://ifconfig.me/ip`

Of course, you'll want to check the return code in case something goes wrong. It does seem quite robust for scripting, though.

Morphit
  • 226
  • 1
  • 7
3
  1. Open browser.
  2. Visit a website that tells you your IP address.
  3. Script into periodic job for best results.

Alternately, buy a static IP address, but if you just need to know occasionally/just in case, that's how you'd do it. And make sure you set up IPv6/NAT/port-forwarding so the connection actually goes to the server when it hits the gateway.

To quote @MichaelHampton:

Have you deployed IPv6 yet? I'm getting sick of this NAT shit.

HopelessN00b
  • 53,385
  • 32
  • 133
  • 208
  • Your post gave me a "new" idea. Use "back to my mac" to get to the server screen, check ip via a website from there. Brilliant. I'll try that next time i'm onsite. – unom Oct 27 '12 at 21:15
1

You can set up a cron job to perform the following script:

#!/bin/bash

TIME='date' $TIME
IP='curl http://ifconfig.me/ip' $IP
echo $TIME - $IP >> ~/iplogging.txt

This will output the timestamp and IP at the time the script is ran and log it to ~/iplogging.txt.

rwc
  • 316
  • 1
  • 7