 | |
01-11-2003
|
#11 (permalink)
| | Linux Guru
Join Date: Oct 2001 Location: Täby, Sweden
Posts: 7,575
| 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. |
| |
01-11-2003
|
#12 (permalink)
| | 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. |
| |
01-11-2003
|
#13 (permalink)
| | Linux Guru
Join Date: Oct 2001 Location: Täby, Sweden
Posts: 7,575
| 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. |
| |
01-11-2003
|
#14 (permalink)
| | 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. |
| |
01-11-2003
|
#15 (permalink)
| | Linux Guru
Join Date: Oct 2001 Location: Täby, Sweden
Posts: 7,575
| 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. |
| |
01-11-2003
|
#16 (permalink)
| | 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. |
| |
01-11-2003
|
#17 (permalink)
| | Linux Guru
Join Date: Oct 2001 Location: Täby, Sweden
Posts: 7,575
| 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. |
| |
01-11-2003
|
#18 (permalink)
| | 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. |
| |
01-11-2003
|
#19 (permalink)
| | Linux Guru
Join Date: Oct 2001 Location: Täby, Sweden
Posts: 7,575
| 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. |
| |
01-11-2003
|
#20 (permalink)
| | Linux Guru
Join Date: Oct 2001 Location: Täby, Sweden
Posts: 7,575
| 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. |
| | |
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | | | | Thread Tools | | | | Display Modes | Linear Mode |
Posting Rules
| You may not post new threads You may not post replies You may not post attachments You may not edit your posts HTML code is Off | | | | | | Free Magazines | Cisco News
Receive a free quarterly e-newsletter with exclusive articles on how Cisco IT uses its own products and solutions to enable the business. subscribe | Systems Management News, the newspaper for IT systems administration and data center managers!
Each issue of Systems Management News is chock-full of news and analysis to help you understand what's happening in your field. subscribe | The Enterprise Newsweekly eWeek is the essential technology information source for builders of e-business. subscribe | Oracle Magazine Oracle Magazine contains technology strategy articles, sample code, tips, Oracle and partner news, how to articles for developers and DBAs, and more. Oracle (NASDAQ: ORCL) is the world's largest enterprise software company. subscribe | Total Telecom Total Telecom is "The Economist of the communications industry". subscribe | | More free magazines » | All times are GMT. The time now is 06:07 AM. |
| |