The most used private network is 192.168.0.0 (/24). 192.168.0.1 is probably the most used IP address, so a lot of different hosts have the same IP adress.
DNS returns host IP addresses and no network IP adresses, so you will always get the IP adress of a host and not of a network.
To know what the network to an IP adress is, you have to know the subnet mask. 192.168.0.33 with subnet mask 255.255.255.0 says that 192.168.0.0 is the network (address). (But mostly you don't know the subnet mask of remote networks / hosts and you don't need to know it.)
Assume a workstation PC01
with 192.168.0.33 subnet 255.255.255.0 is asking a DNS for the hostname AnyRemoteServer
and the DNS returns the IP address 192.168.0.200. So PC01
will assume that AnyRemoteServer
is in its own network and try to reach it there. Even when AnyRemoteServer
is in a remote netzwork, there won't be tried to route the packets to the remote network.
When AnyRemoteServer
(which belongs to a remote network) has the IP address 192.168.0.200
which also fits to the network of PC01, then PC01 will try to reach in its network the host AnyRemoteServer
. When in the network of PC01 does also exist a host with 192.168.0.200
(lets call it MyServer
), PC01 will connect MyServer
, thinking it talks to AnyRemoteServer
. On the other side, if there is no machine with that IP then PC01 will run in a time out (depends on the protocoll PC01 is using).
What happens if AnyRemoteServer is in a remote network, but PC01 will try to reach it in PC01 network (it assumes that AnyRemoteServer is in its own network)? The connection cannot be established? – SebiSebi – 2014-12-06T11:12:02.700
@SebiSebi When
AnyRemoteServer
has the IP address192.168.0.200
that is in the network of PC01 then PC01 will try to reach the PC with this IP address. Maybe there isMyServer
with192.168.0.200
attached to the network of PC01 then PC01 will connect this server, thinking it talks toAnyRemoteServer
. If there is no machine with that IP then PC01 will run in a time out (depends on the protocoll PC01 is using). – marsh-wiggle – 2014-12-06T11:26:37.660OK. That is the problem. How can I connect to that server which has an private IP address of 192.168.0.200, but is in another network? The problem is that the two networks (the one of my PC and the server one) have the same address 192.168.0.0. – SebiSebi – 2014-12-06T11:53:39.597
@SebiSebi I suspect that the networks are connected in any way (else you will need magic to solve that). You can use a cheap hardware router (like Linksys WRT54GL) and use natting (NAT) to solve that. It's to broad to explain it here. You will find examples on the internet for that. If you need assistance you may ask a new question here. Good luck!! – marsh-wiggle – 2014-12-06T12:16:29.700
OK. Let's start from the beginning. Supposing I have two local networks, each of that have a router and a switch. The first network is 192.168.1.0/24 with the default gateway 192.168.0.1 and the second one is also 192.168.1.0/24 with the gateway 192.168.0.1 . This is possible since we talk about private IP addresses. Now the first network contains two PC's: PC1 with address 192.168.0.2 and PC2 with address 192.168.0.3. Moreover, the second network has PC3 with address 192.168.4.2 and a server whose IP address is 192.168.0.5. OK. I'll continue the post in another comm since I've run out of char – SebiSebi – 2014-12-06T12:40:52.147
@SebiSebi make a complete new post for that please. This is how it works here :-) (and if my answer to the DNS question helped you, you may want to accept it) – marsh-wiggle – 2014-12-06T12:48:49.163
Sorry, I will continue this post in here. Each router has an public IP address, say R1 is 40.0.0.1 and R2 is 100.0.0.1. If I am at PC1 and I want to connect to server on the second network. The DNS service will say that is has IP 192.168.0.5. Now my PC will assume that it is in the same network (192.168.0.0 the first network) and will try to connect with him using the switch. But the connection fails since this IP does not exist in PC1's network. How can PC1 connect to the server in the second network? – SebiSebi – 2014-12-06T12:54:21.787
@SebiSebi Don't know if you already did it, but this should be solved in a complete new answer and not here in the comment thread. – marsh-wiggle – 2014-12-08T07:32:42.833