I'M taking a Linux/Unix admin course from the Oreilly online school. But I'M having a hard time understanding tcp/ip section, it's really making my head spin. Here is some of the lesson, could someone please help clear this up for me? thanks.
Network, Broadcast, and Subnets
Let's give ourselves a class C network of 192.168.1.xxx. Two of the addresses are automatically used up--the network address of 192.168.1.0 and the broadcast address of 192.168.1.255. The network address is used when referring to the network itself, and the broadcast address is used to refer to all of the hosts on that network. This means you can have 254 hosts on the network. That's quite a few hosts to connect on the same IP network! We need a way to split up the network into smaller parts.
All classes also have what's called a subnet mask. By default a class C network has a subnet mask of 255.255.255.0. (Note that the "on" bits are the same ones represented by red x's in the table above.) In fact, this default mask is really the only thing the old class structure is used for anymore. By changing the subnet mask, we can split up the large IP network into two or more smaller networks. The subnet mask is then used to determine which portion of an IP address defines the network and which defines the host. Let's look at our network again:
11111111 11111111 11111111 00000000 subnet mask (255.255.255.0)
11000000 10101000 00000001 00000001 ip address of the first host (192.168.1.1)
Now let's split it into two subnets instead of one. We'll do this by converting one of the host bits into an additional network bit. The new subnet mask would be as follows:
11111111 11111111 11111111 10000000 (255.255.255.128)
But now, we have two networks and two broadcast addresses as well. This is because the green number, although part of the network portion, can be either a one or a zero. For the network addresses, all of the host bits are 0 and for the broadcast addresses, all of the host bits are 1.
11000000 10101000 00000001 00000000 1st network address (192.168.1.0)
11000000 10101000 00000001 01111111 1st broadcast address (192.168.1.127)
11000000 10101000 00000001 10000000 2nd network address (192.168.1.128)
11000000 10101000 00000001 11111111 2nd broadcast address (192.168.1.255)
The subnet mask is useful because when coupled with a host IP address, it provides all of the necessary information about a subnet. Let's say we're given the following pair:
subnet mask: 255.255.255.128
host address: 192.168.1.140
The subnet mask lets us determine the network and host parts of the IP address. From this IP address and subnet mask, we know the network and broadcast addresses for all of the subnets, as well as which subnet contains the host (which happen to be the second set from above).
The subnet mask is like a filter telling us which parts are for the network and which are for the hosts. But why not just give the IP address and network address? Isn't that enough to describe it? Not really.
network address: 192.168.1.0
host address: 192.168.1.22
From this pair we know that the host is on the 192.168.1.0 network. However, there is no way of knowing whether that network is split into multiple subnets or not. We don't know if 192.168.1.140 is on the same subnet as 192.168.1.22.