In this lesson, we will learn IP address concept in detail.
What is IP address?
An IP address stands for internet protocol address. IP address is a unique identity of a device. It means it uniquely identifies a device on the internet. Every device requires an IP address to connect to internet. Without an IP address a device can’t access internet. So, this way you can understand the importance of IP address in computer networking.
IP address is a string of binary numbers in the form of 1 and 0.
Ex- 10101110 11110011 11111000 00101010
This is an example of 32 bit IPv4 address. Similar way in IPv6, we have 128 bits.
In above example we divided 32 bits into 4 pairs. Each pair consist 8 bits. (8bits = 1 octet).
So, in IPv4 we have 4 octets.
Decimal dotted representation of above IP – 184.108.40.206
Note: In binary number system we have only two bits 1 and 0. So, whenever you read data in binary format or something like that it means it is in the form of 1’s and 0’s.
2 Types of IP Address
IPv4 address (32 bits address)
IPv6 Address (128 bits address)
Note: Here v stands for version. So, we can expand like that IP version 4 and IP version 6.
How I can check IP address of my computer (for windows)?
- Go to the desktop, now type cmd in the window search bar and hit enter button.
- After that command prompt screen will be open.
- Look carefully, there will be a cursor blinking, now just type ipconfig.
- Go to the desktop, now type “ncpa.cpl” in the window search bar and hit enter.
- Now a dialog box will appear on your screen to shows network connection.
- Click on the network from which you are connected, then a dialog box will appear.
- In this dialog box, there is a detail option, click on that.
- Now you able to see the IP address of your computer.
What are the classes of IPv4 Addresses?
IPv4 Addresses are divided into 5 Classes, These are divided by IANA :- Internet Assigned Number authority.
- Class A (1-126)
- Class B (128-191)
- Class C (192-223)
- Class D (224-240)
- Class E (241-239)
Class A, Class B and Class C IP address are used to assign IP to hosts (a host can be a router, switch, PC, mobile)
Class D IP address are used for multicasting purpose.
Class E IP address reserved for future use, but these address are not compatible with any device, so now they are wasted.
Now we will discuss some important parameters that are very important:
IPv4 address has 32 bits.
Ex- 10101110 11110011 11111000 00101010
For Class A-
- First 8 bits are network bits and rest 24 bits are host bits.
- Subnet mask for Class A: 255.0.0.0
- Prefix length: 8 (prefix length represents the no. of network bits.)
For Class B-
- First 16 bits represent network bits and remaining 16 bits represent host bit.
- Subnet mask for class B: 255.255.0.0
- Prefix length: 16
For Class C-
- First 24 bits are network bits and remaining 8 bits are host bits.
- Subnet Mask for class C: 255.255.255.0
- Prefix length: 24
No. of Networks
Addresses per Network
How to Calculate Subnet Mask?
It is a very easy process, once you will learn the method then you will calculate for any prefix length.
Replace all the network bits by 1 and all the host bits by 0.
Now we will do 1 problem to understand this in more clear way-
- 192.168.1.0/24 – (Class C address with prefix length 24. As I told you earlier prefix length represents network bits. So, here we have 24 network bits and 8 host bits.)
- First perform binary to decimal conversion.
192 . 168 . 1 . 0
- Now replace all network bits by 1 and all host bit by 0.
- Now again perform binary to decimal conversion and here we have
How we recognize the IP address class?
By looking at the first octet, you can recognize the class of an IP address.
For Class A: first binary octet is 0xxxxxxx. Here, you can see for Class A first bit of first octet is 0. Here x means it could be either 0 or 1.
In decimal notation, first octet always will be lies in the range of 1 – 126. And rest lie in the range of 0-255. First octet decimal range is 1 -126.
For Class B: first binary octet is 10xxxxxx. So, you can see for Class B first 2 bits of first octet always will be 10.
Decimal Octet range: 128-191
For Class C: First binary octet always will be 110xxxxx.
Decimal Octet range is 192-223.
For Class D: First binary octet always will be 1110xxxx.
For Class E: First binary octet always will be 1111xxxx.
Although, Class D and Class E address will not used in configuration.
What is Public IP?
Public IP is provided by Internet service provider (ISP). Public IP is globally unique. A host with private IP can’t go to the internet. So, whenever a host sitting in our LAN network, want to go on internet, first router performs NAT to convert private into public IP then it forwards the request to the internet.
What is Private IP?
Private IP is used in LAN network only. Sometimes, private IP also called LAN addresses. Private IP is uniquely defined in a LAN network. It means inside a LAN network, you can’t assign same IP address to 2 different hosts. Although, you can assign same IP address in 2 different LAN networks.
There are certain addresses in each class of IP address that are reserved for Private Networks.
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
What is static IP?
Static IP is not a type of IP, it’s kind of terminology. When an IP address is manually configured in a host then it is called as static IP. And the reason is manually configured IP will not change until you change it manually. We mostly configure IP address manually in routers and switches.
What is Dynamic IP?
When an IP address is configured through DHCP then it is called as dynamic IP. Mainly for LAN network we configure DHCP server. DHCP server automatically assigns the IP to the hosts.
What is APIPA address?
APIPA stands for Automatically Private IP Address Assignment. When DHCP server fails, automatically an IP address is generated and this address is called as APIPA address. APIPA assigns a class B address, range from 169.254.0.0 to 169.254.255.255.
Expected Interview questions from IP addressing concept are- (for freshers)
- What is a bit? ( I know this is very basic question, but I remember in one of my interview, interviewer asked this question.)
So, I answered bit is the smallest unit of data. In binary we have 2 bits that are 1 and 0.
- How many bits in IPv4 address?
- How many bits in IPv6 Address?
- How many classes in IPv4 Address? Define all classes with their address range.
- What are public IP and Private IP?
- What are static IP and Dynamic IP?