ManOfSteel wrote:Hello,
I have some questions about networking. Here's my first one.
What's the purpose of subnet masks (eg: "255.255.255.0")? What does it mean? Does it have any impact on security? Can anything other than "255.255.255.0" be used for a private network? Does its value depend on the IP address of the computer?
PS: I've already read some technical stuff about it but didn't understand much.
Thanks for your help.
The subnet mask indicates which addresses belong to your subnet. It could be (back in the days up to 1995 or so) either 255.0.0.0, 255.255.0.0 or 255.255.255.0. If it's the first, the network stretches to, say, 85.*.*.*. If the second, it'll stretch to 169.254.*.*. If the third, you'll reach 192.168.0.*. The numbers aren't random.
In the past there were 3 types of network sizes, class A, B and C. Class A was 16.8 million addresses and had the first type of netmask and applied to all networks below 128. This includes the localnet IP address range 10.* and localhost address range 127.*. Yes, your computer is also adressable at 127.12.34.56.
The second type is between 128.0.0.0 and 191.255.0.0. This includes the Microsoft non-routing segment 169.254.* (which by default has 255.255.0.0 as netmask).
The third type is between 192.0.0.0 and 223.255.255.0. This includes the common localnet network 192.168.0.*, although the entirety of 192.168.* is reserved for this purpose.
There is a fourth type, class D, between 224.0.0.0 and 239.255.255.255, which is reserved for multicast (so don't assign any of these to your computer). A fifth class, class E, is plain reserved, and goes from 240.0.0.0 to 255.255.255.254. The single last address is reserved as global broadcast address, which has lead to all Windows machines plain ignoring it (since it was a handy way of reaching all machines you could find).
Nowadays, there are more complex types of subnetting, which involves knowing how many bits of the address are fixed (and thereby, how many you can fill in, and thereby how many you can choose yourself). This is commonly indicated as a /xyz subnet. For instance, the three localnets above would be 127.0.0.0/8, 169.254.0.0/16 and 192.168.0.0/24. Since the 0's are redundant you can omit them, leaving 127/8 (uncommon since it's confusing), 169.254/16 and 192.168.0/8.
Since the distinction leads to largely unused networks (say, for universities, 65k addresses is too few, but 16 million is a bit over the top) these were split up and are sold in smaller portions. There are a few universities that still own a /8, as well as large US corporations.
Smaller netmasks are also possible. The / system only allows logical subnets, in that all addresses in it are consecutive. You could make a netmask 255.254.254.254 over the network 192.168.0.0 but that would allow 8 addresses, 192.168.0.0, 192.168.0.1, 192.168.1.0, 192.168.1.1, 192.169.0.0, 192.169.0.1, 192.169.1.0 and 192.169.1.1. As you can tell, that confuses the hell out of most people. Don't use them, use only those you can express with a / notation.
Which are they then? The / notation indicates, from the most significant bit going backwards into the number (to the right) how many bits exactly must be kept equal to the network address. So, 192.168.0.0/19 indicates a range from 192.168.0.0 to 192.168.7.255 (first and last reserved as broadcast within the subnet) and 84.25.225.61/14 (which is an IP address in the city I was born in - coincidentally -
http://whois.domaintools.com/84.25.225.61) in a subnet between 84.24.0.0 to 84.31.255.255. Write down the IP addresses in hexadecimal, binary or octal form to make this more clear.