Friday, 13 June 2014

IPv4 Addressing, Subnetting and CIDR

IP Addressing:
An IP (Internet Protocol) address is a unique identifier for a node or host connection on an IP network. An IP address
is a 32 bit binary number usually represented as 4 decimal values, each representing 8 bits, in the range 0 to 255
(Known as octets) separated by decimal points. This is known as "dotted decimal" notation.

Example: 140.179.220.200

It is sometimes useful to view the values in their binary form.
140 .179 .220 .200
10001100.10110011.11011100.11001000

Every IP address consists of two parts, one identifying the network and one identifying the node. The Class of the
address and the subnet mask determine which part belongs to the network address and which part belongs to the
node address.
Address Classes:
There are 5 different address classes. You can determine which class any IP address is in by examining the first 4
bits of the IP address.

Class A addresses begin with 0xxx, or 1 to 126 decimal.
Class B addresses begin with 10xx, or 128 to 191 decimal.
Class C addresses begin with 110x, or 192 to 223 decimal.
Class D addresses begin with 1110, or 224 to 239 decimal.
Class E addresses begin with 1111, or 240 to 254 decimal.


Addresses beginning with 01111111, or 127 decimal, are reserved for loopback and for internal testing on a local
machine. [You can test this: you should always be able to ping 127.0.0.1, which points to yourself]
Class D addresses are reserved for multicasting.
Class E addresses are reserved for future use. They should not be used for host addresses.

Now we can see how the Class determines, by default, which part of the IP address belongs to the network (N) and
which part belongs to the node (n).

Class A -- NNNNNNNN.nnnnnnnn.nnnnnnn.nnnnnnn
Class B -- NNNNNNNN.NNNNNNNN.nnnnnnnn.nnnnnnnn
Class C -- NNNNNNNN.NNNNNNNN.NNNNNNNN.nnnnnnnn

In the example, 140.179.220.200 is a Class B address so by default the Network part of the address (also known as
the Network Address) is defined by the first two octets (140.179.x.x) and the node part is defined by the last 2 octets
(x.x.220.200).

In order to specify the network address for a given IP address, the node section is set to all "0"s. In our example,
140.179.0.0 specifies the network address for 140.179.220.200. When the node section is set to all "1"s, it specifies a
broadcast that is sent to all hosts on the network. 140.179.255.255 specifies the example broadcast address. Note
that this is true regardless of the length of the node section.

Private Subnets:
There are three IP network addresses reserved for private networks. The addresses are 10.0.0.0/8, 172.16.0.0/12,
and 192.168.0.0/16. They can be used by anyone setting up internal IP networks, such as a lab or home LAN behind
a NAT or proxy server or a router. It is always safe to use these because routers on the Internet will never forward
packets coming from these addresses
Subnetting an IP Network can be done for a variety of reasons, including organization, use of different physical media
(such as Ethernet, WAN, etc.), preservation of address space, and security. The most common reason is to
control network traffic. In an Ethernet network, all nodes on a segment see all the packets transmitted by all the other
nodes on that segment. Performance can be adversely affected under heavy traffic loads, due to collisions and the
resulting retransmissions. A router is used to connect IP networks to minimize the amount of traffic each segment
must receive.

Subnet Masking
Applying a subnet mask to an IP address allows you to identify the network and node parts of the address. The
network bits are represented by the 1s in the mask, and the node bits are represented by the 0s. Performing a bitwise
logical AND operation between the IP address and the subnet mask results in the Network Subnet or host ID.
For example, using our test IP address and the default Class B subnet mask, we get:
10001100.10110011.11110000.11001000 140.179.240.200 Class B IP Address
11111111.11111111.00000000.00000000 255.255.000.000 Default Class B Subnet Mask
10001100.10110011.00000000.00000000 140.179.000.000 Network Subnet


Default subnet masks:
Class A - 255.0.0.0 - 11111111.00000000.00000000.00000000
Class B - 255.255.0.0 - 11111111.11111111.00000000.00000000
Class C - 255.255.255.0 - 11111111.11111111.11111111.00000000

IPv4 subnetting
The process of subnetting involves the separation of the network and subnet portion of an address from the host identifier. This is performed by a bitwise AND operation between the IP address and the (sub) network mask. The result yields the network address or prefix, and the remainder is the host identifier.

Subnetting

Subnetting is the process of designating some high-order bits from the host part and grouping them with the network mask to form the subnet mask. This divides a network into smaller subnets. The following diagram modifies the example by moving 2 bits from the host part to the subnet mask to form four smaller subnets one quarter the previous size:
Binary form
Dot-decimal notation
IP address
11000000.10101000.00000101.10000010
192.168.5.130
Subnet mask
11111111.11111111.11111111.11000000
255.255.255.192
Network prefix
11000000.10101000.00000101.10000000
192.168.5.128
Host part
00000000.00000000.00000000.00000010
0.0.0.2

Subnet and host counts

The number of subnetworks available, and the number of possible hosts in a network may be readily calculated. In the example (above) two bits were borrowed to create subnetworks, thus creating 4 (22) possible subnets.
Network
Network (binary)
Broadcast address
192.168.5.0/26
11000000.10101000.00000101.00000000
192.168.5.63
192.168.5.64/26
11000000.10101000.00000101.01000000
192.168.5.127
192.168.5.128/26
11000000.10101000.00000101.10000000
192.168.5.191
192.168.5.192/26
11000000.10101000.00000101.11000000
192.168.5.255

CIDR (Classless Inter-Domain Routing or supernetting)


CIDR (Classless Inter-Domain Routing, sometimes known as supernetting) is a way to allocate and specify the Internet addresses used in inter-domain routing more flexibly than with the original system of Internet Protocol (IP) address classes. As a result, the number of available Internet addresses has been greatly increased. CIDR is now the routing system used by virtually all gateway hosts on the Internet's backbone network. The Internet's regulating authorities now expect every Internet service provider (ISP) to use it for routing.

A network is called a supernet when the prefix boundary contains fewer bits than the network's natural (i.e. classful) mask. A network is called a subnet when the prefix boundary contains more bits than the network's natural mask.
Examples
209.60.128.0 is a class C network address with a natural mask of /24.
209.60.128.0 /22 is a supernet which yields:
209.60.128.0 /24
209.60.129.0 /24
209.60.130.0 /24
209.60.131.0 /24

And A CIDR network address looks like this:
192.30.250.00/18
The "192.30.250.00" is the network address itself and the "18" says that the first 18 bits are the network part of the address, leaving the last 14 bits for specific host addresses. CIDR lets one routing table entry represent an aggregation of networks that exist in the forward path that don't need to be specified on that particular gateway, much as the public telephone system uses area codes to channel calls toward a certain part of the network. This aggregation of networks in a single address is sometimes referred to as a supernet.
CIDR is supported by the Border Gateway Protocol, the prevailing exterior (interdomain) gateway protocol. (The older exterior or interdomain gateway protocols, Exterior Gateway Protocol and Routing Information Protocol, do not support CIDR.) CIDR is also supported by the OSPF interior or intradomain gateway protocol.





No comments:

Post a Comment