Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to get subnet mask using .net?

I want to get client subnet mask using c#.

How can I get it?

like image 400
BrMe Avatar asked Dec 16 '12 12:12

BrMe


People also ask

How do I find subnet mask from net ID?

The network ID is found by logically ANDing the binary form of the IP address with the binary form of the subnet mask for the network. For example, if a host has an IP address of 172.16. 8.55 on a network with a subnet mask of 255.255. 0.0 (the default subnet mask), the network ID of the host is 172.16.

How do I find subnet ID from IP address?

To calculate the IP Address Subnet you need to perform a bit-wise AND operation (1+1=1, 1+0 or 0+1 =0, 0+0=0) on the host IP address and subnet mask. The result is the subnet address in which the host is situated.


1 Answers

First of all, check NetworkInterface class first. There are a lot of information in it. And these articles will be helpful for you:

  • IP Address Calculations with C# (Subnetmasks, Networks, …)
  • Get Subnet Mask
  • Finding subnet mask from IP4 address using c#
like image 163
Soner Gönül Avatar answered Oct 17 '22 01:10

Soner Gönül