title: How to store and search for an IP Address
body: <p>I have the 4 sources of IP addresses , I want to store them in SQL Server and allow the ranges,  that can be categorised by the originating country code, to be maked in an Exclusion list by country. </p>
  
  <p>For this I have 2 tables.</p>
  
  <p>IPAddressRange
  CountryCode</p>
  
  <p>What I need to know is, if this data was returned to the client then cached for quick querying , what is the best way to store the returned data to query a specific IP address within the ranges. I want to know if the supplied IP address is in the list. </p>
  
  <p>The reason the list is in the db is for easy storage. </p>
  
  <p>The reason I want to cache then use the data on the client is that I have heard that searching IP addresses is faster in a trie structure. So , I am think I need to get the list from the db , store in cache in a structure that is very quick to search.</p>
  
  <p>Any help in the A) The SQL stucture to store the addresses and b) Code to search the IP addresses.</p>
  
  <p>I know of a code project solution which has a code algorithm for searching not sure how to mix this with the storage aspect.</p>
  
  <p>Ideally without the use of a third party library. The code must be on our own server.</p>