Excluding IP-ranges

Discussion in 'ASP .Net' started by Snedker, Jul 30, 2008.

  1. Snedker

    Snedker Guest

    Hi there,

    I really need some input of how to approach my little assignment.

    A customer wants to exclude all US IP-ranges from accessing part of
    his website. From http://www.ipaddresslocation.org/ I've collected
    about 16,000 ranges in the format

    208.202.120.0 208.203.111.255
    208.203.114.0 208.203.244.127
    ....

    I don't yet know how many individual IP's then ranges totals, but I
    reckon we speak millions.

    Now, when a user hits that certain webpage a lookup should be
    performed, checking if user is in a range. If he is, he's banned from
    that part of the page.

    My idea is to save to a table (MSSQL) that contains 4 columns - one
    column for each part of the IP. When I import the ranges I save each
    IP in that interval, ending up with all (or so) current US IP-
    addresses. Each of the four columns are indexed.

    A lookup will then use a phonebook-kinda-lookup (SELECT COUNT(*) FROM
    myTable WHERE col1=62 AND col2=63 AND col3=64 and col4=65). If it
    returns 0, user is allowed.

    Is that a crappy approach, or should I consider something else?


    Thanks in advance for any input.

    Regards /Snedker
    Snedker, Jul 30, 2008
    #1
    1. Advertising

  2. > Hi there,
    >
    > I really need some input of how to approach my little assignment.
    >
    > A customer wants to exclude all US IP-ranges from accessing part of
    >
    > I don't yet know how many individual IP's then ranges totals, but I
    > reckon we speak millions.



    Check with www.apnic.net
    Gaurav Vaish \(a.k.a. MasterGaurav\), Jul 30, 2008
    #2
    1. Advertising

  3. Snedker wrote:
    > Hi there,
    >
    > I really need some input of how to approach my little assignment.
    >
    > A customer wants to exclude all US IP-ranges from accessing part of
    > his website. From http://www.ipaddresslocation.org/ I've collected
    > about 16,000 ranges in the format
    >
    > 208.202.120.0 208.203.111.255
    > 208.203.114.0 208.203.244.127
    > ...
    >
    > I don't yet know how many individual IP's then ranges totals, but I
    > reckon we speak millions.
    >
    > Now, when a user hits that certain webpage a lookup should be
    > performed, checking if user is in a range. If he is, he's banned from
    > that part of the page.
    >
    > My idea is to save to a table (MSSQL) that contains 4 columns - one
    > column for each part of the IP.


    First of all, you should convert each IP address to a single 32 bit
    value. There is no reason to compare four values when you can compare one.

    > When I import the ranges I save each
    > IP in that interval, ending up with all (or so) current US IP-
    > addresses. Each of the four columns are indexed.


    If only 10% of the IP range is allocated to US, that makes a table with
    430 million records...

    You should definitely store the ranges, not the individual IP addresses.

    > A lookup will then use a phonebook-kinda-lookup (SELECT COUNT(*) FROM
    > myTable WHERE col1=62 AND col2=63 AND col3=64 and col4=65). If it
    > returns 0, user is allowed.
    >
    > Is that a crappy approach, or should I consider something else?
    >
    >
    > Thanks in advance for any input.
    >
    > Regards /Snedker



    --
    Göran Andersson
    _____
    http://www.guffa.com
    Göran Andersson, Jul 30, 2008
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Paul Cook
    Replies:
    1
    Views:
    383
    Harley
    Aug 7, 2003
  2. Frank Rizzo
    Replies:
    2
    Views:
    3,029
    Frank Rizzo
    Jan 12, 2004
  3. Jon Maz

    Excluding a file from VS.Net Project

    Jon Maz, Nov 18, 2004, in forum: ASP .Net
    Replies:
    10
    Views:
    539
    Jon Maz
    Nov 19, 2004
  4. Olav Tollefsen
    Replies:
    2
    Views:
    347
    Olav Tollefsen
    Feb 1, 2005
  5. Andy Fish

    excluding some rows when databinding

    Andy Fish, Mar 31, 2005, in forum: ASP .Net
    Replies:
    1
    Views:
    687
    Brock Allen
    Mar 31, 2005
Loading...

Share This Page