Questions tagged [netmask]

A network mask is used to determine which part of an IP address belongs to the network and which part identifies the host.

A classic IP v4 address consists of a 32 bit binary number. This number is a concatenation of the network and the host number.

e.g. if I have network 1.2.3.0/8 with on that computer number 4 then we say that:

  • 1.2.3.0 is the network
  • and 1.2.3.4 is the IP of a host on that network.

To determine where the numbers for the network range stop and where the host part starts we need an extra item. This is the network mask.

Example using the number from above:

32 bits as a ruler  12345678 90123456 78901234 56789012
1.2.3.4 in binary   00000001 00000010 00000011 00000100

Network/Host        NNNNNNNN NNNNNNNN NNNNNNNN HHHHHHHH

Here we see that 24 bits are used for the network part and 8 bits are used for the host. If we turn all these N's into 1's and the H's into zeros then we can logically and and IP address with that mask and the result is the network.

Example:

1.2.3.4 in binary   00000001 00000010 00000011 00000100
Mask                11111111 11111111 11111111 00000000
                    -----------------------------------  AND
                    00000001 00000010 00000011 00000000

Thus the network is 00000001000000100000001100000000.

This is usually written in dotted decimal format where eight bits are grouped into one number. Simple binary calculation will show use that 00000001 equals 1, 00000010 equals 2, 00000011 equals 3 and 00000000 equals 0. Thus the network in dotted decimal notation is 1.2.3.0.

This is usually written as 1.2.3.0/8, or in the combination of "network 1.2.3.0" "netmask 255.255.255.0" where 255 is the binary values of the mask we ANDed with.

35 questions
29
votes
2 answers

What is the difference between a subnet mask and a netmask?

Is there any logic in using two different names for determining host ID and net ID? For example, if you type print route in a Command Prompt you get things with netmask, but the IPv4 settings seems to use subnet mask. Is there any significant…
Alireza
  • 979
11
votes
4 answers

Why can't my OpenVPN client access machines on same LAN as OpenVPN server?

I have configured OpenVPN on my Linux server and Windows client according to the instructions here. My client can access the server, but can't get any further onto the LAN. My Server is 10.23.29.64/24, my OpenVPN subnet is 10.23.30.0/24 and my…
Grezzo
  • 982
8
votes
2 answers

When is the subnet mask used?

My NIC on my computer has a subnet mask. Is this only for it's own information? Or does the subnet mask get tossed into the TCP/IP headers to help the next device up route it? I'm guessing it's only for the individual device's information. Thanks…
pkSML
  • 466
4
votes
2 answers

Is there any way to quickly and efficiently get a count of IP host addresses in thousands of CIDR/netmask ranges in Bash?

I am using IPSet to managed tens of thousands of IPv4 CIDR/netmask ranges that then get linked to IPTables rules. This setup is working great, but I would like to get a good, high-level overview count of the IP host addresses IPSet acts on for…
Giacomo1968
  • 58,727
3
votes
1 answer

Is there a way to detect a LAN's IP and its subnet mask?

I'm not a English speaker, but I'll try my best make it clear: If your laptop connects to a unknown local network (through a wireless or wired router) and there's no DHCP service at all, and nobody would tell you the configuration of this network,…
JeffLyn
  • 33
3
votes
2 answers

What does mask 0.0.0.0 mean when it's assigned to a network interface?

Suppose I use ifconfig or some similar command to setup my network interface, and I assign 0.0.0.0 to the mask parameter. Does it have a special meaning? What implications could this have?
3
votes
3 answers

Subnet cross-access with three routers

I am trying to build a home network with three routers and one switch. My search here and on the internet didn't yield much, partly due to every question being very specific and also me being a novice at this (at best). I'd like to maintain two…
liatorp
  • 33
3
votes
3 answers

Why aren't public IP addresses always displayed with their subnet mask?

I've been told that a public ip address without its corresponding subnet mask is meaningless, because one couldn't know how to split the network id from the host id, which makes total sense to me. However, most of the time I see ip addresses (DNS,…
Radioreve
  • 133
2
votes
1 answer

Is there any command-line to change my network mask in Windows shell?

I have not been able to find nothing on the netsh command shell documentation for changing only the netmask configuration without modifying rest of it (ip, gateway, DNSs and so on). The closest I know about is this one, that changes too IP and…
2
votes
3 answers

In Linux, why can't I access my network after subnetting with a mask of 255.255.255.240?

OK, first I have a dual boot system. Linux Mint 18 (Sarah) Cinnamon and Windows 7 SP1. Good thing I did this, because I'm new to Linux. When I first installed both Windows and Linux, I setup LAN1 as 192.168.1.1/255.255.255.0. I had no problem…
1
vote
1 answer

How can I configure my DD-WRT VPN PPTP server to assign netmask 255.255.255.0 to clients?

I have a router running DD-WRT with a PPTP Server working fine, but every PPTP client gets assigned IP like this one: IPv4 Address . . . . . . . . . . . . : 192.168.210.2 Subnet Mask . . . . . . . . . . . . : 255.255.255.255 As long as I know,…
1
vote
1 answer

What is major network mask and subnet mask

I've been served with a question to find Major Network Mask and I've only given Host IP address and sub-net mask. I have to find the Major Network Mask using Host IP and sub-net mask. Another stackoverflow question says both are the same I've…
1
vote
2 answers

Why is 172.16/12 contiguous?

I'm confused. From RFC 1918: 10.0.0.0 - 10.255.255.255 (10/8 prefix) 172.16.0.0 - 172.31.255.255 (172.16/12 prefix) 192.168.0.0 - 192.168.255.255 (192.168/16 prefix) The prefix 172.16/12 seems strange to me for the range…
Jesse
  • 215
1
vote
1 answer

Subnet masking to get 2 subnets each with 126 host

Suppose we have a subnet mask of value 255.255.255.128. May I know please why this would split the network into 2 subnets each with 126 hosts? From my understanding, if the subnet mask was 255.255.255.0, it would mean we have 254 host as there is 2…
Avv
  • 113
1
vote
2 answers

netmask: how to calculate number of networks?

My way to calculate netmask number of host, for example: i want to know the number of hosts for netmask 255.255.255.192 (prefix 26) 255.255.255.192 11111111.11111111.11111111.11000000 26 128+64=192 the 192 is 128+64…
elbarna
  • 466
1
2 3