Should i use my local ip address or 127.0.1.1 in /etc/hosts

Discussion in 'Installation/Configuration' started by adamjedgar, Oct 8, 2017.

  1. adamjedgar

    adamjedgar Member

    Should i use my local ip address (eg 192.168.0.1) or 127.0.1.1 in /etc/hosts when setting up a webserver?

    For example, in Section 10.4 of the Debian Reference Manual

    Some software (e.g., GNOME) expects the system hostname to be resolvable to an IP address with a canonical fully qualified domain name. This is really improper because system hostnames and domain names are two very different things; but there you have it. In order to support that software, it is necessary to ensure that the system hostname can be resolved. Most often this is done by putting a line in /etc/hosts containing some IP address and the system hostname. If your system has a permanent IP address then use that; otherwise use the address 127.0.1.1.


    My google cloud instance does not have a static internal ip address at this stage (due to it being a trial i can only use 1 static ip, which i have set to the external ip).

    Does this mean that in my current /etc/hosts file

    127.0.0.1 localhost
    ::1 localhost ip6-localhost ip6-loopback
    ff02::1 ip6-allnodes
    ff02::2 ip6-allrouters

    10.152.0.4 server3.foo.com.au server3
    #10.152.0.4 server3.c.myprojectID-1.internal server3 # Added by Google
    169.254.169.254 metadata.google.internal # Added by Google


    1. So does this information from the Debian quote above, and the fact i am not using a static internal ip address mean that i should change the line in my /etc/hosts file commencing with current internal ip address"10.152.0.4" to "127.0.1.1"?

    2. If the Debian standard was to use 127.0.1.1, why is google automatically adding 10.152.0.4 by default along with the projectID in its own default entries?

    3. I hope this makes sense...i am keen to understand this in far more detail...I realise that in a web server environment it seems like i "should" also have a static internal ip address, however with regard to my original configuration shown above, is it important to have one over the other ip address in /etc/hosts?
     
  2. ztk.me

    ztk.me ISPConfig Developer ISPConfig Developer

    depends on many various things. For example you're sending internal mails to your own server "[email protected]" and you have someplace.tld in your hosts system knows where to deliver it without the need to query external DNS which might not even be aware of your internal hostname.
    You can either use the external IP which google maps to the internal IP or just the internal IP, basically doesn't matter much, however if your system is not aware that the external IP is acutally its own, it might send stuff over the wire without needing it.
    Also ISPConfig may determine which IP initially to setup according to the hosts file, it'll configure your websites to listen to that IP for example when you aswell wanted to use the external IP => then put the external IP to the hosts-file.
    If your external IP changes however, stay with the entry google set for you, it's an internal IP which is not routed and you could setup @home aswell. Just pretend your server is in a DMZ with changing external IPs.

    Hope it helps, it's 7am and didn't have my tea yet :)
     

Share This Page