7

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 ?

2 Answers 2

9

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.

1

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.

2
  • 127.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. Commented Sep 10, 2014 at 10:38
  • OMFG, corrected - should get more coffee before posting! Thank you @countermode
    – Jan
    Commented Sep 10, 2014 at 11:02

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .