Skip to content
Advertisement

PHP Script to Traceroute?

I have a website running PHP on a GoDaddy shared linux server. I need to determine if users are connected to the companies VPN. If I simply do $_SERVER[‘REMOTE_ADDR’] it gives me the clients IP address. However if I can dig deeper with a tracert, the 2nd hop would show up as the companies IP address.

Is it possible to do a traceroute from the webpage using PHP to determine if users are connected to the company’s split tunnel VPN?

Advertisement

Answer

Creating a traceroute program in PHP

http://www.adayinthelifeof.nl/2010/07/30/creating-a-traceroute-program-in-php/

In case the site goes down here’s the jist:

JavaScript

You need to be root. This means it probably is not going to work when running it from a web-server, you have to run it from the command line:

JavaScript

This is a traceroute to www.kernel.org. I’ve removed the second hop (because that’s the IP at my place). The 3rd hop returned a timeout. Probably the station there did not return a ICMP packet back to use.

The above code can be found on github: https://github.com/jaytaph/traceroute

User contributions licensed under: CC BY-SA
3 People found this is helpful
Advertisement