Should the loopback alias in /etc/hosts be localhost?

This was something I ran across recently when installing NTP...for some reason, if I change the loopback alias to my actual machine name, the command <code>ntpq -p</code> would not work...it would reply: Name or service not known.  However, leaving the alias as localhost and trying the command again works just fine.
The reason I had altered it initially was due to Xfce giving me a warning dialog box upon startup that says it cannot find the host.  Changing my loopback line to
127.0.0.1 localhost.localdomain servername
instead of the default...
127.0.0.1 localhost.localdomain localhost
eliminated that error message and Xfce would start up with no problems.  I vaguely remember reading somewhere that it should be left at localhost and not be set to your actual machine name, but I don't remember the reasoning behind it.  Do I really have to choose one error or the other?  Any thoughts?

Ahhh...never knew you could do that.  I'll give that a shot once I get home and let you know if it worked.  Thanks Mr. Prickly!

Similar Messages

  • Hosts-update: automatically append the mvp blocklist to /etc/hosts

    This util written by wintervenom has actually been in the AUR for going on 2 years now. 
    What it does:
    Updates /etc/hosts with the mvps blocklist to prevent thousands of parasites, hijackers and unwanted adware/spyware/privacy websites from working.
    Operation is trivial:
    1) Edit /etc/hosts.local to match the hostname of your system and adjust the domainname as needed. Also add any hosts that you wish to keep i.e. other PCs on your network.
    2) Run /usr/bin/update_hosts as root which will append /etc/hosts.local to the mvps blocklist and apply some post processing writing the final file to /etc/hosts automatically.
    3) (Optional) Add a cronjob under root crontab at some interval to keep your /etc/hosts fresh.
    AUR: https://aur.archlinux.org/packages/hosts-update
    Github: https://github.com/graysky2/hosts-update
    Original thread: https://bbs.archlinux.org/viewtopic.php?id=106367
    Enjoy!
    Last edited by graysky (2013-12-11 17:09:06)

    Sure you can, but not in this particular tool.  There is a script written by haarp designed to run on a tomato-usb powered router that does just this.  I host the code here: https://github.com/graysky2/adblock
    EDIT: I can't remember if it pulls from the same urls as pgl does but you can certainly modify the code to do it.
    Last edited by graysky (2013-12-11 19:52:02)

  • What is the original file /private/etc/hosts ?

    Trying to understand I made a bad edit !
    Thanks !

    To set it back, it should read like this. At least, this is the content on my Mac.
    # Host Database
    # localhost is used to configure the loopback interface
    # when the system is booting.  Do not change this entry.
    127.0.0.1             localhost
    255.255.255.255  broadcasthost
    ::1                      localhost
    fe80::1%lo0        localhost
    Don't know if it would make a difference, but the first and fourth sentences ending with "localhost" use a tab character for the space between 127.0.0.1 and fe80::1%lo0. The second and third lines are padded out with space characters.

  • In the command line how do I find the etc/host file? is there one?

    I am trying to work remotely and use our lotus notes system (which is from a windows based server) but I have to connect to the mail server and our IT person wants to find the equivalent of the Windows host file or host table . is there such a file? we went here
    http://linux.die.net/man/5/hosts
    hosts(5) - Linux man page
    Name
    hosts - The static table lookup for host names
    Synopsis
    /etc/hosts
    thanks

    Since you're using a Macintosh, quit reviewing linux stuff. These, when entered in the Terminal app (inside /Applications/Utilities/) should point you in the right direction:
    *cat /etc/hosts*
    details in:
    *man hosts*
    FWIW, you should search the Unix forum (or post your query there) under OS X Technologies.

  • SAP on Ubuntu Correct settings for etc/hosts?

    Hi,
    I installed the SAP test drive version on Ubuntu (VirtualBox). After starting the SAP GUI (
    /home/minisap/SAPClients/SAPGUI7.20rev5/bin/guistart /H/ubuntu64/S/3242
    ) I get the following error:
    Error: partner 'ubuntu64:3242' not reached
    Sun Feb  5 14:07:26 2012
    Release 720
    Component NI (network interface), version 40
    rc = -10, module nixxi.cpp, line 3286
    Detail NiPConnect2: 127.0.0.1:3242
    System Call connect
    Error No 111
    'Connection refused'
    I guess that the settings of the file etc/hosts are not correct. After the installation of ubuntu the file contains
    10.0.2.15    ubuntu64    # Added by NetworkManager
    127.0.0.1    localhost.localdomain    localhost
    ::1    ubuntu64    localhost6.localdomain6    localhost6
    127.0.1.1    ubuntu64
    # The following lines are desirable for IPv6 capable hosts
    ::1     localhost ip6-localhost ip6-loopback
    fe00::0 ip6-localnet
    ff00::0 ip6-mcastprefix
    ff02::1 ip6-allnodes
    ff02::2 ip6-allrouters
    ff02::3 ip6-allhosts
    According to the test drive readme file I have to ensure that etc/hosts contain at least the following lines:
    127.0.0.1      localhost      
    n.n.n.n      <HOSTNAME>.<DOMAINNAME>      <HOSTNAME>
    n.n.n.n      nplhost      
    where "n.n.n.n" is a valid IP-adress.
    I tried different settings but the above mentioned error still occurs... Does anyone know the correct settings of etc/hosts or know what the problem could be?
    Thanks and regards

    OK, I logged on as user nnpladm and typed
    startsap nplhost
    ps -ef|grep sap
    ps -ef|grep sap
    sdb       3424     1  0 16:15 pts/1    00:00:00 /sapdb/NPL/db/pgm/vserver -sdbstarter 1002 1003 A -S 7200 -Y
    sdb       3425  3424  0 16:15 pts/1    00:00:00 /sapdb/NPL/db/pgm/vserver -sdbstarter 1002 1003 A -S 7200 -Y
    sdb       3428     1  0 16:15 pts/1    00:00:00 /sapdb/programs/pgm/niserver
    sdb       3448     1  0 16:15 ?        00:00:00 /sapdb/NPL/db/pgm/kernel NPL -diagpipe 16
    sdb       3451  3448  0 16:15 ?        00:00:02 /sapdb/NPL/db/pgm/kernel NPL -diagpipe 16
    npladm    4903     1  0 16:16 ?        00:00:00 /usr/sap/NPL/SCS00/exe/sapstartsrv pf=/usr/sap/NPL/SYS/profile/START_SCS00_nplhost -D
    npladm    5187     1  0 16:16 ?        00:00:00 sapstart pf=/usr/sap/NPL/SYS/profile/START_SCS00_nplhost
    npladm    5209  5187  0 16:16 ?        00:00:00 ms.sapNPL_SCS00 pf=/usr/sap/NPL/SYS/profile/NPL_SCS00_nplhost
    npladm    5210  5187  0 16:16 ?        00:00:00 en.sapNPL_SCS00 pf=/usr/sap/NPL/SYS/profile/NPL_SCS00_nplhost
    npladm    6414     1  0 16:16 ?        00:00:00 /usr/sap/NPL/DVEBMGS42/exe/sapstartsrv pf=/usr/sap/NPL/SYS/profile/START_DVEBMGS42_nplhost -D
    npladm    6700     1  0 16:17 ?        00:00:00 sapstart pf=/usr/sap/NPL/SYS/profile/START_DVEBMGS42_nplhost
    npladm    6740  6700  0 16:17 ?        00:00:00 ms.sapNPL_DVEBMGS42 pf=/usr/sap/NPL/SYS/profile/NPL_DVEBMGS42_nplhost
    npladm    6742  6700  0 16:17 ?        00:00:00 ig.sapNPL_DVEBMGS42 -mode=profile pf=/usr/sap/NPL/SYS/profile/NPL_DVEBMGS42_nplhost
    npladm    6755  6742  0 16:17 ?        00:00:00 /usr/sap/NPL/DVEBMGS42/exe/igsmux_mt -mode=profile -restartcount=0 -wdpid=6742 pf=/usr/sap/NPL/SYS/profile/NPL_DVEBMGS42_nplhost
    npladm    6756  6742  0 16:17 ?        00:00:00 /usr/sap/NPL/DVEBMGS42/exe/igspw_mt -mode=profile -no=0 -restartcount=0 -wdpid=6742 pf=/usr/sap/NPL/SYS/profile/NPL_DVEBMGS42_nplhost
    npladm    6757  6742  0 16:17 ?        00:00:00 /usr/sap/NPL/DVEBMGS42/exe/igspw_mt -mode=profile -no=1 -restartcount=0 -wdpid=6742 pf=/usr/sap/NPL/SYS/profile/NPL_DVEBMGS42_nplhost
    npladm    7930  1544  0 16:47 pts/1    00:00:00 grep sap
    telnet ubuntu64 3242
    Trying ::1...
    Trying 127.0.1.1...
    Trying 10.0.2.15...
    telnet: Unable to connect to remote host: Connection refused

  • /etc/hosts Private Host Name Fully Qualified Domain Name does it matter?

    During installation of 11gR1 on Windows 2003 the examples in the installation guide show adding the Private IP and host name to /etc/hosts
    However they only add the short name, racnode1, not Fully qualified Domain Name (FQDN), racnode1.mycompany.com
    e.g.
    10.0.0.1 racnode1
    10.0.0.2 racnode2
    Later when installing the Clusterware it then expects to see the FQDN, racnode1.mycompany.com, of course you can modify this and remove the domain name and continue. OR go back and add the FQDN in /etc/hosts
    e.g.
    10.0.0.1 racnode1 racnode1.mycompany.com
    10.0.0.2 racnode2 racnode2.mycompany.com
    What is the best practice? Currently my company is just dropping the FQDN from the name during the install, my instinct is instead to add the FQDN to the /etc/host in the first place.
    Does anyone have a recommendation or experience with either situation?
    Will (using/ or not using) the FQDN cause me issues in the future?

    If it's a problem, the assistent will tell you :-)
    I don't think it's a problem.
    Please mind that the first entry will be the name of the ip address, if it's not in DNS and a utility tries to get the name. (that's the reason 127.0.0.1 resolves to localhost.localdomain, it's the first entry in /etc/hosts)

  • Make nslookup read /etc/hosts file

    Dear,
    OS: OUL5x64
    my nslookup resolve the name thru dns server.
    question :
    how to make nslookup resolves name through /etc/hosts file.
    i do have /etc/resolv.conf and /etc/nsswitch.conf file
    here is my nsswitch.conf
    /etc/nsswitch.conf
    #hosts: db files nisplus nis dns
    hosts: files
    but it never uses the file to resolve the name.
    how can i force it to read /etc/hosts file first
    Thanks in advance!

    Perhaps it would help to elaborate on WHY you want nslookup to use the /etc/hosts file?
    If you look at the the name of the nslookup utility, it quite probably is an abbreviation of "nameserver lookup". That strongly suggests it is a tool for querying nameservers.
    NOT a tool to debug the name lookups of your operating system.
    On the platforms I use (I don't use HPUX), you can query and set the nameserver nslookup uses. I would consider it a bug if the nslookup tool uses /etc/hosts if set in nsswitch.conf.
    this is how I lookup what server is set for the utility:
    $ nslookup
    serverDefault server: 10.0.1.1
    Address: 10.0.1.1#53this is how nslookup responds to a query:
    nu.nlServer:        10.0.1.1
    Address:     10.0.1.1#53
    Non-authoritative answer:
    Name:     nu.nl
    Address: 62.69.184.53
    Name:     nu.nl
    Address: 62.69.179.198(I don't know how the "jive quote" comes in, it is supposed to be a "bigger than" sign)

  • Appending a blocklist to /etc/hosts

    Is it possible to append a blocklist (er... redirectlist) to /etc/hosts somehow?
    For example, mvps has been supplying a very nice list of known parasite websites for years.  Basically, it just uses 127.0.0.1 to redirect known bad websites so they don't load. It's a nice system-wide method to block them.  I have been pasting their list into my /etc/hosts but am wondering if I can someone call it as I do in bash scripts.
    For example, this doesn't work, but you get idea:
    $ cat /etc/hosts
    127.0.0.1 localhost.localdomain localhost novelty
    192.168.1.1 router
    192.168.1.2 inky
    192.168.1.3 blinky
    . /etc/hostsmvps # try to load the mvps redirect list

    Wintervenom wrote:
    Copy your local machine and network hosts to "/etc/hosts.local," then:
    #!/bin/dash
    ### MVPS Hosts Updater #########
    # Version 0.3 by Scott Garrett #
    # Wintervenom [(at)] gmail.com #
    # Download the MVPS hosts file.
    wget -c -O /tmp/hosts.txt http://www.mvps.org/winhelp2002/hosts.txt
    # Be paranoid and replace every IP address with 0.0.0.0. We also get
    # only want the actual blacklist, 'cause we want to prepend the user's
    # own hosts. 0.0.0.0 is nicer than constantly knocking on localhosts' door.
    sed -r -e 's:^([0-9]{1,3}\.){3}[0-9]{1,3}:0.0.0.0:' /tmp/hosts.txt > /tmp/hosts.new.txt
    tail -n+`grep -nF 'start of lines' /tmp/hosts.new.txt | cut -d':' -f1` /tmp/hosts.new.txt > /tmp/hosts.txt
    # Write this new list over the system hosts list. MVPS' line feeds
    # are \n\r; we will be getting rid of those dirty carriage returns.
    # We'll first write the user's hosts head, then the black list.
    cat /etc/hosts.local > /etc/hosts
    cat /tmp/hosts.txt | tr -d "\r" >> /etc/hosts
    rm /tmp/hosts*.txt
    # This is the end!
    Thanks for the script, I actually wrote one very similar to yours but then thought I'd ask about sourcing it like a bash script does...
    Last edited by graysky (2010-10-10 16:04:16)

  • Pacman ignores /etc/hosts

    I use csslayer-aur-repo which is placed on googlecode.com server, however csslayer-aur-repo.googlecode.com sometimes returns IP of server which doesn't seem to have csslayer-aur-repo.db.tar.gz file. As a workaround i've put csslayer-aur-repo.googlecode.com in /etc/hosts with an IP which works just fine. I've tested it with wget and ping, and both of them seem to use this "new" IP address. However pacman seems to ignore /etc/hosts and picks that random IP which mostly leads to "404 not found" error when doing pacman -Syu/Syy/Sy.
    Here is my /etc/hosts
    # /etc/hosts: static lookup table for host names
    #<ip-address> <hostname.domain.org> <hostname>
    127.0.0.1 localhost.localdomain localhost Archie
    209.85.135.82 csslayer-aur-repo.googlecode.com
    # End of file
    and here is the repo entry from pacman.conf:
    [csslayer-aur-repo]
    Server = http://csslayer-aur-repo.googlecode.com/files

    Yup, wget fetches http://csslayer-aur-repo.googlecode.com … .db.tar.gz just fine and it uses the IP specified in /etc/hosts.
    Surely pacman does not deploy its own DNS server, but seems to ignore /etc/hosts. If i remove csslayer line from /etc/hosts then wget also will fail.
    [hash@Archie ~]$ wget http://csslayer-aur-repo.googlecode.com/files/csslayer-aur-repo.db.tar.gz
    --2010-07-26 18:54:29-- http://csslayer-aur-repo.googlecode.com/files/csslayer-aur-repo.db.tar.gz
    Translacja csslayer-aur-repo.googlecode.com... 209.85.135.82
    Łączenie się z csslayer-aur-repo.googlecode.com|209.85.135.82|:80... połączono.
    Żądanie HTTP wysłano, oczekiwanie na odpowiedź... 200 OK
    Długość: 1190 (1,2K) [application/x-gzip]
    Zapis do: `csslayer-aur-repo.db.tar.gz'
    100%[=============================================================================================================================================================================>] 1.190 --.-K/s w 0,02s
    2010-07-26 18:54:30 (72,5 KB/s) - zapisano `csslayer-aur-repo.db.tar.gz' [1190/1190]
    [hash@Archie ~]$ pacman -Syu
    :: Synchronizing package databases...
    kde-unstable is up to date
    core is up to date
    extra is up to date
    community is up to date
    error: nie udało się pobrać pliku 'csslayer-aur-repo.db.tar.gz' z csslayer-aur-repo.googlecode.com : Not Found
    error: failed to update csslayer-aur-repo (Not Found)
    Last edited by hash (2010-07-26 16:55:47)

  • Asking for a password when trying to add an entry to /etc/hosts

    I am trying to add an entry to /etc/hosts using Terminal. When I type the command: sudo nano /etc/hosts it asks me for a password. I have never set a password so I have no idea what this would be. My admin pw is blank (I just hit enter) and this is not working. Is there a defaut password or how can I reset this? Thanks

    This would be your admin account password. You must set one.
    Forgot Your Account Password
    For Lion, Mountain Lion, or Mavericks
        Boot to the Recovery HD:
    Restart the computer and after the chime press and hold down the COMMAND and R keys until the menu screen appears. Alternatively, restart the computer and after the chime press and hold down the OPTION key until the boot manager screen appears. Select the Recovery HD and click on the downward pointing arrow button.
         When the menubar appears select Terminal from the Utilities menu.
         Enter resetpassword at the prompt and press RETURN. Follow
         instructions in the dialog window that will appear.
         Or see Reset a Mac OS X 10.7 Lion Password, OS X Mountain Lion- Reset a login password,
         and OS X Lion- Apple ID can be used to reset your user account password.
    For Snow Leopard and earlier with installer DVD
         Mac OS X 10.6- If you forget your administrator password
    For Snow Leopard and earlier without installer DVD
        How to reset your Mac OS X password without an installer disc | MacYourself

  • Mpc problem: getaddrinfo not checking /etc/hosts?

    The source of this question is my attempt to get mpc to contact mpd on my localhost when the internet is down. When the internet is up it works fine, but when i'm not connected to the internet, running mpc behaves as follows:
    I seem to have tracked this down to a problem in getaddrinfo (possibly in my sytem configuration?). I created a piece of test code (below) that does a gethostbyname and then a getaddrinfo. On this computer, both work when connected to the internet, but getaddrinfo fails when disconnected. I tested the same code on an ubuntu computer and it getaddrinfo worked even when disconnected from the internet.
    My /etc/hosts and /etc/host.conf seem to be set properly. glibc is 2.8-3. I would have thought that getaddrinfo having such a problem would cause more errors than just in mpc, but I haven't noticed any.
    I'd really appreciate any help.
    #include <stdio.h>
    #include <sys/types.h>
    #include <sys/socket.h>
    #include <netdb.h>
    int main (void)
    struct addrinfo *addrinfo;
    int i, error;
    struct hostent *h;
    h = gethostbyname("localhost");
    if (h) {
    for (i=0; i < h->h_length - 1; i++)
    printf("%d.", h->h_addr_list[0][i]);
    printf("%d\n", h->h_addr_list[0][i]);
    } else {
    printf("no such host\n");
    error = getaddrinfo("localhost", NULL, NULL, &addrinfo);
    if (error) {
    printf("host not found: %s\n", gai_strerror(error));
    } else {
    while (addrinfo) {
    printf("%d %d %d\n",AF_INET,AF_INET6,addrinfo->ai_family);
    addrinfo = addrinfo->ai_next;
    return 0;
    $ ./hnt
    127.0.0.1
    2 10 2
    2 10 2
    2 10 2
    $ sudo dhcpcd -k wlan0
    $ ./hnt
    127.0.0.1
    host not found: Temporary failure in name resolution
    $ mpc
    MPD_HOST and/or MPD_PORT environment variables are not set
    error: host "localhost" not found: Temporary failure in name resolution
    $
    Uncommented and nonblank lines of /etc/hosts:
    127.0.0.1      localhost.localdomain  localhost heroine
    and /etc/host.conf:
    order hosts,bind
    multi on

    Alas, setting MPD_HOST does not help. If there is some way to give mpc an ip address instead of a hostname, that might help. Just putting 127.0.0.1 as MPD_HOST doesn't work.
    I also really think there is something really weird going on with getaddrinfo.
    Thanks for the idea.
    $ MPD_HOST=localhost mpc
    MPD_HOST and/or MPD_PORT environment variables are not set
    error: host "localhost" not found: Temporary failure in name resolution
    $ MPD_HOST=127.0.0.1 mpc
    MPD_HOST and/or MPD_PORT environment variables are not set
    error: host "127.0.0.1" not found: Address family for hostname not supported
    $

  • Bad OPMN server host address: localhost

    Hi.
    When I type opmnctl status, I get the error:
    Bad OPMN server host address: localhost
    Does anyone know how to fix this? Or what causes the problem? Or places I might look for the source?
    Thanks!

    First of all, the reference to localhost is wrong, but could you check the ADMN-xxxx error number that is displayed on the screen and let me know

  • Which localhost line shuold be used in the /etc/hosts file on Solaris Sparc

    Hi There,
    I would like to know which line should be use in the /etc/hosts file:
    127.0.0.1 localhost
    127.0.0.1 localhost.localdomain localhost
    Thanks :-)
    J

    user560159 wrote:
    Hi There,
    I would like to know which line should be use in the /etc/hosts file:
    127.0.0.1 localhost
    127.0.0.1 localhost.localdomain localhost
    Thanks :-)
    JThe format for the hosts file is
    ipaddress alias1 alias2 alias3 alias4 Most shops will just have two aliases, one with just the machine name, one with the fully qualified domain.machine name. In reality, you can do whatever makes sense:
    [root@vmlnx01 ~]# cat /etc/hosts
    # Do not remove the following line, or various programs
    # that require network functionality wil fail
    127.0.0.1       localhost.localdomain localhost
    [root@vmlnx01 ~]# ping localhost
    PING localhost.localdomain (127.0.0.1) 56(84) bytes of data.
    64 bytes from localhost.localdomain (127.0.0.1): icmp_seq=1 ttl=64 time=1.96 ms
    [root@vmlnx01 ~]# ping localhost.localdomain
    PING localhost.localdomain (127.0.0.1) 56(84) bytes of data.
    64 bytes from localhost.localdomain (127.0.0.1): icmp_seq=1 ttl=64 time=0.094 ms
    [root@vmlnx01 ~]# vi /etc/hosts
    <<<< adding an alias 'fred' >>>>>
    [root@vmlnx01 ~]# cat /etc/hosts
    # Do not remove the following line, or various programs
    # that require network functionality wil fail
    127.0.0.1       localhost.localdomain localhost fred
    [root@vmlnx01 ~]# ping fred
    PING localhost.localdomain (127.0.0.1) 56(84) bytes of data.
    64 bytes from localhost.localdomain (127.0.0.1): icmp_seq=1 ttl=64 time=0.306 ms
    64 bytes from localhost.localdomain (127.0.0.1): icmp_seq=2 ttl=64 time=0.093 ms
    64 bytes from localhost.localdomain (127.0.0.1): icmp_seq=3 ttl=64 time=0.092 msDoes the order of the aliases have any meaning? I leave that quick experiment as an exercise for the student.

  • Strange entry in the /etc/hosts file

    Hi,
    While doing some testings with my network this afternoon, I noticed that there's this strange line in my /etc/hosts file:
    ::1 localhost
    Anybody has any idea what the "::1" is for? The only thing related to network that I had recently installed is VPN Tracker. Could it be VPN Tracker that added that line to the hosts file?
    Thanks in advance for your help!
    Frank
    PowerBook G4   Mac OS X (10.4.8)  

    It's supposed to be there, here's a fresh install's complete hosts file...
    # Host Database
    # localhost is used to configure the loopback interface
    # when the system is booting. Do not change this entry.
    127.0.0.1 localhost
    255.255.255.255 broadcasthost
    ::1 localhost "
    Not sure what it means... may be a 16 bit number though! :-D

  • Adding the /etc/host.deny file like linux in solaris 10.

    Dears,
    I need to add a file which will works like the file of /etc/hosts.deny of Linux in Solaris.
    If it is possible in the same manner please let me know that, and if it need some other trick to deny a specific host to access the system please tell me the way to do that.
    Eagerly waiting to hear from you.
    BR//
    Sohel.

    IPfilter can deny a specific IP address access to the host - enable IPFilter with svcadm and edit the /etc/ipf/ipf.conf file to add the IP to block. An example could be:
    block in log quick on bnx0 proto tcp from 192.168.1.5/32 to any
    I use IPfilter to pass and block all sorts of specific IP addresses as well as block/allow specific ports (like only specific hosts can use port 22, ssh).

Maybe you are looking for