What IP address is DNS service returning?

1

Supposing I have a server on a network that has a private IP address, and somewhere on a another network is a client that has the same private IP address. It is possible beaucase they are on different networks? Now if the client performs a DNS lookup to find the server IP address it will get the private IP address of the server, or the address of the network the server belongs to? Normally it should receive the address of the network, but then how it can know which is the station in that network corresponding to the server?

SebiSebi

Posted 2014-12-06T09:29:54.577

Reputation: 155

Answers

2

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

marsh-wiggle

Posted 2014-12-06T09:29:54.577

Reputation: 2 357

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 address 192.168.0.200 that is in the network of PC01 then PC01 will try to reach the PC with this IP address. Maybe there is MyServer with 192.168.0.200 attached to the network of PC01 then PC01 will connect this server, thinking it talks to AnyRemoteServer. 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.660

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

0

it should receive the address of the network, how it can know which is the station in that network corresponding to the server

That is the job of the public facing router of the network. This is usually done by Network Address Translation with Port Forwarding.

How to Set Up Port Forwarding on a Router explains how to do this.

Port forwarding opens certain ports on your home or small business network, usually blocked from access by your router, to the Internet. Opening specific ports can allow games, servers, BitTorrent clients, and other applications to work through the usual security of your router that otherwise does not permit connections to these ports.

For more information see http://portforward.com/ one of the best references for all things to do with port forwarding ...

DavidPostill

Posted 2014-12-06T09:29:54.577

Reputation: 118 938