Can two hosts have the same IP address in /etc/hosts?
Solution 1
This fully valid and correctly. Also you can write names in one string with space delimiter:
127.0.1.1 debian mini mini.local
The both variants is fully valid.
Solution 2
can two hosts share the same IP Address without a conflict Short answer: No.
Now as can be seen both mini and debian share the same IP Address. No, it's the other way round: Both names resolve to the same IP and that is OK.
The IP 127.... are loopback Adresses, only available on your machine, read up here.
Note that these IPs are not accessible from outside your computer.
After some deeper research, describe your issue with apache in a new question.
Related videos on Youtube
shirish
A GNU/Linux and Debian user. Debian user for more than 5 years and yet still feel like a kid who has just started using the system yesterday.
Updated on September 18, 2022Comments
-
shirish over 1 year
can two hosts share the same IP Address without a conflict. This is how my /etc/hosts looks like :-
$ cat /etc/hosts 127.0.0.1 localhost 127.0.1.1 debian 127.0.1.1 mini
Now as can be seen both mini and debian share the same IP Address.
Now debian is my hostname.
$ hostname debian
while mini is a virtual host for an apache site.
/etc/apache2/sites-available$ head minidebconfindia.conf <VirtualHost mini:80> ServerAdmin webmaster@localhost
This is in Apache 2.4. I am just not sure whether this is good or not. A friend of mine has the same setup (with a different hostname) on Apache 2.2 and that works without issue.
Looking forward to know if this is valid or should I be doing any changes ?
-
countermode over 9 years127.0.0.0/8 is loopback; private addresses by RFC 1918 are 10.0.0.0/8, 172.16.0.0/16 and 192.168.0.0/16.
-
Jan over 9 yearsOMFG, corrected - should get more coffee before posting! Thank you @countermode