php cidr

Hi i need to get 2500 CIDR of websites. How i can do it with php ?
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Ray PaseurCommented:
Are you talking about the RFC?

If so, please tell us why you need this information and show us what you have tried to use to get it, thanks.
umaximAuthor Commented:
umaximAuthor Commented:
I try to use to get this information because one of my client want to block all online proxy so he ask me ban it by ip i desiced to ban it by cidr.
Cloud Class® Course: CompTIA Healthcare IT Tech

This course will help prep you to earn the CompTIA Healthcare IT Technician certification showing that you have the knowledge and skills needed to succeed in installing, managing, and troubleshooting IT systems in medical and clinical settings.

whois is definitely not the proper tool for various reasons
- the information it provides is never up to date
- it is very likely that thousands of sites will correspond the the same whois entry

if you have a list of websites, you probably can simply perform a DNS lookup and insert each ip of each site as a /32 in the list
if you are using a firewall, it is very likely that the firewall can accept fqdn names and perform the lookup by itself

what is your original list ?
what tool are you using to block traffic ?
umaximAuthor Commented:
i use iptables to block the original list is list of websites and their ip
then you do not need to do anything more. what are you really trying to achieve

use something like "-d --dport 80" to block whatever sites you need to block or if you want to use ips, in php you can use gethostbynamel(), -- the ending L is not a typo error -- to retrieve all matching ips

something like this will turn an array of sites to a list of ips

foreach($sites as $site){
    die("site has no associated DNS record");
  foreach($ips as $ip)

you may add '/32' at the end of each ip if you need them in cidr notation

you cannot automagically determine what ip pool the site may use. this should be done manually, is difficult and needs to be maintained frequently

you can use the pear package net/dns for a better implementation that will notice the difference between an inexistent dns record and a dead dns server

but endly, i do not believe this is useful compared to just stick the sites in the firewall config


if really you want to block such sites, maybe a proxy doing a little heuristic detection can do reasonably good

some free proxies are bundled with good heuristics and sometimes up to date list of such sites

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
umaximAuthor Commented:
so i can block by websites too for example -d --dport 80 and it will block it
yes : this is the simple straightforward solution providing you have the list of sites you need to block.

the firewall should be intelligent enough not to perform dns queries too often, and intelligent enough too reperform them periodically in case the ips change.
actually i cannot confirm netfilter performs the queries when needed, but most firewalls do.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.