FreeBSD subnetting help.

Hello, I’m currently reading Absolute FreeBSD and I don’t seem to get through the networking section because I don’t seem to totally grasp subnetting, it’s almost like taking 53 mg of Valium because I end up falling dead asleep.

I’m good with converting the 32 bit IP addresses from decimal to binary, I understand the CIDR notation, broadcast addresses and the network IDs. I can also understand the basic idea of borrowing bits from the host for the subnets, but I have no idea what IP addresses would get assigned to the subnets and hosts.

Example:

I want my network to have 4 subnets, so I would borrow 2 bits from the host, 2x2 = 4 and up to 62 hosts 2x2x2x2x2x2 = 64 – 2 = 62.

Network ID: 192.168.1.0
Subnet mask: 255.255.255.192 or /26

My question is, what IP addresses could I use for my subnets and what IP ranges could I use for my hosts on each subnet? Please care to explain how you get those. I’ve read so many articles about this to no avail, the more I read, the heavier I feel!
 
Writing the last octet as binary (with a separator), the 00 subnet covers the IP range:

192.168.1.00|000000 - 192.168.1.00|111111

Converting the last octet back into decimal gives a total IP range:

192.168.1.0 - 192.168.1.63

This is the network

192.168.1.0/26

The first and last addresses are reserved, so your hosts can have IPs:

192.168.1.1 - 192.168.1.62

For the second subnet, replace "00|" with "01|" and repeat:

binary: 192.168.1.01|000000 - 192.168.1.01|111111
range: 192.168.1.64 - 192.168.1.127
network: 192.168.1.64/26
hosts: 192.168.1.65 - 192.168.1.126

Use "10|" (.128) for the third subnet and "11|' (.192) for the fourth.

Here's a calculator to help.
 
For the second subnet, replace "00|" with "01|" and repeat:

binary: 192.168.1.01|000000 - 192.168.1.01|111111
range: 192.168.1.64 - 192.168.1.127
network: 192.168.1.64/26
hosts: 192.168.1.65 - 192.168.1.126

Use "10|" (.128) for the third subnet and "11|' (.192) for the fourth.

Here's a calculator to help.

I was getting confused with the first subnet IP. In my head I'm picturing router A as the main router for the other routers B, C, D, E meaning it has to have its own IP address of 192.168.1.0 then routing to the other subnet routers. The way you explained there is no router A, just a network ID of 192.168.1 and the data will route itself to the correct router depending on the last octet. Am I on the correct path in understanding this?
 
There are several tools in the ports which may help you do the math, so you don't have to think about it too much, try apropos subnet.

Generally, address and mask are 32 bit long integers. So 192.168.0.1 is in fact 3232235521 and computer sees it as 11000000110000000000000000000001. Then you have mask in exactly same form, which say what part of this number is network and which is host on this network. For example mask 255.255.255.0 would be 11111111111111111111111100000000. Now you can overlay (thus mask) second number over the first one like

[FONT=courier new]110000001100000000000000 00000001
111111111111111111111111 00000000
network part bits |hosts bits[/FONT]

and you have your network/hosts division. You don't want to have hosts bits scattered ale over the place, because ugly things would start happening pretty quick. So you have to have continuous ones for network part first and then continuous zeros for hosts at the end.

Because both of these forms are quit hard to remember, we have four octets notation. Split 32 bites into 4 bytes and you have
[FONT=courier new]11000000 11000000 00000000 00000001
192 168 0 1[/FONT]
and because we already know, that we really don't want to have non-continuous masks, that dictates where the network/hosts split can happen.

Regarding routing - it is quite easy. When both hosts are on same network, they know about each other on the ethernet level using ARP protocol. One host can send packets directly to the other. When they are not on the same network, they have to have either static route, saying this host/network is reachable via address xy or default route, where everything else is send in hope that some host somewhere would know how to reach given destination.
--
edit: looks like monospace isn't so much mono here, hope it is still understandable
And some online tools may help understand all this mess, I like http://subnetmask.info/ for example.
 
I was getting confused with the first subnet IP. In my head I'm picturing router A as the main router for the other routers B, C, D, E meaning it has to have its own IP address of 192.168.1.0 then routing to the other subnet routers. The way you explained there is no router A, just a network ID of 192.168.1 and the data will route itself to the correct router depending on the last octet. Am I on the correct path in understanding this?

Routers connect different networks, so the router's internal IP can be assigned from any of the 4 subnets or from a different network entirely (10.10.10.0/24) and it will still be happy to pass data between them unless prevented by firewalling.
 
Last edited:
Back
Top