So you must have heard of IP address a gazillion times. Every computer on TCP/IP must have an IP address. Ip address has four values separated with dots eg 188.8.131.52 but in actual a real IP address is just 32 bits of ones and zeros. the above decimal values are for us to understand easily.
whenever you write a phone number (221) 333-2323 you add dashes and parenthesis but you know those are for us humans only we will not write them which dialing the number the same is the case with IP.
Now you converting the IP to binary you can simply check the image below which shows you how IP is converted into a binary number.
So the above image shows the process of converting. For this conversion simply remember one number which is 128 after then your next number will be half of the previous number uptill you get to number one. for example, after 128 you will get 64 and in the end, we will sum all the bit which have binary number 1 below them.
ARP ( Address Resolution Protocol ):
ARP is a broadcast that is sent on a network that says I have this IP address if it is yours please respond back. Now the basic purpose of ARP is to get the MAC address of that PC so that PC will respond with his MAC address saying Yes this is my IP and here is my MAC address. You can use the command arp -a to find the cashed IP address on your PC.
Now the subnet mask is used to find if the request we are going to make is local ( within our network ) or not. If its local you can simply do ARP and get started talking with the host. But what if it’s not local. Well, then you have to go to some other network over the internet.
So that’s where the default gateway comes to play. You can say default gateway is a door technically its IP address of your Router. So if your Host which you want to talk to is from another network you will send that request to your Router using your Default Gateway and from there Router will forward that request.
Now subnet mask is used to find where to send the request but how? let’s say we have a subnet mask of /24 it will be 255.255.255.0 if you break it to binary same as an IP address you will find it has 24 ones and 8 zeros so that is why we are saying it /24. Now every IP which will be in this network will have the same sequence at first 3 pairs and 4th can be changed eg 184.108.40.206-255 ( Not you can not use 0 and 255 ) this will have all the IPs from 0 to 255 and they will be sent in the same network.
Now if the IP changes eg 220.127.116.11 now because of 42 it is a different network and we will have to send it to default gateway instead of ARP on your network.
Now on the internet you just can not assign any IP address to a computer there are a certain number of total IP address and they are assigned by IANA ( Internet Assigned Numbers Authority ). As this is a worldwide job so IANA doesn’t pass those IP addresses to individuals they assign them to RIR ( Regional Internet Registry ). These are RIRs that are further divided with respect to continents. After that RIRs pass on IP addresses to ISPs ( Internet Service Providers ) and you will get IP from your ISP.
Now for providing IP address how much a person needs they are divided into classes A, B, C, D & E. Class A is 0-126/8 so any IP starting from this range will be class A. Class B is 128-191/16 in this class you get 65534 IP address and class C start with 192-223/24. D and E are for research purposed only you can not use them.
Well, now the problem is if I get a class C I am still getting 254 hosts. So to solve that we do subnetting depending upon our needs. But this was old techniques to then CIDR ( classless Inter-Domain Routing ) was introduced.
In this technique subnetting moved from having /24. Now, what happened is we can do /25, /26 /27 and so on and the more /numb you have the less host you will be able to make. So with /24, you have 256-2 hosts available with /25 you have 128-2 hosts available and with /26 you have 65-2 hosts.
Now from the below image, you can easily understand which /* you want if you need a certain number of IP addresses for example if you need 4 IP addresses you will get a /29. So in short CIDR subnetting helps you decrease the no. of IP addresses you want.
DHCP ( Dynamic Host Configuration Protocol )
Every computer on the network must have an IP address, subnet mask, and default gateway. One thing that can happen is you enter a static IP address according to your configuration which will be static and the second thing you can do is let DHCP do this for you automatically.
Now the duty of DHCP is to assign IP addresses automatically but how this process takes place Client Broadcast a messaging saying I don’t have any IP address DHCP will offer the client an IP. Now either client will accept the offer or client will say can I just get the old IP which I had before.
Nowadays almost all routers have DHCP servers builtin. There should be one DHCP server within your network.
Now if you want to make sure that you are successfully running a DHCP server simple do ipconfig in windows and on your IP option check the IP address if it’s within your network range great your DHCP server is working. If the IP address starts with 169.254.x.x then there is a problem with your DHCP server and you have given an APIPA ( Automatic Private IP Addressing ) default IP address with is given if the DHCP server is not working.
Special IP Address
Now there are some groups of IP addresses that you should remember those can never be used on the internet and they are private.
1: Any IP address start with 10.x.x.x –> Private IP Address
2: Any IP address starts with 172.16.x.x to 172.31.x.x –> Private IP Address
3: Any IP address starts with 192.168.x.x –> Private IP Address
after this, we have a loopback address 127.0.0.1 this address is your own address and for IP V6 your loopback address is ::1
now the last one is APIPA ad discussed above and it always starts with 169.254.x.x
Simple Problems in IPs
Now there are some problems that can occur when you are setting your IP address and one of them is having the same IP address on two different hosts. If you are running a Windows OS good thing is window will automatically find it and fix it but on Linux or MAC, you will have to fix that manually. Such problems can occur while adding static IP addresses manually or because of Roug DHCP.
Similarly adding the same mac address is also a problem so make sure to double-check mac address while adding them.
One more problem can be the wrong gateway. If you have not set that correctly you will not be able to connect to the internet because it is your router IP address. You will be able to talk within your network but you can’t connect to the internet.
The wrong subnet mask is also a problem that occurs you have to remember that for one network every host must have to have same subnet mask to detect the problem in subnet mask simply ping from one host to other if one of them can not ping back to other you know its a subnet mast problem.