browser - Difference between DNS and /etc/hosts in name resolving during an HTTPS request

08
2014-07
  • user3099638

    My question is: what is the difference between DNS and the static resolution method based on /etc/hosts in name resolving during an HTTPS connection? In order to connect to a site using https the first action is ask to DNS for the ip of the requested server (if there are no record in /etc/hosts for that domain).

    I'm trying to figure out why I can connect to a server only with the right ip inside /etc/hosts file (and not using DNS).

    The URL of the server is "https://www.ovh.it/managerv3/login.pl" and I cannot connect to it if there's not a record "94.23.64.34 www.ovh.it" in /etc/hosts. There's also another fact that I can't explain: when I'm connected to my ADSL I've to use this trick, but when I use tethering through my phone everything works fine (also without changing /etc/hosts).

    If I ping the domain www.ovh.it the result is the same on both connections:

    PING www.ovh.it (198.27.92.4): 56 data bytes (ADSL)
    PING www.ovh.it (198.27.92.4): 56 data bytes (TETHERING)
    

    If I ping the domain ovh.it the result is the same on both connections:

    PING ovh.it (94.23.64.34): 56 data bytes (ADSL)
    PING ovh.it (94.23.64.34): 56 data bytes (TETHERING)
    

    Using ping (ICMP protocol) the result of the name resolution is the same on both connections. Why using a browser and an HTTPS connection I can't connect to the server with ADSL and there are no problem with TETHERING of my SMATPHONE? And why manually inserting the ip on ovh.it in /etc/hosts it works also connecting with my ADSL?

    Additional informations: I tried with Safari, Chrome and Firefox and the result is the same. I tried to reboot laptop and wifi-router (ADSL router). I also tried with a different laptop.

  • Answers
  • Julian Knight

    I think that you probably know the answer to your question. The difference is that /etc/hosts is STATIC whereas DNS is DYNAMIC. DNS lookups are good for a specified time period after which the client will re-query. DNS servers can also be smart about what they return - acting as simple load spreaders for example or failing over to backup servers.

    In your case, clearly either the client PC (some kind of Linux? You don't say) or the ADSL router would appear to be wrongly configured.

    Firstly check that you haven't put some kind of fixed config on the network card for the PC. Second check the configuration of the router to make sure it gives a valid DNS server. If the PC is set to use DHCP from the router, check if the router is reporting itself as a DNS server (very common for consumer grade routers). If it is, change the DHCP config to give the client PC's proper DNS servers such as your ISP, Google or best of all, OpenDNS.

    The other possibility I can think of is that you are using your ISP's DNS when connected via ADSL and that it is broken. Not that uncommon. Change to use OpenDNS or Google DNS to see if that fixes the issue.

    Although using the hosts file may appear to work, you are fixing the IP address and a service like OVH is likely to use several sets of addresses that you wont be getting access to.


  • Related Question

    ping - DNS unknown host resolved to some pblic ip
  • JavaUser

    In my windows machine all unknown host name resolved to some public open dns ip address when i try to ping any unknown host name as below but for the name host name other windows machine in the same subnet show "unknown host" error

    ping aaaasdas11223
    
    Reply from 69.63.189.11: bytes=32 time<1ms TTL=128
    Reply from 69.63.189.11: bytes=32 time<1ms TTL=128
    Reply from 69.63.189.11: bytes=32 time<1ms TTL=128
    Reply from 69.63.189.11: bytes=32 time<1ms TTL=128
    
    Ping statistics for 69.63.189.11:
        Packets: Sent = 4, Received = 4, Lost = 0 (0% loss), Approximate round trip times in milli-seconds: Minimum = 0ms, Maximum = 0ms, Average = 0ms
    

    From other machine :

    ping aaaasdas11223
    
    Ping request could not find host aaaasdas11223. Please check the name and try again.
    

    I haven't configured nothing specific to DNS in both the machines Please let me know what could be the problem and how to resolve this

    Thx


  • Related Answers
  • Server Horror

    Some providers start replying with "helpful navigation assistants". If you are not on a DOMAIN or WORKGROUP and don't have control over the DNS server you are asking I'd give the provider a phone call and ask why they are mucking with DNS.

    Also you are not giving us the information you get from DNS, dig is my tool of choice that can tell what exactly is going on looking at the DNS site of things...

    May I suggest that these kinds of questions be directed at superuser.com - It seems more a "Desktop/Workstation Problem" than system administration...