Networking Notes
Categories:

IPv4:

Network classes:

An address is made up of the "network", the "subnet", then the "host" portions. The "network" is defined by the first 3 bits, and can be class A, B, C, etc... "Networks" are allocated to an organization. An organization can then subdivide the network into "subnets", by taking some of the bits allocated in the "host" portion of the address and using them to create subnetworks instead. The remaining bits are then allocated to the host portion of the address.

If an organization has a Class A network, uses a subnet mask of /24, it then has 8 bits per network to allocate to hosts. That leaves 254 hosts. An example would be 126.3.4.50. "126" is the Class A network address, "3.4" is the subnet, and "50" is the host address on that network.

Class A:

First bit in the address is a 0
Gives us the range of 0.0.0.0 - 127.255.255.255
First 8 bits are the "network" portion, the rest is the host address
2^24 (~4 million) hosts per network

Class B:

First 2 bits are 10
Ranges of: 128.0.0.0 - 191.255.255.255
First 16 bits are for the network, last 16 bits for host address
2^16 (65532) hosts per network

Class C:

First 3 bits are 110
Range of: 192.0.0.0 - 223.255.255.255
First 24 bits for network portion, last 8 bits for host addresses
2^8 (256) hosts per network

Class D, Class E:

...

Routers

Router can look at the first 3 bits and figure out if it's class A, B, or C, and can handle the packet.

Special Networks

Network 0

A network that starts with 0.something, like 0.1.2.3, is technically a Class A network, but it is not assigned publicly. It can be used inside a network to refer to "this" network only, but does not go outside of "this" network.

Subnet 0

When the subnet portion of an address is all zeros, (126.0.0.50), some older routers cannot handle this.

127

The last class A before class B. Allocated for loopback. 127.0.0.1 is typically used for loopback, but technically the whole range could be used if a machine was configured for it.

Class-less Subnets

The host address portion that is all 0's is reserved to identify the network itself, so it cannot be used as a host address.

IP address with all 1's on the host portion is reserved for broadcast.

/30 only allows 2 hosts. This is a good subnet to use if connecting 2 routers together.

/30 is really the smallest network you can have. A /31 only gives you a network and a broadcast, and no addresses available for hosts.