Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7611155
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T01:35:47+00:00 2026-05-31T01:35:47+00:00

Here I have a static reference the ranges I need to check: private static

  • 0

Here I have a static reference the ranges I need to check:

private static List<string> Ip_Range = new List<string>()
{
    "12.144.86.0/23",
    "31.201.1.176/30",
    "46.36.198.101/32",
    "46.36.198.102/31",
    "46.36.198.104/31",
    "46.136.172.0/24",
    "63.65.11.0/24",
    "63.65.12.0/25",
    "63.65.12.128/26",
    "63.65.12.192/27",
    "63.65.12.224/28",
    "63.65.12.240/29",
    "63.65.12.248/30",
    "63.65.12.252/31",
    "63.65.12.254/32",
    "65.173.56.0/21",
    "67.23.241.179/32",
    "67.23.241.180/30",
    "67.23.241.184/29",
    "67.23.241.192/30",
    "67.23.241.196/31",
    "67.23.241.198/32",
    "72.32.164.56/29",
    "72.46.244.32/28",
    "74.91.16.48/29",
    "74.91.16.208/29",
    "74.91.20.48/28",
    "74.91.20.64/29",
    "74.112.134.120/29",
    "74.112.135.104/29",
    "74.205.37.16/29",
    "78.24.205.32/28",
    "98.129.27.88/29",
    "98.129.91.40/29",
    "166.114.0.0/16",
    "167.157.0.0/16",
    "174.143.165.80/29",
    "186.0.156.0/22",
    "186.2.0.0/17",
    "186.27.0.0/17",
    "190.0.248.0/21",
    "190.3.184.0/21"
};

Here’s some pseudo code on how I see it working:

public static bool IpIsWithinRange(string ip) //Something like 127.0.0.1 or 184.56.26.35
{
    IPAddress incomingIp = IPAddress.Parse(ip);
    foreach (var subnet in Ip_Range)
    {
        IPAddress sub = IPAddress.Parse(subnet); ?????
        if (incomingIp "is in" sub) ?
            return true;            
    }
    return false;
}

Any suggestions on how to code up this functionality?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-31T01:35:48+00:00Added an answer on May 31, 2026 at 1:35 am

    Decided to answer my own question so people can benefit. If it can be improved, please do!

    I used the IPNetwork library and it worked out fantastically!

    nuget install IPNetwork2
    

    Below is the code I used:

    using System.Net;
    
    public static class RedirectHelpers
    {
        public static bool IpIsWithinBoliviaRange(string ip)
        {
            IPAddress incomingIp = IPAddress.Parse(ip);
            foreach (var subnet in Bolivia_Ip_Range)
            {
                IPNetwork network = IPNetwork.Parse(subnet);
    
                if (IPNetwork.Contains(network, incomingIp))
                    return true;
            }
            return false;
        }
    
        private static List<string> Bolivia_Ip_Range = new List<string>()
        {
            "12.144.86.0/23",
            "31.201.1.176/30",
            "46.36.198.101/32",
            "46.36.198.102/31",
            "46.36.198.104/31",
            "46.136.172.0/24",
            "63.65.11.0/24",
            "63.65.12.0/25",
            "63.65.12.128/26",
            "63.65.12.192/27",
            "63.65.12.224/28",
            "63.65.12.240/29",
            "63.65.12.248/30",
            "63.65.12.252/31",
            "63.65.12.254/32",
            "65.173.56.0/21",
            "67.23.241.179/32",
            "67.23.241.180/30",
            "67.23.241.184/29",
            "67.23.241.192/30",
            "67.23.241.196/31",
            "67.23.241.198/32",
            "72.32.164.56/29",
            "72.46.244.32/28",
            "74.91.16.48/29",
            "74.91.16.208/29",
            "74.91.20.48/28",
            "74.91.20.64/29",
            "74.112.134.120/29",
            "74.112.135.104/29",
            "74.205.37.16/29",
            "78.24.205.32/28",
            "98.129.27.88/29",
            "98.129.91.40/29",
            "166.114.0.0/16",
            "167.157.0.0/16",
            "174.143.165.80/29",
            "186.0.156.0/22",
            "186.2.0.0/17",
            "186.27.0.0/17",
            "190.0.248.0/21",
            "190.3.184.0/21",
            "166.114.0.0/16",
            "167.157.0.0/16",
            "186.2.0.0/18",
            "190.11.64.0/20",
            "190.11.80.0/20",
            "190.103.64.0/20",
            "190.104.0.0/19",
            "190.107.32.0/20",
            "190.129.0.0/17",
            "190.181.0.0/18",
            "190.186.0.0/18",
            "190.186.64.0/18",
            "190.186.128.0/18",
            "200.7.160.0/20",
            "200.58.64.0/20",
            "200.58.80.0/20",
            "200.58.160.0/20",
            "200.58.176.0/20",
            "200.75.160.0/20",
            "200.85.128.0/20",
            "200.87.0.0/17",
            "200.87.128.0/17",
            "200.105.128.0/19",
            "200.105.160.0/19",
            "200.105.192.0/19",
            "200.112.192.0/20",
            "200.119.192.0/20",
            "200.119.208.0/20",
            "201.222.64.0/19",
            "201.222.96.0/19"
        };
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have the following code: public class DeserializeAndCompare { public static List<string> IntoXML() {
Here is a reduced version of what I need. Essentially, we have a list
Just a quick sanity check here! If I have a static method in an
I have following code: public static void ProcessStep(Action action) { //do something here if
I have a few classes as shown here public class TrueFalseQuestion implements Question{ static{
I have configured WordPress to display a static front page as described here: http://codex.wordpress.org/Settings_Reading_SubPanel#Reading_Settings
Here I have: Public Structure MyStruct Public Name as String Public Content as String
Here I have a password field: /*********************PASSWORD**********************/ $password = new Zend_Form_Element_Password('password'); $alnumValidator = new
I have a static method like this public static string DoSomethingToString(string UntrustedString) { //parse
Suppose you have a private static method called Inst() which allows the class to

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.