What is IP Address
IP address is a unique address which is given to each device that is present in any network.
But before going to IP Addresses we need to understand what an address is and then I think we should be able to understand clearly.
We can divide addresses (Not IP Address) in two parts: –
- Physical address
- Logical address
Physical address is MAC address or Media Access Control address is the address given to any network card. If a machine have multiple network cards, it will have multiple MAC addresses.
You can check MAC address by typing below commands.
But we are more interested in IP Addresses so will bypass this topic here and go to Logical addresses.
Logical address is an IP Address. Logical address can be divided into two parts IPv4 and IPv6.
IPv4 is Internet Protocol version 4. And this is the most used Internet Protocol over the internet.
IPv6 internet protocol version 6 and would be used mostly in future.
IPv4 or IP Address
So going further in this article we will refer IPv4 as Internet Protocol or IP.
Whenever we say its internet protocol or IP, it means we are talking about IPv4.
We can understand this by using below example.
I have a friend living in New York and I want to send a letter from London to him, where I am living. To do this communication we must know the address of our friend who is living in New York. Without knowing the complete address of my friend I cannot send him the letter. This address includes his house number, society, City, country and pin-code.
Similarly I want to send email to my friend I must know his address over internet. And this address would be his IP Address.
There are some things about IP which we should know:
- IP Address is a 32 bit logical address
- It is divided into 4 octets
- Each octet is made up of 8 bits
- Each octet can have values between 0 255
- Each IP can be divided into two parts Network ID and Host ID
Now suppose we have an IP: 184.108.40.206
We can see in the above diagram that this have 4 octets of 8 bits each.
And if calculate 8*4 we get 32 which becomes the total size of an IPv4 Address.
Here we are going to see some valid and invalid IP Address examples.
|10.1.0.256||This IP is Incorrect as it have value 256 in 4th octet which is greater than 255|
|156.2.560.3||This IP Address is Incorrect as it have value 560 in 3rd octet which is greater than 255|
IPV4 Classes or Classes in IP Address
There are 5 classes of IP or IPv4 Address
|Class A||This ranges from 220.127.116.11 to 18.104.22.168|
Class A IP Addresses are used for large networks
|Class B||This ranges from 22.214.171.124 to 126.96.36.199|
|Class C||This ranges from 192.0.0.0 to 188.8.131.52|
Class C IP Addresses are used for small networks
|Class D||This ranges from 184.108.40.206 to 220.127.116.11|
Class D IP Addresses are used for multicast
|Class E||This ranges from 240.0.0.0 to 255.255.255.255|
Class D IP Addresses are used for multicast
For designing our networks we use class A, class B or Class C IP addresses. We generally don’t use class D and class E IP addresses for designing on networks. So in further discussion we will focus only on Class A, B and C networks.
Examples of IPs
Here are some examples of IP Addresses. You can verify the classes of these IPs from above section.
Missing IP range OR Localhost
If you look carefully, when we are going from class A class B there is an IP range 127.x.x.x which is missing. Where the range has gone?
One of the things that is not so good is that a decision was made long ago about the size of an IP address – 32 bits. At the time it was a number much larger than anyone could imagine ever having that many computers but it turned out to be to small.
– Jon Postel
The story behind it: When the IPv4 was being designed, the people who were designing it assumed that they have designed a very large number of IP Addresses and they would not need more than that in future. So they dedicated a complete IP Address range which is 127.x.x.x as a loopback range, though only a single IP which is 127.0.0.1 is used as a localhost from this range. So that seems to be a mistake now as we know that there is a shortage of IPv4 addresses and to overcome this IPv6 has to be designed.
Network and Host in an IP Address
An IP of any class is divided into two parts
- Network part
- Host part.
Network part determine how many bits or octets of that particular IPv4 has been dedicated to network.
Host part determine how many bits or octets of that particular Address are dedicated to hosts or we can say that how many hosts or machines can be created in that particular network.
For each class this Network and host part varies.
To understand this we will see some diagrams.
Class A: In class A IPs, first octet is reserved for Network and the remaining octets are for Host.
Class B: In class BAddress, first two octets are reserved for Network and the remaining octets are for Host.
Class C: In class C IPv4, first three octets are reserved for Network and the remaining octets are for Host.
Network ID of an IP Address
Network part of an IP is called its Network ID.
How to find network IDs in IP Addresses
Suppose we have an IP 10.40.1.25 which is of Class A .
We can see that in class A IP Address the first octet is reserved for Network part, and we need to find the Network ID so we will replace Host part by 0. What we get now is the Network ID of this IP Address.
If we take a Class B IP Address: 18.104.22.168
The Network ID of this IP Address will be: 22.214.171.124
This is because in Class B we denote first two octets of IP Address as Network bits and remaining as Host bits.
Public and Private IP Address
Now we are going to discuss a little bit about public and private IP Addresses
Public IP Address
A public IP Address is an IP Address that can be accessed over the internet. It is assigned to a machine or a computer which is connected to internet and it is globally unique. There are no two devices present on internet can have same IP Address. It means if you have a public IP Address and it is associated with your laptop then no one in this world can have the same IP Address.
Public IP Address has to be purchased from vendors. One such vendor is GoDaddy.
Private IP Address
The IPs which are used inside LAN are called Private IP Addresses. We don’t need to purchase these from anywhere.
Each class has a range of private IP Addresses.
|Class||IP Address range|
|Class A||10.0.0.0 to 10.255.255.255|
|Class B||172.16.0.0 to 172.31.255.255|
|Class C||192.168.0.0 to 192.168.255.255|
Why we need Private IP Addresses
There is a limited number of Public IP Addresses. So in a network we need to be cheeky in usage of Public IPs. So we can purchase a single Public IP Address, assign it to a router and use Private IPs inside the network. To send the traffic from Private IP to the outside of network or internet, we would need a NAT device so that the receiver will think that the traffic is coming from Public IP Address. In case the traffic comes from outside the network for that Private IP , NAT will translate that Public IP to Private IP Address.
Broadcast IP Address
The biggest IP Address which can happen in a network is the broadcast IP of that network. If we send any data or traffic to that IP Address, this will be delivered to all the machines connected to that network.
If we have an IP 10.40.1.25, the Broadcast IP of this network is 10.255.255.255.