In Linux, how do
/etc/hosts and DNS work together to resolve hostnames to IP addresses?
- if a hostname can be resolved in
/etc/hosts, does DNS apply after
/etc/hoststo resolve the hostname or treat the resolved IP address by
/etc/hostsas a "hostname" to resolve recursively?
In my browser (firefox and google chrome), when I add to
127.0.0.1 google.com www.google.com
typing www.google.com into the address bar of the browsers and hitting entering won't connect to the website. After I remove that line from
/etc/hosts, I can connect to the website. Does it mean that
/etc/hostsoverrides DNS for resolving hostnames?
After I re-add the line to
/etc/hosts, I can still connect to the website, even after refreshing the webpage. Why doesn't
/etc/hostsapply again, so that I can't connect to the website?