I got to know about NAT and it's use in a LAN. I am just curious to know that, is it possible for two or more than two devices to have the same private IP in a LAN ?
Yes, it is possible but will only cause you issues. You will end up with IP conflicts and will see issues where some frames/packets will travel to one device and some frames/packets to the other.
The other issue you will see is the mapping between MAC addresses and IP addresses. Each MAC address on the LAN segment will be mapped to an IP address and devices will use ARP to resolve an IP address to a MAC and place it in their ARP table. When two MAC addresses have the same IP address, you will end up sending data to the wrong device as on local LAN segment, data is being send based on MAC destination and source address.
When devices use ARP to find out who has IP address 192.168.1.1 for example, the device will end up with two responses from two different devices and you might see the ARP table being constantly updated as devices on the LAN segment will think the MAC has changed for that particular IP address.
if you are using windows, type in arp -a in command prompt to see the ARP cache and it looks similar to this.
> 192.168.0.1 00-00-4e-03-01-01 dynamic > 192.168.0.255 ff-ff-ff-ff-ff-ff static > 22.214.171.124 01-00-3e-6e-03-16 static > 126.96.36.199 01-00-4e-4e-03-fc static > 245.254.255.250 01-00-5e-7f-ff-fa static > 245.254.255.255 ff-ff-ff-ff-ff-ff static
So using these details, when your Windows PC wants to send data, it will look at the destination IP address, then resolve this IP address to a MAC address so that it can use layer 2 to send the frame to the destination MAC address. If it does not know the MAC address, it will issue an ARP which is a broadcast, asking "Who has IP address 192.168.1.1", and wait for a response. It should only receive one response and if there are two, you know you have more than one device with the same IP address.
If we are talking about NAT, then you can join two networks that are using the same private IP schemes but when you are connecting to the second network, passing through NAT, your IP address will be changed to the external address so you are no longer using the private IP address of the first network. The IP address will get translated to an IP address that can work on the second network and not cause any conflicts. The translated address for example could be reserved to still use an IP address in the private range, but the configuration will make sure that you are not using an address that is already used on the second network and has been added to the NAT pool of addresses.
Hope this helps.
Within the same LAN segment? No. Between LAN networks, you can see the same IP address. But within that network, all the IPs have to be unique.
So in Site A you've got a LAN with IPs 192.168.1.0 - 192.168.1.255 And in Site B (connected to site A via a router with NAT enabled on it) you've got a LAN with the same IPs - 192.168.1.0 - 192.168.1.255
This is possible. But within the same network, having two hosts both with IP 192.168.1.1 is not possible, it will clash. NAT is mainly so that you can use the same private IPs between sites.
Just imagine if for site A we could use 192.168.1.0-255 and for site B we had to use 192.168.2.0-255. And similarly for site C,D,E... you didn't have the option to use 192.168.1 or .2 subnets? That'd lead to a lot of waste in terms of usable IP addresses wouldn't it?
Hence, NAT allows same IP ranges to be used between segments. But no you definitely, not with NAT or anything for that matter, have two hosts on the same segment both with the same IP address. It has to be unique.
Hope it helped!