Skip to content
Related Articles

Related Articles

Improve Article
Save Article
Like Article

Can Two IP Addresses Be Same?

  • Difficulty Level : Easy
  • Last Updated : 09 Sep, 2021

Overview :
A simple definition of Computer Network is an interconnection of two or more computers(includes personal computers, mobiles, laptops, etc, network devices like a router, switch, bridge, etc)  for the purpose of transferring data. Now one obvious question arises how does one computer in the network identify another? Here, is the answer. By MAC address and IP address

MAC (Media Access Control) is 6 bytes 
=48 bits =12 nibbles
(1 nibble=4bits) long . 

Note –
It is a hardware address given to each NIC(Network Interface Card). 

Attention reader! Don’t stop learning now. Get hold of all the important CS Theory concepts for SDE interviews with the CS Theory Course at a student-friendly price and become industry ready.

 

  1. Can two devices have the same MAC address?
    No.
  2. Can two devices have the same IP address?  
    Yes

Why and How :
Now comes the interesting part, WHY and HOW? Let me first explain WHY and then HOW ingeniously we do that as follows.



Why :

  • Today the two most widely used version of IP is IPv4 and IPv6.
  • IPv4 is 32 bit and IPv6 is 128 bit
  • if we talk about IPv4 it has only 32 bits means 2^32 addresses
  • possible (max) which is roughly equal to 4 billion(10^9) addresses.
  • but to have more than billions of devices in the world is possible
  • as now we have lots of IoT devices, smartphones, even smart
  • fridges which are connected to the internet.
  • so we have to find out some solution that how can we reuse the already used IP address. otherwise we will run out of IP

How :
To solve this problem we introduce two terminologies Public IP address and Private IP address are as follows.

Public IP address and Private IP address :
Any IP address in this range is the private IP address and the remaining are public IP addresses.

  • Private IPs are free of cost
  • Public IPs are costly (ISPs like Jio, Airtel purchase public IPs)
10.0.0.0        -    10.255.255.255/8
172.16.0.0      -    172.31.255.255/12
192.168.0.0     -    192.168.255.255/16

Diagram Representation –
Here we have two routers Jio and Airtel both are connecting private networks and public networks. Remember we do not talk directly to Google or Amazon server or any public device directly, we talk via our ISP . we talk to ISP router and ISP router talk to the Internet. All ISP or public routers have public IP addresses that they purchase and all have different public IP addresses, they can’t be the same, as in fig. Airtel public IP is 43.5.6.1 and Jio public IP is 53.9.7.1. Now under each public IP address, any private IP address range can be used (private IP range listed above).  That’s why host A and host B in fig. can have the same private IP address. so within one network for ex-Airtel, all private IPs must be different but for hosts, on two different networks ex-Airtel and Jio hosts may have the same private IP address this way we reuse the private IPs.

Public and private network

Conclusion :
All public IPs assigned to Routers of ISPs or Routers connecting to Internet are unique. but private IPs of two hosts can be the same if both are connected to different public networks. So the combination of public and private IP identifies your device uniquely. One interesting activity you can do, take two or more phones to connect all the phones with the hotspot of anyone’s phone. now on all the phones type on Google “what is my IP address” it will give you the public IP to which your phone is connected, (not the private IP), you will see all of your phones have the same public IP (because all of you are connected to the same public router) and to see your private IP  go to setting and then Wi-Fi and then Wi-Fi setting. You will see your private IP address ( for your mobile model please search on google how to find private IP). One more thing you will note here is that all of your private IPs will differ in a uniform manner. Because all of you have the same public network your private IP can’t be the same. 

My Personal Notes arrow_drop_up
Recommended Articles
Page :

Start Your Coding Journey Now!