Page 1 of 2 12 LastLast
Results 1 to 10 of 20

Thread: sudo unable to resolve host new problem (not /etc/hosts /etc/hostname difference)

  1. #1
    Join Date
    Aug 2008
    Beans
    54

    sudo unable to resolve host new problem (not /etc/hosts /etc/hostname difference)

    I am having a problem with sudo. anytime I use a sudo command I get "sudo: unable to resolve host LinMyron" although the sudo command works.

    here is my /etc/hosts and /etc/hostname:
    Code:
     1
    
    /etc/hosts:
    
    127.0.0.1 localhost
    127.0.1.1 LinMyron
    
    
    # The following lines are desirable for IPv6 capable hosts
    ::1 ip6-localhost ip6-loopback
    fe00::0 ip6-localnet
    ff00::0 ip6-mcastprefix
    ff02::1 ip6-allnodes
    ff02::2 ip6-allrouters
    ff02::3 ip6-allhosts
    
    /etc/hostname
    
    LinMyron
    any help is appreciated.

  2. #2
    Join Date
    Aug 2008
    Beans
    54

    Re: sudo unable to resolve host new problem (not /etc/hosts /etc/hostname difference)

    could avahi cause this problem?

    I just noticed under system monitor that there is an entry for: avahi-daemon: running [LinMyron.Local]
    Last edited by Dejavou42; August 18th, 2008 at 07:02 AM.

  3. #3
    Join Date
    Aug 2008
    Beans
    54

    Re: sudo unable to resolve host new problem (not /etc/hosts /etc/hostname difference)

    so, after editing /etc/sudoers with gedit...booting into recovery mode (luckily I made a backup) and restoring the file, I am back to the sudo error. (*INFO: lesson learned)

    I just noticed that the auth.log in syslog shows a very interesting pattern

    Code:
    Aug 18 06:17:08 ubuntu sudo:    myron : unable to resolve host ubuntu
    Aug 18 06:17:08 ubuntu sudo:    myron : TTY=pts/0 ; PWD=******* ; USER=root ; COMMAND=/usr/bin/apt-get update now
    Aug 18 06:17:08 ubuntu sudo: pam_unix(sudo:session): session opened for user root by myron(uid=0)
    Aug 18 06:17:08 ubuntu sudo: pam_unix(sudo:session): session closed for user root
    Aug 18 06:17:22 ubuntu sudo:    myron : unable to resolve host ubuntu
    Aug 18 06:17:22 ubuntu sudo:    myron : TTY=pts/0 ; PWD=******** ; USER=root ; COMMAND=/usr/bin/apt-get update
    Aug 18 06:17:22 ubuntu sudo: pam_unix(sudo:session): session opened for user root by myron(uid=0)
    Aug 18 06:17:22 ubuntu sudo: pam_unix(sudo:session): session closed for user root
    Aug 18 06:17:49 ubuntu sudo:    myron : unable to resolve host ubuntu
    Aug 18 06:24:13 ubuntu sudo:    myron : unable to resolve host ubuntu
    Aug 18 06:25:01 ubuntu CRON[7084]: pam_unix(cron:session): session opened for user root by (uid=0)
    Aug 18 06:25:01 ubuntu CRON[7084]: pam_unix(cron:session): session closed for user root
    Aug 18 06:26:43 ubuntu sudo:    myron : unable to resolve host ubuntu
    Aug 18 06:30:48 ubuntu sudo:    myron : unable to resolve host ubuntu
    Aug 18 06:31:17 ubuntu last message repeated 2 times
    notice the pam_unix open and close entry right before the sudo errors.

    again, I have all functionality of sudo, but I still get this annoying error message.

    any thoughts? all help is greatly appreciated.

    btw I also edited my hostname between the last post and this post...just to make sure....
    Last edited by Dejavou42; August 18th, 2008 at 12:03 PM.

  4. #4
    Join Date
    Jul 2008
    Location
    CA
    Beans
    29
    Distro
    Ubuntu 10.10 Maverick Meerkat

    Re: sudo unable to resolve host new problem (not /etc/hosts /etc/hostname difference)

    "sudo" tries to resolve "localhost" to an IP address, and, if it can't, you get this error. If your hostname resolution includes /etc/hosts, then this file can map the localhost IP address to the name "localhost".

    Now, here's kind of the weird thing: in Ubuntu, in addition to the traditional 127.0.0.1 being "localhost", 127.0.1.1 is also used internally as localhost. So both should be included.

    Try setting up your /etc/hosts file to include (at the top) the following, where "yourhost" is your short hostname, and "yourhost.yourdomain.com" is your fqdn:

    ( using your favorite editor, eg: $ sudo vim /etc/hosts )

    127.0.0.1 localhost.localdomain localhost yourhost
    127.0.1.1 yourhost yourhost.yourdomain.com


    I'm not sure if the fqdn is necessary or not, but I've included it for now in mine. The following should also be fine,

    $ cat /etc/hosts
    127.0.0.1 localhost.localdomain localhost yourhost
    127.0.1.1 yourhost

    (Hopefully I don't have any typos.)

    Cheers,
    -m

  5. #5
    Join Date
    Aug 2008
    Beans
    54

    Re: sudo unable to resolve host new problem (not /etc/hosts /etc/hostname difference)

    I think that the fix you are describing is the is the fix for the difference between /etc/hosts and /etc/hostname. This is not the problem that I am experiencing. posted above are my /etc/hosts and /etc/hostname files, which are not different. That problem would also make the sudo command inoperable including all updates and administrative functions. I have full functionality of sudo commands and administrative functions.

    example:

    Code:
    myron@ubuntu:~$ sudo ls -l
    sudo: unable to resolve host ubuntu
    total 582000
    -rw-------  1 root  root   27841788 2008-08-18 04:35 2008-08-18-08-04-16.059-VBoxSDL-8405.log
    the sudo command works, it just displays the error message: sudo: unable to resolve host ubuntu.

    p.s. I just pasted part of the response from the ls-l command.

  6. #6
    Join Date
    Aug 2007
    Location
    istanbul
    Beans
    27
    Distro
    Ubuntu 10.04 Lucid Lynx

    Re: sudo unable to resolve host new problem (not /etc/hosts /etc/hostname difference)


  7. #7
    Join Date
    Aug 2008
    Beans
    54

    Re: sudo unable to resolve host new problem (not /etc/hosts /etc/hostname difference)

    Thanks for the reply, but unfortunately that thread is still discussing the same problem that I mentioned above (/etc/hosts /etc/hostname difference), which is also not the problem that I am experiencing. As said in a post above, this would make sudo commands not work. My sudo commands all work, as well as administrative functions, it just gives me that error message. Thanks for the attempt though.... I appreciate any help that someone can send my way.

  8. #8
    Join Date
    Jul 2008
    Location
    CA
    Beans
    29
    Distro
    Ubuntu 10.10 Maverick Meerkat

    Re: sudo unable to resolve host new problem (not /etc/hosts /etc/hostname difference)

    Quote Originally Posted by Dejavou42 View Post
    unfortunately that thread is still discussing the same problem that I mentioned above (/etc/hosts /etc/hostname difference), which is also not the problem that I am experiencing.
    ...Have you tried the proposed solution? Your hosts file still looks basically incomplete; it's NOT the same thing as I've posted.

    Quote Originally Posted by Dejavou42 View Post
    As said in a post above, this would make sudo commands not work. My sudo commands all work, as well as administrative functions, it just gives me that error message.
    Well, this is not true; I've just tried this, myself. I do get the warning message, but sudo works. I'll post exactly what I have (only the hostname / domain name changed to protect the innocent):

    In both cases, I have my hostname:
    Code:
    $ cat /etc/hostname 
    myhost
    === good configuration ====
    Code:
    $ cat /etc/hosts
    127.0.0.1 localhost.localdomain localhost myhost
    127.0.1.1 myhost myhost.mydomain.com
    
    # The following lines are desirable for IPv6 capable hosts
    ::1 ip6-localhost ip6-loopback
    fe00::0 ip6-localnet
    ff00::0 ip6-mcastprefix
    ff02::1 ip6-allnodes
    ff02::2 ip6-allrouters
    ff02::3 ip6-allhosts
    
    $ whoami
    userfoo
    
    $ sudo ls
    [sudo] password for userfoo: 
    file1 file2 ....
    === bad configuration (slightly different, yes, but it causes the problem) ====
    Code:
    $ cat /etc/hosts
    127.0.0.1 localhost.localdomain localhost
    127.0.1.1 myhost.mydomain.com
    
    # The following lines are desirable for IPv6 capable hosts
    ::1 ip6-localhost ip6-loopback
    fe00::0 ip6-localnet
    ff00::0 ip6-mcastprefix
    ff02::1 ip6-allnodes
    ff02::2 ip6-allrouters
    ff02::3 ip6-allhosts
    
    $ sudo ls
    sudo: unable to resolve host myhost
    file1 file2 ...
    (Note: it doesn't ask my passwd the second time, since it remembered that I had just run a sudo command).

    And, auth.log,
    Code:
    /var/log/auth.log:Aug 21 10:49:19 myhost sudo: userfoo : unable to resolve host myhost
    So, your problem may be completely unrelated, but this still sounds quite similar like what you're experiencing.

    Try posting your updated hosts file that tries this suggested solution, and you might get people looking for other possible solutions ... but until you try this (until we know you've tried this), there's not much reason to pursue & post alternative solutions. Nothing is a substitute for physical hands-on the keyboard, so we can only suggest things & hope the feedback you provide is sensible (cause/effect from our suggestions) & can generate new ideas.

    Thanks & good luck,
    -m

    ps: btw, you might also check the sudo config,

    Code:
    # /etc/sudoers
    #
    # This file MUST be edited with the 'visudo' command as root.
    #
    # See the man page for details on how to write a sudoers file.
    #
    
    Defaults    env_reset
    
    # Uncomment to allow members of group sudo to not need a password
    # %sudo ALL=NOPASSWD: ALL
    
    # Host alias specification
    
    # User alias specification
    
    # Cmnd alias specification
    
    # User privilege specification
    root    ALL=(ALL) ALL
    
    # Members of the admin group may gain root privileges
    %admin ALL=(ALL) ALL
    Last edited by michael_1234; August 21st, 2008 at 09:06 PM. Reason: added /etc/sudoers and auth.log warning

  9. #9
    Join Date
    Aug 2008
    Beans
    54

    Re: sudo unable to resolve host new problem (not /etc/hosts /etc/hostname difference)

    Ok, I checked sudoers file (it actually got me into alot of trouble because I didn't edit it with Visudio Read Above^) I checked my hosts and hostname file again. they looked ok. I went to System --> Administration --> Network and changed Domain to local. Afterwards I changed the /etc/hosts file to match it like this:

    Code:
    /etc/hosts:
    
    127.0.0.1 localhost.local localhost ubuntu
    127.0.1.1 ubuntu
    
    
    # The following lines are desirable for IPv6 capable hosts
    ::1 ip6-localhost ip6-loopback
    fe00::0 ip6-localnet
    ff00::0 ip6-mcastprefix
    ff02::1 ip6-allnodes
    ff02::2 ip6-allrouters
    ff02::3 ip6-allhosts
    I didn't put the myhost.mydomain.com part because I was not sure about the mydomain.com. All of this did not yield any different results. I still recieved the sudo error, but this time the terminal was sluggish to open and trying to edit /etc/hosts would not work because the editor froze. I changed it all back. Thanks for the help, but it didn't seem to work. Any suggestions? Maybe the mydomain.com thing. does my ISP go there? Thanks for all the help everyone.

  10. #10
    Join Date
    Aug 2008
    Beans
    54

    Re: sudo unable to resolve host new problem (not /etc/hosts /etc/hostname difference)

    OK I have some new information. I just installed ubuntu on a hp laptop for a friend. In the meantime, I compared my /etc/hosts ; /etc/hostname ; /etc/sudoers ; and /etc/modprobe.d/aliases files to the brand new installation. With the exception of the hostnames, my files are exactly identical to his. so, this tells me that the problem is not in one of the previously mentioned files. I do however have a bridge set up between eth0 and a connection called VBox0 to give my Virtual Machine a unique ip address on my local network. Could something like that cause an unresolvable host issue? Any help is appreciated.

Page 1 of 2 12 LastLast

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •