When I enter 'google.com' in my web browser, my computer goes to the DNS server and gets Google's server IP address, then it look for that address in the local network and when it doesn't find it it goes to the gateway and off it goes.

My question is, if by any chance there was a device in my local network that uses that IP address, would my machine go to that device?

That would be a problem in the protocol because now its easy to go in a public network and set a static IP for my device and trick other people in the network that I'm the real Google website. I think that there's something more to it so this doesn't happen but I haven't been able to find an answer.


The short answer is no, this would not happen.

The reason is that if you change the IP address of a machine to say $$ (the result i get when doing a DNS lookup for google.com), the machine would belong to a different subnet and therefore not be visible to other machines on the physical network.

An IP address consists of two parts: a network identifier and a host identifier. The $n$ most significant bits specifies the network part and the $32-n$ (for IPv4) least significant bits specify the host, where the number $n$ is given by the subnet mask.

Suppose the machines on your network use a subnet mask of $$ then the $24$ most significant bits of the IP address specify the network, meaning that only machines that have IP addresses that are identical in the first $24$ bits are considered to be on the same network.

For further info i would suggest reading about subnetworks and routing .

|improve this answer|||||
  • But what if we change the private IP address of our router (and thus change our personal network subnet)? – Iago Carvalho Apr 28 '19 at 12:12
  • 1
    Suppose you set the subnet mask to $$ (i.e. the network part is $0$ bits), then all IP addresses are considered to be on the LAN. Therefore, no traffic is forwarded to a router, and as a result there would be no internet connectivity. – AcId Apr 28 '19 at 12:29
  • 1
    If you control the router, you control the data flow of all devices using that router. All bets for integrity is off by then. – vidarlo Apr 28 '19 at 17:00

Where the packets are sent are determined by your computer's routing table. For example:

% ip route
default via dev wlan0 metric 1 dev wlan0 proto kernel scope link src 

This very simple routing table shows that is reachable directly on device wlan0, but traffic to all other networks must go via my router. Suppose google.com returns and I set my local subnet to In that case, I wouldn't be able to reach google.com as my computer would try to reach it only on the local network.

This is why we have RFC1918. These are networks that are reserved for local networks and not on the internet. Use of an RFC1918 network for your LAN guarantees you won't run into a conflict with an internet-routable host.

If you set an IP on one of your local hosts but it's on the local subnet as understood by the sending computer, it will never see traffic at all as the other host won't be sending traffic there.

|improve this answer|||||

Actually many years back, a large government internal network was using public IP addresses belonging to other commercial companies. It worked fine as long as they remained fully isolated from the internet. They were resistant to change but I suspect it has been corrected since then as it was a potential disaster waiting to happen.

|improve this answer|||||

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy