own IP adress

liunx

Guest
Hi<br />
<br />
Im working on a small webserver and wonder if there is any way to find out the IP adress of my server using HTML code?<!--content-->I believe html is incapable of doing that. Use Java, Perl or PHP instead.<!--content-->Yes you will need a server side language to do this. Even if it were possible client side it would be with java script or something not html. html is not a scripting language it is a markup language meaning it is really only used for organization and it is not event based.<!--content-->If you have Netscape, and JavaScript is enabled:<br />
<br />
&nbsp;ia=java.net.InetAddress.getLocalHost();<br />
&nbsp;hn=ia.getHostName();<br />
&nbsp;ha=ia.getHostAddress();<br />
&nbsp;document.write("Host = " + ia);<br />
&nbsp;document.write("<br \/>");<br />
&nbsp;document.write("...Name = " + hn);<br />
&nbsp;document.write("<br \/>");<br />
&nbsp;document.write("...Address = " + ha);<!--content-->Actually, that uses JavaScript and Java to get it. Also, it won't work cross browser.<br />
<br />
Seems a bit easier to use PHP, SSI or ASP to get it, depending on which your server supports: <!-- m --><a class="postlink" href="http://www.webdevfaqs.com/php.php#getip">http://www.webdevfaqs.com/php.php#getip</a><!-- m --><!--content-->pyro, you're obviously correct.&nbsp; I was hoping his IP doesn't change, so he could determine it once and be done with it.&nbsp; Cross-browsder is not an issue then.&nbsp; You could also visit <!-- m --><a class="postlink" href="http://grc.com/">http://grc.com/</a><!-- m --> to run their port scanner and they will tell you your IP as part of the process.<!--content-->Even if you did do it client side (not using any ssi) it would not work on internet explorer (I have never seen one that did) and it would also display your local ip and not your network or modem ip. I use asp.net which is a server side langauge to access server variables and for loggin. At the top of my site is the ip and gmt-5 time. Also if you go to<br />
<!-- m --><a class="postlink" href="http://knights.europe.webmatrixhosting.net/servervars.aspx">http://knights.europe.webmatrixhosting. ... rvars.aspx</a><!-- m --> you can see the os browser ip host name and other good stuff.<br />
EDIT, for example this is me when I am on ie, I am using xp pro with ntfs by the way<br />
<br />
HTTP_USER_AGENT:Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; .NET CLR 1.1.4322) <br />
<br />
this is me on mozilla firebird<br />
<br />
Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.5a) Gecko/20030728 Mozilla Firebird/0.6.1<br />
<br />
this is me on mozilla reg<br />
<br />
Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.4) Gecko/20030624<br />
this is me on opera<br />
<br />
Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1) Opera 7.11 [en]<br />
<br />
using these differences you can tell a whole lot about the user the windows nt 5.1 tells you my os the other stuff basically tells you my browser type. If you want functionality it is generally a good rule of thumb to do things server side. Java script is for affects and after market stuff to make your page look nice but you should use it conservativly and you should not rely on it.<!--content-->Well, what I want is a way for the client to find out the IP of the server it is connected to. I think there is a really simple way of doing this :rolleyes:<!--content-->Originally posted by PeOfEo <br />
... if you go to<br />
<!-- m --><a class="postlink" href="http://knights.europe.webmatrixhosting.net/servervars.aspx">http://knights.europe.webmatrixhosting. ... rvars.aspx</a><!-- m --> you can see the os browser ip host name and other good stuff.<br />
<br />
<br />
It lists my IP as 141.216.1.4.&nbsp; That's my firewall; mine is 141.216.11.124.&nbsp; The one listed by grc.com runs through SSL and is always correct.<br />
<br />
Originally posted by Apan <br />
Well, what I want is a way for the client to find out the IP of the server it is connected to. I think there is a really simple way of doing this :rolleyes: <br />
<br />
The client probably connected to the server using a name that was then translated into an IP by a DNS.&nbsp; It seems to me that the only good way to get back the server's IP would be from the server.<!--content-->Originally posted by jalarie <br />
It lists my IP as 141.216.1.4.&nbsp; That's my firewall; mine is 141.216.11.124.&nbsp; The one listed by grc.com runs through SSL and is always correct.<br />
<br />
<br />
<br />
The client probably connected to the server using a name that was then translated into an IP by a DNS.&nbsp; It seems to me that the only good way to get back the server's IP would be from the server. That Ip it lists is your network ip. If this 'firewall' of yors is on your router then of cource that is what it would list. If you are looking for your local ip no it can't see that and why would you want it to? A local ip or one that is behind a router or a broad band modem can be changed at any time by the user so it would be useless to track it if you are using the ip for site security reasons or ip logging. Once again I used asp.net for this which is a server side language, so the ip it lists is what the server sees. Also that statement about ssi always being correct, how do you figure? If this is truely displaying a local ip then it would not be correct and also there is the fact that we are running on different servers. Please tell me where on that site you listed it is giving you a different ip then the one it gives on my site because I want to see what they did and see for myself if it is a local ip that is being displayed.<!--content-->To PeOfEo:<br />
<br />
I refered to SSL (Secure Socket Layer) not SSI (Server-Side Include) in my message.<br />
<br />
It doesn't really matter why I or anyone else would wish to know the specific machine IP rather than the firewall / router / proxey address.&nbsp; It is significant to know that there may be different answers so that I can intelligently pick the one I want in a particular situation.<br />
<br />
To get all sorts of really usefull (in my not-so-humble opinion) stuff, visit <!-- m --><a class="postlink" href="http://grc.com/.&nbsp;">http://grc.com/.&nbsp;</a><!-- m --> Click on the "Shields UP" logo, scroll about half-way down the page and click on the "ShieldsUp!" link, scroll down about a third of the way and read your current machine IP from the bottom of the light blue box.<br />
<br />
You might wish to click on the "All Service Ports" link at the top of the light blue box (see previous paragraph) for a real eye-opener.&nbsp; It will scan the first 1024 ports on your machine to see if you are vulnerable to attack on those ports.<!--content-->Originally posted by jalarie <br />
To PeOfEo:<br />
<br />
I refered to SSL (Secure Socket Layer) not SSI (Server-Side Include) in my message.<br />
<br />
Crap, what do you call it when you read an I instead of an l? A reado? The ip address on grc lists my remote ip btw, 24.129.59.208, 24.129.59.208 is what is listed on my site to. The ip address on my site is correct, because it is what the server sees. So to say that the ip listing for you on my site is incorrect would be a false statement. It is most certainly your ip. It might be your router ip but still it is none the less your remote ip which is seen by the internet. To say it is not your ip is wrong, to say it is not your local ip or something like that might be acceptable. The reason why I think seeing a machine ip is kind of dumb is because it can just be changed at any time I mean its not hard, I would do it right now if it would not mess up all of the stuff that I am running and I would not have to map out all the server ports back to my computer.<!--content-->PeOfEo, Every machine at this location, all multiple thousand of them, lists as 141.216.1.4 at your site; grc.com lists each uniquely.&nbsp; Which is correct depends on what you wish to see.&nbsp; I wish only to point out that there are different answers depending on the viewpoint and that the user should be aware so that s/he can inteligently choose.<!--content-->You cannot change you machine IP, they are given by your ISP and remain. That is what is logged at forums and such. Lower right hand corner of your post.<br />
<br />
You can change the external one but the machine IP you cannot.<br />
<br />
I am on a MAC and have tried and it always changes back to the sameone when I restart my machine.<br />
<br />
MNS<!--content-->Originally posted by MotherNatrsSon <br />
You cannot change you machine IP, they are given by your ISP and remain. That is what is logged at forums and such. Lower right hand corner of your post.<br />
<br />
You can change the external one but the machine IP you cannot.<br />
<br />
I am on a MAC and have tried and it always changes back to the sameone when I restart my machine.<br />
<br />
MNS You seem to have this mixed up. If you are on a router or something the router and the modem have separate ip addresses from your machine. The rarely ever needs to see your machines actual ip unless they are doing something like this site jalari listed, that is why it can be changed freely. If you are on 56k however you have no control over your ip, that is the isp. But I can change my ip all I want, I am running xp pro btw.<br />
<br />
Also jalarie it is supposed to list all of those ip addresses as being the same because you are on the same network. The server sees all of those machines as one because you are on the same hubb or connector. This ssl is actually connecting a socket and this could cause problems for most sites. I guess the reason why grc is doing it is because they are also scanning your ports and need a connection to your actual machine. You will see the majority of ip logging on the internet is done the way I did it because if you did it with ssl you can have many many machines with the same ip addresses that are on different networks.<!--content-->
 
Back
Top