I need to perform a TCP traceroute using either the Linux traceroute or another package, but I'm struggling to find a way of making the request from PHP without needing sudo privileges.
Because the URL will be from a user request I don't want to use sudo.
Here's an example:
$url = 'ebay.com'; $exec = 'sudo traceroute -w 1 -q 1 -T ' . $url; $escaped_command = escapeshellcmd($exec); $result = shell_exec($escaped_command); echo $result; var_dump($result);
This code works, but only with
sudo or without
sudo, it returns an empty string. Without
-T the traceroute does not survive firewalls.
If it helps, I'm on a Centos 7 OS.
Note: I can't use UDP instead of TCP because it often gets blocked by the destination firewall.