Answer the question
In order to leave comments, you need to log in
What real IP will come from the subnet?
Good day to all!
I have a nodejs (or php, whatever) service. This service is requested from servers on the 31.131.xxx.x/25 or 46.182.xx.xxx/29 subnet. What IP will I receive in the code of my project? How can I calculate this IP from, for example, 31.131.xxx.x/25 or 46.182.xx.xxx/29?
My service hangs on a separate IP in none of these subnets.
Thank you.
Answer the question
In order to leave comments, you need to log in
This function checks that the address is on a CIDR subnet:
function cidr_match($ip, $cidr)
{
list($subnet, $mask) = explode('/', $cidr);
if ((ip2long($ip) & ~((1 << (32 - $mask)) - 1) ) == ip2long($subnet))
{
return true;
}
return false;
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question