The Community Forums

Interact with an entire community of cPanel & WHM users!
  1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

localhost, 127.0.0.1, server IP, host name: which is best?

Discussion in 'General Discussion' started by sysnop, Sep 29, 2005.

  1. sysnop

    sysnop Member

    Joined:
    May 22, 2005
    Messages:
    12
    Likes Received:
    0
    Trophy Points:
    1
    I realize this is a broad question if asked in the context of various daemons, services, scripts, etc. I'm relating to WHM's resolver setup, when it was adviseable to replace the local host IP (127.0.0.1) with the server's main IP for security reasons, which made sense. So when does it not make sense to replace localhost settings with something more specific?

    Let's take my mail system as an example:

    In squirrelmail/config/config.php, for the $domain, $imapServerAddress, and $smtpServerAddress entries, should 'localhost' be replaced by the server's host name or IP? When I look into it, some say to do it this way, others say to do it the other way, while nobody disagrees that 'localhost' will always work.

    Another case in point are my courier-imap/imapd and pop3d files, which seem to be using 127.0.0.1. Would I be better off using the server's IP?
     
  2. chirpy

    chirpy Well-Known Member

    Joined:
    Jun 15, 2002
    Messages:
    13,475
    Likes Received:
    20
    Trophy Points:
    38
    Location:
    Go on, have a guess
    You only need to use the servers IP address if you want to either put the requests through a local iptables firewall or because of other security concerns. I'm only aware of the bind issue because of the trusing nature of daemons with port 127.0.0.1 (i.e. the loopback device).

    Normally, it's cheaper, performance wise (though very negligable) to route local IP traffic through 127.0.0.1, so you may as well use that. You can use localhost if you want, which is only there if for some bizarre reason you wanted to point localhost to some other IP address. If you do use localhost, make sure it's defined as 127.0.0.1 in /etc/hosts.
     
  3. sysnop

    sysnop Member

    Joined:
    May 22, 2005
    Messages:
    12
    Likes Received:
    0
    Trophy Points:
    1
    Thanks for the info.

    If I use the server's host name in the imapd and Squirrelmail configs, will it speed up the lookup process? For now I've got DNS lookup disabled wherever it's an option. But mail in general seems too slow. Converting to maildir was supposed to help but I haven't noticed any enhancement over mbox in terms of speed.
     
  4. chirpy

    chirpy Well-Known Member

    Joined:
    Jun 15, 2002
    Messages:
    13,475
    Likes Received:
    20
    Trophy Points:
    38
    Location:
    Go on, have a guess
    If speed is of concern then using IP addresses is best as it avoids the lookup. However, the main problem with that is if you change IP addresses and they'll then be stuffed ;)
     
Loading...

Share This Page