IP Address

  • Internet Protocol
  • IP address is the identity of hosts
  • Versions:
    • IPv4 (32 bits)
    • IPv6 (64 bits)
  • It is a Layer-3 protocol

IPv4

  • 192.168.39.240 [0-255].[0-255].[0-255].[0-255]
  • 32 bits = 4 octets (bytes) = 8 bits + 8 bits + 8 bits + 8 bits

Classes of IPv4

  • Generally Class A-C are used
  • Class A: [0-127].*.*.*
    • N.H.H.H
    • Used for big networks
    • Special IPs which cannot be used:
      • 127.*.*.* (Loopback Address: )
      • 0.*.*.*
  • Class B: [128-191].*.*.*
    • N.N.H.H
    • Used for medium to large organizations
  • Class C: [192-223].*.*.*
    • N.N.N.H
    • Used for small networks and home
  • Class D: [224-239].*.*.*
    • Used in multicast
  • Class E: [240-255].*.*.*
    • Used for Research
Class AClass BClass C
Range1.0.0.0 to
126.255.255.254
128.0.0.0 to
191.255.255.254
192.0.0.0 to
233.255.254.254
Max No. of Networks possible12816,3842,097,152
Max No. of Hosts possible16,777,21665,536256

Network and Host

  • IP address consists of Network ID and Host
  • Different octets are used for Network ID ( N ) and Host ( H )
  • Classes:
    • Class A: N.H.H.H
    • Class B: N.N.H.H
    • Class C: N.N.N.H
  • Network ID bit is represented by 1 and Host is represented by 0
  • Calculate Network ID of 115.10.0.15
    • Since the above IP belongs to Class A IP address, we only take the network octet and make other octets zero
    • Answer: 115.0.0.0
  • Calculate Subnet Mask of 115.10.0.15
    • Since the above IP belongs to Class A IP address, we only take the network octet and turn each bit to 1 (effectively 255) and make other octets zero
    • Answer: 255.0.0.0

Network ID and Broadcast ID

  • These are reserved IP addresses and are not “usable” IP address
  • Network ID IP address has 0 in all the host octets
  • Broadcast IP address has 255 in all the host octets
  • For 150.10.20.30:
    • It is a class B IP address
    • Network ID: 150.10.0.0
    • Broadcast ID: 150.10.255.255
    • We have 8+8 = 16 bits for host part, hence
      • Total IP addresses: possible permutations for Host octet (last 2 octets)
      • = 2^16 = 655,36
      • Total usable IP addresses = Total IP addresses - 2 {Broadcast ID and Network ID}
      • = 2^16 - 2 = 655,34

Private IP Ranges

  • Class A: [1-126].*.*.*
    • Private: 10.*.*.*
  • Class B: [128-191].*.*.*
    • Private: 172.[16-31].*.*
  • Class C: [192-223].*.*.*
    • Private: 192.168.*.*
  • We don’t need to purchase private IPs
  • We can purchase Network ID

Reserved IP addresses

loopback address

  • address of loopback Interface
    • IPv4: 127.0.0.1
    • IPv6: ::1
  • loopback interface is a virtual network interface which sends packet to the sender itself as if the packet came from real network interface
    • In MacOS it is named lo0 revealed by ifconfig
    • In Windows probably it is not shown
    • In Linux it is named lo revealed by ifconfig
  • Reserved domain name localhost points to the loopback address
  • Advantages
    • Allows developers to test applications locally before deployment
    • Ensures safe testing of sensitive applications without external exposure
    • Provides fast processing of requests without external routing
  • ref

0.0.0.0 address