How to see if an IP address belongs inside of a range of IPs using CIDR notation?

后端 未结 7 2061
猫巷女王i
猫巷女王i 2020-12-09 08:54

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

private static List Ip_Range = new List()
{
    \"12.144.86.0/23\",
           


        
7条回答
  •  南方客
    南方客 (楼主)
    2020-12-09 09:50

    For start, you should use that:

    IPNetwork ipnetwork = IPNetwork.Parse("192.168.168.100/29");
    Console.WriteLine("CIDR: {0}", ipnetwork.Cidr);
    

    Output

    CIDR: 29
    

提交回复
热议问题