so right now im working on two million machine, and in a walkthrough i saw that i have to edit the /etc/hosts to be able to access the website on that machine, my question is why do i have to do that?
is it because for example this website doesn’t have an entry on a real DNS server so i have to do that because it for some reason only opens when it’s name is on the browser? can someone pls explain it to me
Ok, EthernalBlue give us a description, but the motive can be varius.
For example, the Dns need to be maintenance and have a cost or maybe need to recycles the Ip address for other purpose.
Generally, when you use /etc/hosts, then bypass the Dns and if you are forced to do this it’s because it’s convenient for someone
sorry for the late reply but let me get this straight
so basically what happens before we add an entry to /etc/hosts is:
1-when i try to access it via ip address it redirects me to 2million.htb domain name
2-the browser goes to that redirection and checks for a DNS entry to that domain name but there is no DNS server entry
and what happens after we add an entry to /etc/hosts is:
1-when i try to access it via ip address it redirects me to 2million.htb domain name
2-because that domain name is now mapped to the ip address it goes to 2million.htb and knows it is associated with that ip address but instead of going back to the default page on an infinite loop of redirections it shows the actual website because the server is only configured to be accessed by its name not its ip address when the domain name is mapped to the ip address
is that it or do i still not get it?
I think it is the opposite. The server can be found by the ip, so you can identify in /etc/hosts that the domain name has this ip and the host can be located.
? can you elaborate?
Note: Our browsers usually first look up records in the local ‘/etc/hosts
’ file, and if the requested domain does not exist within it, then they would contact other DNS servers. We can use the ‘/etc/hosts
’ to manually add records to for DNS resolution, by adding the IP followed by the domain name.
The request is sent to the ip, if the browser doesnt get the ip from DNS the communication doesnt work.
You put the website name in the browser, the machine look the /etc/hosts for the ip and send the request.
Yes of course.
The /etc/hosts is the father of the DNS. many year ago the DNS don’t exist, so the people for search and contact a server make the /etc/hosts, where we have the map IP → HOSTNAME. This is normal because we can remember a name better than a number.
When network of computer grow with after only 1 year, the computer scientist need to create a centralized system for mapping IP → HOSTNAME, so born the DNS.
Today, a OS first look in the /etc/hosts and later into DNS (many level of DNS, Primary and Slave).
Both are only a database with a key → values for resolution between Ip and Hostname (and vice versa).
The /etc/hosts is local for a machine, DNS is a centralized system, more complex, can comunicate with other DNS in the world and can make also update of the database from master and slave.
In the world we have only 13 DNS for global internet domain (remember www.site.com is a Ip address).
isn’t that the same as what i said? how is it the opposite?
Nobody is contradicting you. Everyone simply contributes to the thread in their own way
bro im not tryna start an argument with them or anything im asking about this:
they said it’s the opposite so im asking what they meant by that
Haha
Ok bro if you said that, was my mistake. No problem.