TimeLinux1

Tuesday, September 28, 2010

Linux HowTo: IPv4 Addressing Basics

The Internet Protocol (IP) is part of the TCP/IP stack. IP is the protocol that is responsible for addressing the nodes on a network. The most common example of such a network where this is in play is the Internet. The IP protocol helps uniquely identify each node on the Internet. The IP addressing scheme we currently see in use is the version 4 and is called ipv4 for short. An ipv4 address is 32 bits long and is represented as 4 dot separated decimal numbers between 0 and 255 (eg 192.168.1.1 or 10.10.1.10 note: the first number cannot be zero) for human readability (the computers translate it to binary for their communication). ipv4 can support about 4 billion addresses, but since the Internet is growing explosively, 4 billion is just not enough. Therefore the new version 6 of IP (ipv6) has been developed and it can support a mind blowing number of hosts (how about 1 followed by 38 zeroes - yes, that big !!). However, in this post we limit to ipv4.
===

-Every IP v4 address has four 8 bit octets represented like N.N.H.H, where N vary between decimal 1-255 and H vary between decimal 0-255 (note the first octet cannot be zero ie an IP address cannot start with 0); example 172.10.1.2. The IP address can be divided into a network part (N.N) and a host part (H.H) . The network part identify the network type and the host part identify the individual hosts in that network. Depending on the value of the network part the network can be classified as A, B, C and D type network as shown below:
-ipv4 network type & octets:
        - class A        - 0 - 126
        - class B        - 128 - 192.167                [ 127 reserved for localhost ]
        - class C        - 192.169 - 223                [ 192.168 reserved for private n/w ]
        - class D        - 224 - 255                       [ reserved, not used ]
-private IP reservations [ ie IP addresses not accessible on the Internet (eg personal home network) as opposed to public IP which are publicly accessible on the Internet ]
        - 10.0.0.0   
        - 172.16 - 172.31
        - 192.168

Closely related to the IP address of a host is its Subnetwork mask or subnet mask or simply the netmask.
-netmask    -  is a special representation of the ip address with n/w part as 255 and host part as 0.
                  -  it tells the ip stack, what part is the n/w addr and what part is the host.
                  -  the nic uses netmask to decide if the destn of the pkt belongs in this subnet or needs to be routed.

-netmask    with Binary AND to    n/w addr    =    ip addr
-netmask    with Binary AND to    ip    addr    =    n/w addr
   
-network addr / numb    =>    network addr / number of bits in the netmask
                    =>    network addr / 32 - number of hosts possible in that network.
-note:    In the more recent Classless Internet Domain Routing (CIDR) IP nomenclature, netmasks don't need to fall on class boundaries. This increases the available IP addresses for the Internet and thereby making more effective usage of the available 4 billion plus IP addresses in ipv4.

No comments:

Post a Comment