Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

IP address on a web page 1

Status
Not open for further replies.

scorney

Technical User
Sep 15, 2003
115
CA
Hello all,
I'd like to represent my IP address on my personal web page. The main reason is that I have a UNIX Box at home and would like to connect to it remotely. The issue is that my ISP is providing me DHCP and I can't know remotely which address is now my connection at home.

I have set at home on my router DMZ to my UNIX box, so if I know the address I can do SSH session to it, but when i don't know the address I could just go to my ISP personal web page which I could even put a password on it. Is there an application or script that I can add to my web page to display/show this IP address, as it can change at any time because of power failure or re-sync DSL or any other factor.

Any Idea would be appreciate?
 
Hi

scorney said:
The issue is that my ISP is providing me DHCP and I can't know remotely which address is now my connection at home.
Then how you will access your web page to see the IP address displayed on it ?

I think a dynamic DNS will help you more.

What you ask for is the server's [tt]LOCAL_ADDR[/tt] environment variable. You can use a CGI script, but the simplest way is to display it with SSI :
Code:
<!--#echo var="LOCAL_ADDR" -->
Note that I never tried it in your situation. Is possible to not have it updated on IP address change. In that case I would try to parse the [tt]ifconfig[/tt] command's output.

Feherke.
 
Feherke.
You get the home unix box to publish it's IP periodically to a page on an external webserver. Then to check the IP is a simple matter of visiting said page to get the address of the home box.
You could even, I suppose, have the box email you whenever it's IP was changed.

However, I would suggest DynamicDNS too! Why reinvent the wheel?

<honk>*:O)</honk>

Tyres: Mine's a pint of the black stuff.
Mike: You can't drink a pint of Bovril.
 
Hi

Oops. So the page showing the home IP address would be hosted on another machine. Then the problem changes abit. Then the main question would be the communication between the two machines.

I done this for company's internal use with [tt]bash[/tt] scripts :
[ul]
[li]far machine :
[ul]
[li]/etc/ppp/ip-up is called by the ppp daemon[/li]
[li]/etc/ppp/ip-up.local calls my script and passes the interface data[/li]
[li]my script sends the IP[/li]
[/ul]
[/li]
[li]near machine :
[ul]
[li]xinetd listens for incoming connections[/li]
[li]xinetd calls my script and passes the incoming data[/li]
[li]my script updates the /etc/hosts file[/li]
[/ul]
[/li]
[/ul]
As you can see scorney, it depends on how you can communicate between the two machines.

Using a dynamic DNS service now seems even better idea.

Feherke.
 
Thanks guys, but I think I didn't express myself properly...
This issue is that I'm using the server at home not to host the web site. The web page is hosted on my IPS server which is it's on that page that i want to see the ip address that my router has (ip address of the existing session) out of the router it doesn't really matter as long as I'm setting up DMZ toward the right machine.
Let's say for example.

IP address provided by ISP is 70.49.53.xxx
my Router connection is on that 70.49.53.xxx, but all the machine connected to my router are 192.168.2.xxx.
From outside world I cannot connect directly to 192.168.2.xxx so I need to connect to the 70 network but how should i be able to know it without posting that address on the web or any other way to do it. hope it help to understand my issue.

THanks,
Sylvain
 
OK

I think I understand what you are saying but I wouldn't have thought it a problem.

If, from a machine behind your router, you go to a site like does it not show you the IP of your router(i.e. the one given to you by your ISP)?

So, by that token, run a script on an external webserver that will grab the ip of something connecting to it. Perhaps, for extra security, add some authentication feature so only your machine can trigger the script.

Then set up a machine behind your network with a script that will hit the external script with an http request every x minutes.

The external script simply logs the ip of whatver is hitting it and, for the sake of argument, writes it to a text file. You can then find out that IP by checking that text file.

It seems a long winded way to do it though.
Is Dynamic DNS not suitable?
<honk>*:O)</honk>

Tyres: Mine's a pint of the black stuff.
Mike: You can't drink a pint of Bovril.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top