-2

I have a set of domain names and their IP addresses. When i send http requests to the domain names and IP addresses separately then I found discrepancy in the responses. The responded hosts are higher while sending http requests to the domain names than IP addresses. So, I was wondering if the IP addresses of the domain names changes overtime. If it changes then what could be the reason. I would appreciate any response.

saz
  • 955
  • 5
  • 15
  • 26
  • I'm not sure what do you mean by "The responded hosts are higher while sending http requests to the domain names than IP addresses." – pajaja Feb 10 '15 at 20:54
  • for example if i send http request to 20 domain names and their 20 ip addresses separately then if i get 15 http response when sending requests to domain names and 10 in case of ip addresses requests. – saz Feb 10 '15 at 21:02
  • When you send an HTTP request, regardless of whether it goes to a domain or an IP, you get an HTTP response back, unless the domain fails to resolve to an IP, or the socket fails to connect to an IP. So you should be getting 20 responses for 20 requests, unless errors are occurring. Are errors actually occurring? – Remy Lebeau Feb 10 '15 at 21:04

1 Answers1

2

I was wondering if the IP addresses of the domain names changes overtime

They might change over time, and probably will eventually.

If it changes then what could be the reason.

It really depends on the individual server. If the server has static IP addresses, they likely won't change, but can. If the server has dynamic IP addresses, they will most likely change. If the server is moved to a new building/network, the IP addresses can, and likely will, change.

This is what DNS is all about - being able to resolve a given hostname to its current IP addresses at that moment, regardless of what the addresses actually are. When a hostname is registered with DNS, the hostname's DNS records are updated accordingly when its IP addresses change, and those changes are propagated and cached throughout public DNS servers. That is why sometimes when a hostname changes its IP addresses, the change might take a little time (minutes, hours) for client systems to detect the new IP addresses, depending on which DNS servers are being queries and how the DNS request is formatted.

When a client wants to connect to a server by hostname, it sends a DNS request to get the current IP addresses. The request circulates through the DNS system until a DNS server decides it has a suitable answer and replies back with the IP addresses it currently knows about (which may be cached, so a DNS request might not always be an authoritive response, unless the client explicitly requests that, in which case the request gets routed to the DNS server that owns the hostname), and then the client connects to those IP addresses as needed.

Sometimes those IP addresses might be related to networks that the client is not connected to. Sometimes the IP addresses might be cached by an intermediate DNS server and can go stale over time. This is why it is best to attempt to connect to every IP address that is reported in a DNS response. But many socket programmers do not do that, they usually just connect to the first IP address that is reported. If you can, try not to fall into that same pitfall.

Remy Lebeau
  • 555,201
  • 31
  • 458
  • 770