When I type a domain URL in the browser (or send a ping or write code that fetches a particular IP) the browser gets the associated IP address based on DNS lookup in a distributed database system – the DNS name servers.
But once the IP is obtained – how does the browser know how to go to the particular computer that this IP represents?
import urllib.request
nf = urllib.request.urlopen("http://192.168.1.2")
>Solution :
The operating system will compare the target IP address with its own IP address. If both addresses are part of the same network, the OS will issue an ARP request to obtain the physical address (the MAC) of the target interface.
If both IP addresses are not part of the same network, the OS will forward the traffic to the gateway responsible for the subnet that is addressed. If it has no such a route, the OS will forward the traffic to the default gateway.
From there the game starts anew.