Wednesday, November 20, 2013

IP Networks and Subnets

What Do All Those Numbers Mean?

Your basic network device needs a couple pieces of information to be able to send and receive traffic.

First of all, it needs an address. As you can see in Internet Addressing, it can have a host name type of address. But it always has to have a numerical IP address. If it has a host name, that's just so that we can type it in and a computer can look up the numerical address.

Ok, so each device has to have an IP address. We will talk here about "IPv4", which is the standard set of IP protocols we've been living with for decades. In IPv4, IP addresses are 32 binary digits, but they are normally written as four decimal numbers separated by dots.

For example, my server at home is And my client machine is

You see how the first bunch of numbers are all the same? That's because the client and the server are on the same network. You can call it a "subnet" if you like. A subnet is basically a bunch of computers that can talk to each other directly without going through a router.

So the next piece of information each device needs is a "subnet mask". A subnet mask looks like an IP address, but it normally starts with 255, which a normal IP address would never start with. The computer can tell if another computer is on the same subnet by comparing it's own address with the other address, and seeing if the subnet part of the address is the same.

In computerese, that might look like:
if ((my_address & subnet_mask) == (his_address & subnet_mask)) then

A good point to note is that we don't care if the other computer's subnet mask is the same as ours. We only use our own subnet mask to make the comparison.

How does this help? Well, if I have another server on my network with the address, the subnet mask will determine if they are on the same subnet, which means they can talk directly, or if they are on different subnets and have to talk through a router (also called a gateway).

In this example, if the subnet mask is, then they are on the same subnet. But more commonly, the subnet mask would be, and they would be on different subnets.

That leads to the third piece of information your device will usually need - a default gateway. The default gateway is an IP address of a router (or "gateway") that will forward traffic for us to different subnets.

You can have very complicated networks with multiple routers handling different subnets, or if you are viewing this at home from behind your broadband router, you probably have only that router to worry about.

Let's look at some examples:

For my client machine at home,
    IP address =
    Subnet mask =
    Default gateway =

The first value will vary, but almost all broadband routers default to the subnet mask and default gateway shown here.

Another example - a computer in a lab at a university
    IP address =
    Subnet mask =
    Default gateway =

And a final example, for a really tiny network with only two devices on it,
    IP address =
    Subnet mask =
    Default gateway =

No comments:

Post a Comment