Koozali.org: home of the SME Server

Display servers wan ip on primary web page

Offline gbentley

  • ****
  • 482
  • +0/-0
  • Forum Lurker
    • Earth
Re: Display servers wan ip on primary web page
« Reply #15 on: March 18, 2009, 08:02:21 AM »
http://whatismyip.com/ will reveal your adsl WAN side IP address (IP address assigned by your ISP).

OK, the original question: I needed the sme webserver to display a page _that I can access remotely from another location_ - that will display the wan ip of the network that the sme is on - *not my* wan ip.

whatismyip etc wont help - and most php I have seen / tried only derives the referrers wan ip (ie the wan ip of the browser making that request)

I have also seen alot of other linux commands to derive the wan ip but this has to be done as root. Plus I am no coder so wouldnt even be able to attempt to write a Perl script that could write out to an html page on the fly!

However ... screen scraping this url http://dynupdate.no-ip.com/ip.php may be an
answer if I can figure out the right php - so thanks for that!
« Last Edit: March 18, 2009, 08:11:42 AM by gbentley »
"If you don't know what you want, you end up with a lot you don't."

Offline Stefano

  • *
  • 10,839
  • +2/-0
Re: Display servers wan ip on primary web page
« Reply #16 on: March 18, 2009, 08:26:15 AM »
gbentley..

you could create a cron script that:
- call http://whatismyip.com/ or http://checkip.dyndns.org/ and download the page (something like wget http://checkip.dyndns.org/)
- grep the ip from html code
- then write the ip in a inclusion file that you can use in your page.. THAT ip will be, for sure, your WAN ip..

you could use perl regexp to grep ip from html, I've found some example googling a bit.

HTH
Ciao
Stefano

Offline gbentley

  • ****
  • 482
  • +0/-0
  • Forum Lurker
    • Earth
Re: Display servers wan ip on primary web page
« Reply #17 on: March 18, 2009, 08:56:13 AM »
Thanks for answers etc ; from Thomas idea this works on my own 3bds server but not on sme - guess its to do with php setup ;

<?
$url = "http://dynupdate.no-ip.com/ip.php";
$raw = file_get_contents($url);
echo "{$raw}";
?>

Anyway, as Mary stated ; PuTTY, WinSCP and MS PPTP Client all work fine with DynDNS 'hostname' !

"If you don't know what you want, you end up with a lot you don't."

Offline Stefano

  • *
  • 10,839
  • +2/-0
Re: Display servers wan ip on primary web page
« Reply #18 on: March 18, 2009, 09:01:05 AM »
Thanks for answers etc ; from Thomas idea this works on my own 3bds server but not on sme - guess its to do with php setup ;
Code: [Select]
<?
$url = "http://dynupdate.no-ip.com/ip.php";
$raw = file_get_contents($url);
echo "{$raw}";
?>

Anyway, as Mary stated ; PuTTY, WinSCP and MS PPTP Client all work fine with DynDNS 'hostname' !


please use the "code" block.. otherwise part of your post will be invisible :)
EDIT: strange enough, now I can see your last sentence...

are you getting any error with php on SME?

Ciao
Stefano
any error reference?

Offline gbentley

  • ****
  • 482
  • +0/-0
  • Forum Lurker
    • Earth
Re: Display servers wan ip on primary web page
« Reply #19 on: March 18, 2009, 09:06:17 AM »
No, just no output from php at all!
"If you don't know what you want, you end up with a lot you don't."

Offline janet

  • ****
  • 4,812
  • +0/-0
Re: Display servers wan ip on primary web page
« Reply #20 on: March 18, 2009, 11:03:56 AM »
gbentley

Quote
..as Mary stated ; PuTTY, WinSCP and MS PPTP Client all work fine with DynDNS 'hostname' !

Yes the need to know the IP is no longer as VPN is now working.

Another approach (if using a gateway server) is to run a cron job eg

55,56,57,58,59,00  20 * * * root /sbin/e-smith/db configuration getprop ExternalInterface IPAddress
Please search before asking, an answer may already exist.
The Search & other links to useful information are at top of Forum.

Offline Jáder

  • *
  • 1,099
  • +0/-0
    • LinuxFacil
Re: Display servers wan ip on primary web page
« Reply #21 on: March 18, 2009, 01:01:12 PM »
I create a "new" command on all new servers, it's something like this (from memory!):

Code: [Select]
---  /usr/bin/ipconfig ---

#/bin/bash
lynx --dump www.whatismyip.com |grep "Your IP is"

--- end of usr/bin/ipconfig ---

this should show you external IP address. Of course you can put this on a shell variable and use it on HTTP page. Google for help about this.

Jáder
...

Offline gbentley

  • ****
  • 482
  • +0/-0
  • Forum Lurker
    • Earth
Re: Display servers wan ip on primary web page
« Reply #22 on: March 18, 2009, 06:26:15 PM »
Missed the easiest one yet ....

ping myhostname.dyndns.com

resolved ip

:)
"If you don't know what you want, you end up with a lot you don't."

Offline RedBeard

  • **
  • 62
  • +0/-0
Re: Display servers wan ip on primary web page
« Reply #23 on: March 19, 2009, 06:47:29 PM »
How about this:

lynx --dump www.whatismyip.com/automation/n09230945.asp

This will out put the ip address directly.
............