Questions tagged [netmask]

A bitwise mask that shows which part of the IP address is shared by all computers in the subnetwork and is used to identify them all together in some larger network. The IP address part that is not flagged by this mask identifies individual computers in the subnetwork.

Netmask can be specified either in quad-dotted decimal representation like 255.255.254.0 (means the seven lower bits identify computers in subnetwork) or, together with IP address, as a number of the high bits used by the larger network and not by subnetwork (192.168.80.0/23, the same).

The bitwise AND operation between mask and IP address results the address of the network itself, and the remainder identifies the computer LAN connector within that network.

81 questions
40
votes
8 answers

How to calculate the IP range when the IP address and the netmask is given?

When a IP-Range is written as aaa.bbb.ccc.ddd/netmask (CIDR Notation) I need to calculate the first and the last included ip address in this range with C#. Example: Input: 192.168.0.1/25 Result: 192.168.0.1 - 192.168.0.126
Anheledir
  • 4,292
  • 7
  • 30
  • 34
17
votes
6 answers

Given the IP and netmask, how can I calculate the network address using bash?

In a bash script I have an IP address like 192.168.1.15 and a netmask like 255.255.0.0. I now want to calculate the start address of this network, that means using the &-operator on both addresses. In the example, the result would be 192.168.0.0.…
Christian
  • 2,735
  • 4
  • 28
  • 32
7
votes
3 answers

Calculate CIDR from a given netmask - Java

Is there a way to calculate a CIDR given a Sub net mask using any Java lib/function/trick?? I have been looking for a while and all I can find is from CIDR -> Netmask and I need it the other way arround Netmask -> CIDR ... Im not that handy on…
PzP01
  • 73
  • 1
  • 4
6
votes
3 answers

Java & Windows 7: Reliably getting IPv4 netmask?

I've run into a known bug with Java 6 on Windows. My understanding is that the normal way to get the netmask is to look up the network prefix length and do some bit shifts. The problem is that on Windows the prefix length is often returned…
Timothy Miller
  • 1,365
  • 4
  • 24
  • 41
6
votes
4 answers

How to convert a CIDR prefix to a dotted-quad netmask in Python?

How can I convert a CIDR prefix to a dotted-quad netmask in Python? For example, if the prefix is 12 I need to return 255.240.0.0.
planetp
  • 10,603
  • 14
  • 62
  • 124
5
votes
1 answer

Standard/safe way to check if IP address is in range/subnet

I have a small piece of code that converts a 32-bit unsigned integer (ie: uint32_t) into a set of four 8-bit fields, treats it like an IP address, and then reports to the client if it falls within a predetermined range of IP addresses. I've already…
Cloud
  • 17,212
  • 12
  • 64
  • 137
5
votes
1 answer

DhcpInfo isn't responding the netmask in Android Lollipop

Yesterday I update my nexus 5 to lollipop and my application stops working, after a little investigation I found the problem the DhcpInfo isn't is returning null on the netmask variable. I couldn't find any alternative to this class.
Carlos EduardoL
  • 640
  • 6
  • 14
4
votes
1 answer

How can I get netmask from Android device?

I need to get the netmask and ip from the Android so I can calculate all the IP's within my subnet range. I've been searching and so far I've found this: Programmatically getting the gateway and subnet mask details The problem is that it doesn't…
sergi
  • 929
  • 5
  • 14
  • 21
4
votes
3 answers

How to determine netmask of active interface in Objective-C on a Mac?

I'm trying to determine the network segment my Macbook is in, because I then want to scan this segment for active hosts (basic IP scanner) by using the CFHost class. Therefore I need the IP and Netmask of my active interface. This is how I get the…
Martin
  • 351
  • 1
  • 4
  • 11
4
votes
4 answers

Bash - Convert netmask in CIDR notation?

Example: I have this netmask: 255.255.255.0 Is there, in bash, a command or a simple script to convert my netmask in notation /24?
Alex_DeLarge
  • 185
  • 1
  • 8
4
votes
2 answers

Efficient way to test if bitwise IPv6 netmask is contiguous

I need to store IP addresses/netmasks in an in_addr/in6_addr struct. For IPv4 I use the following code to test if the netmask is contiguous: ((((~netmask + 1) & (~netmask)) != 0) && (netmask != 0)) I was wondering if there is a smart way to do the…
evelina
  • 147
  • 1
  • 7
3
votes
0 answers

How to convert netmask to wildcard with netaddr python library?

I want to convert netmask to wildcard mask with netaddr library so the input is netmask = 255.255.255.0 and the output is wildcard = 0.0.0.255 or the input is netmask = 255.255.255.252 and the output is wildcard = 0.0.0.3
Adhy
  • 137
  • 1
  • 6
3
votes
4 answers

Converting netmask number to 32 bit in golang

I am trying to get the IP address and subnet mask by ifaces, err := net.Interfaces() for _, iface := range ifaces{ localip, _ = iface.Addrs() } However, I am looking forward to get the subnet as something like 255.255.255.0 rather than /24.…
scott
  • 1,317
  • 2
  • 12
  • 28
3
votes
2 answers

Need to break down a IP subnet

I am trying to write a script which breaks down subnets larger(not greater than /16) than /24 to a /24 subnet. Eg : 10.10.10.0/23 should give me 10.10.10.0/24 and 10.10.11.0/24 My logic is to first scan for the CIDR mask. if smaller than 24, then…
skd
  • 35
  • 5
3
votes
1 answer

Android, detect local IP and subnet mask for WiFi, both while tethering and connected to access point

I need to detect the local IP address and subnet mask on the WiFi network, on an Android device (in order to proper calculate the UDP broadcast address strictly for the local subnet). When the device is connected to an Access Point, the following is…
GozzoMan
  • 662
  • 8
  • 20
1
2 3 4 5 6