Up till now, I've been talking about IP addresses and specifying the netmasks by spelling them out: network 192.168.13.0 with a netmask of 255.255.255.0. I've explained that the netmask indicates the bits that are the network part of the address, and that changing anything in those bits puts you on a different network or subnet.
Is there any real difference between a network and a subnet? Not really. Any network is a subnet of something larger, so in that sense, the terms are identical. However, you could look at this another way: your network is the addresses which you can subnet. Or, your network is the bits you cannot change because someone else assigned them to you. As it's always just the number of bits that is important, we can represent networks or subnets another way. The network 192.168.0 with that 255.255.255.0 netmask can be expressed as 192.168.13.0/24. The "24" is the number of bits set to "1" (remember, 8 bits in each section of a mask).
So, a 255.0.0.0 netmask would be /8, a 255.255.0.0 would be /16 and so on. Those are pretty easy. What about masks like 255.255.240.0? If you aren't used to thinking in bits, this might give you a little headache. But don't panic, it's not that hard. One way to think of it is how many bits are not set in the third octet. We have 8 each set in the first two, so that's 16, and it would be 24 if all the bits were set in the third, but bits adding up to 15 (255 - 240) are missing. That's the 8-4-2-1 bits (8 + 4 + 2 + 1 = 15), so 4 bits are missing, so it is a 20 bit mask: /20.
More Articles by Tony Lawrence © 2011-08-23 Tony Lawrence
Technology is both a tool for helping humans and for destroying them. This is the paradox of our times which we're compelled to face. (Frank Herbert)
---January 8, 2005
The line:
When it comes to /30, I think of that as two bits less than /32. A /32 gives you no address at all (well, it's one address but it's useless). So /31 is 2 addresses (still useless) and /32 is 4 addresses (but still only two useable).
Should read:
and /30 is 4 addresses (but still only two useable).
I think...?
---January 8, 2005
Yes, thank you - fixed.
--TonyLawrence
---January 23, 2005
The line:
A mask of 248 gives you 6 addresses: 256 - 248 is 8, minus the top and bottom equals 8.
Should read:
is 8, minus the top and bottom equals 6.
Ivan
---January 23, 2005
Thank you, corrected.
--TonyLawrence
Sun Jun 22 07:03:31 2008: 4355 NickPowers
/32 is used with PPP in dial-up Internet. It assigns a single IP address to the machine with a 255.255.255.255 netmask and the system uses that same IP address as it's default gateway. This causes the system to use the PPP link for it's default gateway (route of last resort). If you have ever worked at an Internet Service Provider (ISP) you would see many /32 subnets.
Nick Powers
Sun Jun 22 07:25:32 2008: 4356 NickPowers
Although /30 may seem silly since it only has two usable addresses but it is one of the most used subnets. It is used for creating point to point connections. For example, if I was an ISP and you bought a T1 circuit from me and I wanted to give you a /24 network (256 IP) I would first use a /30 to establish the 2 ends of the T1 circuit, one on your end and one on my end. Once I had done this then I would put a route in my router routing the /24 to the IP address I assigned to your end of the /30. This also is how DSL providers set up DSL circuits. I have often wondered why Cable modem providers don't use this method but they don't.
So say I have a /30 100.100.100.0/30 (which gives me 100.100.100.0 as a network address, 100.100.100.1 and 100.100.100.2 as usable IP addresses and 100.100.100.3 as my broadcast address). Also following the scenario above I want to route over 100.100.1.0/24 to you then I could do this:
ISP Router(100.100.100.1)-------T1 LINE-------YOU(100.100.100.2)
route add 100.100.1.0 255.255.255.255 100.100.100.2
So, you would have a router with 2 interfaces one is T1 and one is Ethernet. The T1 interface would be 100.100.100.2/30 and your Ethernet interface (the one you would set the computers on your Ethernet segment as their default gateway) could be any of the 100.100.1.0/24 but the most likely suspect would be 100.100.1.1/24 and then you would assign 100.100.1.2-100.100.1.254 for systems.
Your router would look like this:
----T1----(100.100.100.2/30)----Ethernet--(100.100.1.1/24)
Hope this helps
I agree though that /31 is useless, if anyone knows a practical use for this subnet please email me because I have never seen it used.
Nick Powers
Sun Jun 22 07:30:26 2008: 4357 NickPowers
oops this:
route add 100.100.1.0 255.255.255.255 100.100.100.2
should read:
route add 100.100.1.0 255.255.255.0 100.100.100.2
the previous is a /32 mask and the later is a /24.
Sorry for the mistake (it's late!)
Nick Powers
Tue Aug 23 22:30:12 2011: 9733 NickBarron
Just having a trawl through these old articles, interesting and still very useful.
Thanks for showing the usage of /32 Nick
------------------------
Printer Friendly Version
Understanding CIDR Copyright © November 1998 Tony Lawrence
Have you tried Searching this site?
This is a Unix/Linux resource website. It contains technical articles about Unix, Linux and general computing related subjects, opinion, news, help files, how-to's, tutorials and more.
Contact us
Printer Friendly Version