Finding out IP Address behind NAT

Finding out IP Address behind NAT

am 16.01.2008 04:04:17 von KDawg44

Hi,

I am writing a PHP app for a small business (family member owes me
after this...) but they need to get their box back before I am
finished. They have a DSL with dynamic ip and I need to be able to
SSH in to their box, so I need to write a script that i have run as a
cron job that will email me the current public IP of their DSL modem
(as it will change). I am not sure the best way to go about this....
I was hoping someone could give me a suggestion of a PHP script....

Thanks for any help.

Re: Finding out IP Address behind NAT

am 16.01.2008 04:06:31 von Jerry Stuckle

KDawg44 wrote:
> Hi,
>
> I am writing a PHP app for a small business (family member owes me
> after this...) but they need to get their box back before I am
> finished. They have a DSL with dynamic ip and I need to be able to
> SSH in to their box, so I need to write a script that i have run as a
> cron job that will email me the current public IP of their DSL modem
> (as it will change). I am not sure the best way to go about this....
> I was hoping someone could give me a suggestion of a PHP script....
>
> Thanks for any help.
>
>

Don't make it hard on yourself. Check out one of the free dynamic IP
name servers such as dyndns.org.

BTW, there's a good possibility you won't be able to SSH to their box,
but that's not a PHP problem.

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex@attglobal.net
==================

Re: Finding out IP Address behind NAT

am 16.01.2008 04:15:53 von Daniel Ennis

Jerry Stuckle wrote:
> KDawg44 wrote:
>> Hi,
>>
>> I am writing a PHP app for a small business (family member owes me
>> after this...) but they need to get their box back before I am
>> finished. They have a DSL with dynamic ip and I need to be able to
>> SSH in to their box, so I need to write a script that i have run as a
>> cron job that will email me the current public IP of their DSL modem
>> (as it will change). I am not sure the best way to go about this....
>> I was hoping someone could give me a suggestion of a PHP script....
>>
>> Thanks for any help.
>>
>>
>
> Don't make it hard on yourself. Check out one of the free dynamic IP
> name servers such as dyndns.org.
>
> BTW, there's a good possibility you won't be able to SSH to their box,
> but that's not a PHP problem.
>

If you do want to do it as cronjob as you said, you could do http
request on many of the free online ip address displayer's and parse the
IP out of it.

--
Daniel Ennis
faNetworks.net - Quality Web Hosting and Ventrilo Services
System Administrator / Web Developer
PHP Developer for 6 years
daniel@fanetworks.net

Re: Finding out IP Address behind NAT

am 16.01.2008 12:17:29 von Courtney

KDawg44 wrote:
> Hi,
>
> I am writing a PHP app for a small business (family member owes me
> after this...) but they need to get their box back before I am
> finished. They have a DSL with dynamic ip and I need to be able to
> SSH in to their box, so I need to write a script that i have run as a
> cron job that will email me the current public IP of their DSL modem
> (as it will change). I am not sure the best way to go about this....
> I was hoping someone could give me a suggestion of a PHP script....
>
> Thanks for any help.
>
You say cron job - that implies *nix.

Why not write it in shell, and just add a line saying 'mail'

Getting the IP address is trickier: need to interrogate their NAT router.

Thats probably going to be a telnet script or SNMP.

I THINK ther are snmp tools for Linux..

None of this has to do with PHP

Re: Finding out IP Address behind NAT

am 16.01.2008 14:06:08 von Toby A Inkster

The Natural Philosopher wrote:

> Getting the IP address is trickier: need to interrogate their NAT
> router.

Only if they use NAT. If the machine is directly routed, here's a quick
way of determining the IP address from the command line:

/sbin/ifconfig eth0 | grep -o "inet addr:[0-9\.]*" | sed 's/[^0-9\.]//g'

Where "eth0" is the interface (i.e. network card or virtual network card)
to check.

--
Toby A Inkster BSc (Hons) ARCS
[Geek of HTML/SQL/Perl/PHP/Python/Apache/Linux]
[OS: Linux 2.6.17.14-mm-desktop-9mdvsmp, up 17 days, 6 min.]

Gnocchi all'Amatriciana al Forno
http://tobyinkster.co.uk/blog/2008/01/15/gnocchi-allamatrici ana/

Re: Finding out IP Address behind NAT

am 16.01.2008 14:30:24 von colin.mckinnon

On 16 Jan, 11:17, The Natural Philosopher wrote:
> KDawg44 wrote:
> > Hi,
>
> > I am writing a PHP app for a small business (family member owes me
> > after this...) but they need to get their box back before I am
> > finished. They have a DSL with dynamic ip and I need to be able to
> > SSH in to their box, so I need to write a script that i have run as a
> > cron job that will email me the current public IP of their DSL modem
> > (as it will change). I am not sure the best way to go about this....
> > I was hoping someone could give me a suggestion of a PHP script....
>
> > Thanks for any help.
>
> You say cron job - that implies *nix.
>
> Why not write it in shell, and just add a line saying 'mail'
>
> Getting the IP address is trickier: need to interrogate their NAT router.
>
> Thats probably going to be a telnet script or SNMP.
>
> I THINK ther are snmp tools for Linux..
>
> None of this has to do with PHP

