For some reason it is not showing any ports that I opened on my router except for 80. For example I have port 5445 open. But the script is not seeing it as opened. I have verified that it is open by going to other sites like CanYouSeeMe.org and plus the device that uses that particular port is working.
Here is my script:
<?php
$ip = "xx.xxx.xxx.xx";
$port = "5445";
if(fsockopen("$ip",$port))
{
print "I can see port $port on $ip";
}
else
{
print "I cannot see port $port on $ip";
}
?>
It shows port 5445 as closed but it is open.
It does show as opened on other port checking sites, just not mine.
So I’m wondering if there’s a problem with the script or something on my server that is blocking it?
Maybe a php setting?
Try like this, and put script on host, not localhost
<?php
error_reporting(E_ALL); // error reporting on
$ip = "192.168.1.31"; // my localhost ip
$port = 26354; // 26354 my opened port in modem
$timeout = 30; // connection timeout in seconds
if (fsockopen($ip, $port, $errno, $errstr, $timeout)) {
echo "I can see port $port on $ip";
} else {
echo "I cannot see port $port on $ip, <br> error $errstr ($errno)<br />\n";
}
?>
And are you now running the code from somewhere outside of your local router as @mlukac89 mentioned above? Some routers have different firewall rules and configuration for connections coming in from the outside to those going out from the inside.