TimeLinux1

Sunday, February 13, 2011

Linux: Networking Part - 3

-in ipv4, where the ip addr is 4  bytes long, the boundary between the n/w and host portions is set by the sa.
-in ipv6, where the ip addr is 16 bytes long, the n/w and host portions are 8 bytes each.
-in olden days, ipv4 addresses were divided into 5 classes--A, B, C, D, E.
-of these, class A, B, C are common; class D & E are usually reserved for research purposes.
-the first bytes of class A = 1-127, class B = 128-191, class C = 192-223
-in these days, ipv4 addresses are  preferably represented in Classess notation. This makes more efficient use of addresses.
-subnet mask or netmask is a way to use ipv4 addresses more efficiently.
-subnet mask assigns part of the host portion of the ipv4 address to the n/w portion.
-in other words, this means you can have more smaller n/w than few big n/w.
-subnet mask is 4 bytes long where the 1s are n/w part and 0s are host part.
-the 1s are leftmost and contiguos; atleast 8 bits must be allocated to the n/w portion and 2 bits to the host part.
-this means there can be only 22 distinct ipv4 netmask values (32-10=22).
-netmask are set using the ifconfig cmd for each network interface.
-if netmask is not set, the network interface takes up the default class of ip addr.
-netmask need not end at a byte boundary.
-in those cases, the ip addr is denoted with a /xx entry to denote the bits associated with the n/w part.
-this is called CIDR (or classless inter domain routing).
-eg: 128.138.243.0/26    => a network address in cidr notation.
-in this example there are 32-26=6 bits for the host part. these 6 bits come from the 4th byte of the ip addr.
-since the 4th byte (like any byte) is 8 bits, the n/w part gains two bits (8 bits for a byte - 6 bits for host part)
-so the 4th byte could be 0 (00000000), 64 (01000000), 128 (10000000) or 192 (11000000).
-since a subnet represents the n/w part as all 1s, therefore in the above example (128.138.243.0/26):
    . the subnet would be 11111111.11111111.11111111.11 00000        or
    . 255.255.255.192   
-trick: if you know the net size (ie number of hosts or number of bits to the host portion) then:
    . last netmask byte = 256 - netsize
-in the above example, /26 => net size = 2 to the 32-26 = 2 to the 6 = 64
    => the last netmask byte = 256 - 64 = 192.
-also, the last byte of the network address must be divisible by network size.
-given an ip address, to tell its network and broadcast address, we need the netmask.
-eg: if ip=192.168.1.1/16, netmask=255.255.0.0, n/w addr=192.168.0.0/16, broadcast=192.168.255.255
-or  if ip=192.168.1.1/30, netmask=255.255.255.252, n/w =192.168.1.0/30, broadcast=192.168.1.3

Next up, CIDR...

No comments:

Post a Comment