Monday, May 20, 2024
 Popular · Latest · Hot · Upcoming
57
rated 0 times [  60] [ 3]  / answers: 1 / hits: 155850  / 15 Years ago, wed, september 2, 2009, 12:00:00

Is there any way you can find the IP of the server that the browser is connected to? For e.g. if the browser is accessing http://www.google.com, can we tell in any way what IP it is connected to? This is very useful in cases where Round-robin DNS is implemented. So say, the first request to a.com results in 1.1.1.1 & subsequent request result in 1.1.1.2 & so on.



I couldn't find any way to do it with JavaScript. Is it even possible? If not is there any universal way to find this info out?


More From » javascript

 Answers
65

Fairly certain this cannot be done. However you could use your preferred server-side language to print the server's IP to the client, and then use it however you like. For example, in PHP:



<script type=text/javascript>
var ip = <?php echo $_SERVER['SERVER_ADDR']; ?>;
alert(ip);
</script>


This depends on your server's security setup though - some may block this.


[#98767] Sunday, August 30, 2009, 15 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
cruzs

Total Points: 710
Total Questions: 113
Total Answers: 100

Location: Nepal
Member since Sat, Jul 18, 2020
4 Years ago
cruzs questions
Thu, Nov 26, 20, 00:00, 4 Years ago
Wed, Oct 28, 20, 00:00, 4 Years ago
Wed, Aug 19, 20, 00:00, 4 Years ago
Sun, Aug 2, 20, 00:00, 4 Years ago
;