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 A | Class B | Class C | |
|---|---|---|---|
| Range | 1.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 possible | 128 | 16,384 | 2,097,152 |
| Max No. of Hosts possible | 16,777,216 | 65,536 | 256 |
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
- Class A:
- Network ID bit is represented by
1and Host is represented by0 - 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.*.*.*
- Private:
- Class B:
[128-191].*.*.*- Private:
172.[16-31].*.*
- Private:
- Class C:
[192-223].*.*.*- Private:
192.168.*.*
- Private:
- We don’t need to purchase private IPs
- We can purchase Network ID
Reserved IP addresses
- https://en.wikipedia.org/wiki/Reserved_IP_addresses
- https://developer.apple.com/documentation/network/ipv4address/loopback#Setting-Well-Known-Addresses
- Current Network
0.0.0.0/8: range of0.#.#.#
- Private Ranges
10.0.0.0/8: range of10.#.#.#172.16.0.0/12: range of172.[16-31].#.#192.168.0.0/16: range of192.168.#.#
- Loopback address
127.0.0.0/8: range of127.#.#.#
- Link-local address
169.254.0.0/16: range of169.254.#.#
- Broadcast
255.255.255.255/32: exactly255.255.255.255
loopback address
- address of loopback Interface
- IPv4:
127.0.0.1 - IPv6:
::1
- IPv4:
- 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
lo0revealed byifconfig - In Windows probably it is not shown
- In Linux it is named
lorevealed byifconfig
- In MacOS it is named
- Reserved domain name
localhostpoints 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