Find the answer to your Linux question:
Page 2 of 4 FirstFirst 1 2 3 4 LastLast
Results 11 to 20 of 39
Do you actually get a hostname setting from your DHCP server that differs from the one that you send then? Also, just because it works with dhcpcd doesn't mean it ...
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #11
    Linux Guru
    Join Date
    Oct 2001
    Location
    Täby, Sweden
    Posts
    7,578

    Do you actually get a hostname setting from your DHCP server that differs from the one that you send then? Also, just because it works with dhcpcd doesn't mean it works with dhclient. The best way is probably to find an option for dhclient that tells it not to update the hostname, and if a such doesn't exist, to add a hook that restores the hostname after completion of the lease.

  2. #12
    Linux Engineer
    Join Date
    Jan 2003
    Location
    Lebanon, pa
    Posts
    994
    All I am doing is making gnome think that is my hostname. I am setting what is in hostname as an alias to my box in /etc/hosts.

  3. #13
    Linux Guru
    Join Date
    Oct 2001
    Location
    Täby, Sweden
    Posts
    7,578
    But gnome doesn't read the hostname from /etc/hostname. It uses gethostname(2), if I'm not mistaken, and if dhclient updates the hostname via sethostname(2) without updating /etc/hosts, it won't work anyway.

  4. $spacer_open
    $spacer_close
  5. #14
    Linux Engineer
    Join Date
    Jan 2003
    Location
    Lebanon, pa
    Posts
    994
    ok then run hostname "pick one" then set an alias to it in your hosts file. I don't think dhclient will overwrite your set hostname. Only one way to find out.

  6. #15
    Linux Guru
    Join Date
    Oct 2001
    Location
    Täby, Sweden
    Posts
    7,578
    Apparently it does, since it's precisely that it seems to have done. Possibly it only overwrites the default "inappropriate" hostnames, but that was just what majorwoo and I suggested earlier today, though, by setting the HOSTNAME setting in /etc/sysconfig/network.

  7. #16
    Linux Engineer
    Join Date
    Jan 2003
    Location
    Lebanon, pa
    Posts
    994
    ok if it removes invalid hostnames, adding the alias to it in /etc/hosts like I said should fix that then since it will be valid.

  8. #17
    Linux Guru
    Join Date
    Oct 2001
    Location
    Täby, Sweden
    Posts
    7,578
    Not if the alias doesn't match the hostname as stored in the kernel.
    This is a probably chain of events, as I've managed to gather:
    1. The system boots and there is no HOSTNAME setting in /etc/sysconfig/network, so rc.sysinit sets the hostname to "localhost.localdomain" or something similar.
    2. The dhcp daemon is run on the network interface. It transmits a DHCPDISCOVER message to the DHCP server with the hostname option containing the locally set hostname, namely "localhost.localdomain".
    3. The DHCP server returns something else, such as "dchp-966-63" or whatever it was (see the first post). It does this either because the sysadmins thought it to be appropriate or because it doesn't like one of its configured clients to have a hostname similar to "localhost". Note that the returned hostname is a random name, and is likely to change when a new lease is requested.
    4. dhclient updates the locally set hostname (using sethostname(2)) to the one received from the DHCP server. It does this either because it programmed to do so whatever it receives, or because it deems it better than something similar to "localhost".

    Note, that at this point, it doesn't matter what alias you have previously set in /etc/hosts, since the new random hostname is very unlikely to match it, and even if it does, it does so by chance.
    The fixes to this are several: If the new hostname is set because the previous one was "localhost*", it can be fixed by setting the HOSTNAME setting to something nice. If it's the default behaviour of dhclient and the configured behaviour if the DHCP server to always do so, the best would be to find an option to dhclient that makes ignore the hostname option from the server. If there is no such option, the hostname would have to be reset after dhclient is invoked. That's less elegant, however.

    This is how I've interpreted the previous posts. If I've missed something, please tell me.

  9. #18
    Linux Engineer
    Join Date
    Jan 2003
    Location
    Lebanon, pa
    Posts
    994
    That is why you put a hostname in that file like I have said numerous times. If you do what I said in my original post(setting hostname and then adding an alias to it) gnome will not complain at all.

  10. #19
    Linux Guru
    Join Date
    Oct 2001
    Location
    Täby, Sweden
    Posts
    7,578
    Of course, but then again, that's a one time solution, since the hostname will change once again the next time you request a lease from the DHCP server.

  11. #20
    Linux Guru
    Join Date
    Oct 2001
    Location
    Täby, Sweden
    Posts
    7,578
    Unless your /etc/hostname file was supposed to be the same is the HOSTNAME setting, and you had also thought of that it might be that it replaces an obvious "default-like" hostname? I'm suspecting that we aren't synced in this discussion.

Page 2 of 4 FirstFirst 1 2 3 4 LastLast

Posting Permissions

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