If it is a Unix script - then you'll find that most DHCP clients allow
you to hang a script off lease renewals - which is a far batter way of
doing it than using cron (but this is getting way OT) Try asking on a
newsgroup related to your OS for specifics.

C.

Re: Finding out IP Address behind NAT

am 16.01.2008 23:49:08 von Guillaume Dargaud

>> Don't make it hard on yourself. Check out one of the free dynamic IP
>> name servers such as dyndns.org.

Yup. And there are models of Adsl modems that will do automated dyndns
updates (you don't even need a dyndns updater on the PC).

> If you do want to do it as cronjob as you said, you could do http request
> on many of the free online ip address displayer's and parse the IP out of
> it.

For instance in cron I use:
/bin/wget -q -O - http://www.whatismyip.com/automation/n09230945.asp
No filtering necessary
--
Guillaume Dargaud
http://www.gdargaud.net/
"Military solutions are problems."

Re: Finding out IP Address behind NAT

am 17.01.2008 12:50:49 von Courtney

Toby A Inkster wrote:
> The Natural Philosopher wrote:
>
>> Getting the IP address is trickier: need to interrogate their NAT
>> router.
>
> Only if they use NAT.

Look at the title of this post, numbskull.
"Finding out IP Address behind NAT"

Re: Finding out IP Address behind NAT

am 17.01.2008 12:51:33 von Courtney

Guillaume Dargaud wrote:
>>> Don't make it hard on yourself. Check out one of the free dynamic IP
>>> name servers such as dyndns.org.
>
> Yup. And there are models of Adsl modems that will do automated dyndns
> updates (you don't even need a dyndns updater on the PC).
>
>> If you do want to do it as cronjob as you said, you could do http request
>> on many of the free online ip address displayer's and parse the IP out of
>> it.
>
> For instance in cron I use:
> /bin/wget -q -O - http://www.whatismyip.com/automation/n09230945.asp
> No filtering necessary

That's an even neater trick.

Re: Finding out IP Address behind NAT

am 17.01.2008 13:17:28 von Toby A Inkster

The Natural Philosopher wrote:
> Toby A Inkster wrote:
>
>> Only if they use NAT.
>
> Look at the title of this post, numbskull. "Finding out IP Address
> behind NAT"

Yeah, I only noticed the title of the thread after posting. The body of
the OP's message didn't mention NAT at all.

Nonetheless the technique which you snipped is fairly useful for people
who need to determine the IP address of a machine where NAT is not a
consideration:

/sbin/ifconfig eth0 | grep -o "inet addr:[0-9\.]*" | sed 's/[^0-9\.]//g'

--
Toby A Inkster BSc (Hons) ARCS
[Geek of HTML/SQL/Perl/PHP/Python/Apache/Linux]
[OS: Linux 2.6.17.14-mm-desktop-9mdvsmp, up 17 days, 23:28.]

Gnocchi all'Amatriciana al Forno
http://tobyinkster.co.uk/blog/2008/01/15/gnocchi-allamatrici ana/

Re: Finding out IP Address behind NAT

am 17.01.2008 17:34:37 von Courtney

Toby A Inkster wrote:
> The Natural Philosopher wrote:
>> Toby A Inkster wrote:
>>
>>> Only if they use NAT.
>> Look at the title of this post, numbskull. "Finding out IP Address
>> behind NAT"
>
> Yeah, I only noticed the title of the thread after posting. The body of
> the OP's message didn't mention NAT at all.
>
> Nonetheless the technique which you snipped is fairly useful for people
> who need to determine the IP address of a machine where NAT is not a
> consideration:
>
> /sbin/ifconfig eth0 | grep -o "inet addr:[0-9\.]*" | sed 's/[^0-9\.]//g'
>
Sure, but so what? its a trivial excercise to find out the configured IP
address on any machine.

Re: Finding out IP Address behind NAT

am 17.01.2008 17:47:10 von Captain Paralytic

On 16 Jan, 03:06, Jerry Stuckle wrote:
> KDawg44 wrote:
> > Hi,
>
> > I am writing a PHP app for a small business (family member owes me
> > after this...) but they need to get their box back before I am
> > finished. They have a DSL with dynamic ip and I need to be able to
> > SSH in to their box, so I need to write a script that i have run as a
> > cron job that will email me the current public IP of their DSL modem
> > (as it will change). I am not sure the best way to go about this....
> > I was hoping someone could give me a suggestion of a PHP script....
>
> > Thanks for any help.
>
> Don't make it hard on yourself. Check out one of the free dynamic IP
> name servers such as dyndns.org.
>
> BTW, there's a good possibility you won't be able to SSH to their box,
> but that's not a PHP problem.
>
> --
> ==================
> Remove the "x" from my email address
> Jerry Stuckle
> JDS Computer Training Corp.
> jstuck...@attglobal.net
> ==================

I use noip.com for a similar service.