Search code examples
c#facebookwhoiscidr

Get up-to-date facebook crawler ip list


i hope some one can help me. I need to know if a ip request is from facebook. I have a small list of ip range in cidr format and i'm able to know it the current request ip is in this range. BUT the ranges i have are out dated and i wish to be able to update it frequently

Facebook say on the doc:

whois -h whois.radb.net -- '-i origin AS32934' | grep ^route

But how i can :

1) Get this list on my windows machine. (To update my list manually)

2) Get this list from my c# code. (To update my list automatically)

an other question for what i need : List of IP Space used by Facebook

The error i get in cmd on windows:

C:\Users\Benoit>whois -h whois.radb.net -- '-i origin AS32934'

Whois v1.12 - Domain information lookup utility Sysinternals - www.sysinternals.com Copyright (C) 2005-2014 Mark Russinovich

Usage: whois [-v] domainname [whois.server]¸

-v Print whois information for referrals


Solution

  • What you should do is use https://whoisclient.codeplex.com/ and use the following code.

    using Whois.NET;
    ...
    var result = WhoisClient..Query("-i origin AS32934", "whois.radb.net");
    
    Console.WriteLine("{0} - {1}", result.AddressRange.Begin, result.AddressRange.End);
    

    That should get you going in the right direction. You could parse the results and use them how you see fit.