Saturday, December 18, 2010

Subnet Masks and Subnetting


I haven't work very much previously with network configuration but I am looking at more and more RAC issues recently.

I have started reading up to: Pro Oracle Database 10g RAC on Linux

This is a very good book, I have seen Julian present at an Oracle SIG before, and was rather baffled by the advanced RAC issues he tackled (I was a newbie DBA at the time). Still he had lots of enthusiasm and I have since read a number of presentation online.

Anyway while reading up about I decided I needed a refresher on the background network concepts:

The "Subnet Masks and Subnetting" webpage gives a simple example of how to use a 255.255.255.128 subnet mask to a create a restricted part in a class C network (e.g. 192.168.1.0) for a small enterprise.

Next I moved on to a more detailed explanation on wikipedia, subnetwork masks:

This logical addressing structure permits the selective routing of IP packets across multiple networks via special gateway computers, called routers, to a destination host if the network prefixes of origination and destination hosts differ, or sent directly to a target host on the local network if they are the same. Routers constitute logical or physical borders between the subnets, and manage traffic between them. Each subnet is served by a designated default router... The routing prefix of an address is written in a form identical to that of the address itself. This is called the network mask, or netmask, of the address. For example, a specification of the most-significant 18 bits of an IPv4 address, 11111111.11111111.11000000.00000000, is written as 255.255.192.0.

another important background concept for CIDR notation :

192.168.0.0, netmask 255.255.0.0 is written as 192.168.0.0/16
192.168.1.0, netmask 255.255.255.0 is written as 192.168.1.0/24

this concept is clearest by looking at the full binary format:

Binary form Dot-decimal notation
IP address 11000000.10101000.00000101.10000010 192.168.5.130
Subnet mask 11111111.11111111.11111111.00000000 255.255.255.0
Network prefix 11000000.10101000.00000101.00000000 192.168.5.0
Host part 00000000.00000000.00000000.10000010 0.0.0.130

so going back to the first example, which has a restricted access server on the 2nd half of there private class C network with IP 192.168.1.131, netmask 255.255.255.128 is written as 192.168.1.3/25

Binary form Dot-decimal notation
IP address 11000000.10101000.00000001.10000011 192.168.1.3
Subnet mask 11111111.11111111.11111111.10000000 255.255.255.128
Network prefix 11000000.10101000.00000101.10000000 192.168.1.1
Host part 00000000.00000000.00000000.00000011 0.0.0.3