# 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.

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 :