Subject: Re: Obtaining a host name?
To: Jan Danielsson <jan.danielsson@gmail.com>
From: segv <segv@netctl.net>
List: netbsd-users
Date: 08/14/2005 16:27:24
On Sun, 14 Aug 2005 17:02:44 +0200
Jan Danielsson <jan.danielsson@gmail.com> wrote:
> Now, when I connect to some servers with my Windows system, the
> server will reply "Hello REGULUS3.student.uu.se", or something like
> that. I haven't set that "REGULUS"-variable anywhere, so I assume that
> it is sent to me by the dhcp server(?). Now, my NetBSD system doesn't
> seem to do that, and what's more: I have set my own hostname in rc.conf.
>
I think what happens here is the server to which you're connecting looks up the
hostname, given your ip address, and then it prints out the hostname. This is
common with ftp servers. Your hostname on the current machine may be totally
different.
> I assume that is why it fails on NetBSD, gethostname() isn't
> returning a "proper" name?
>
> Is there any way to fix so that gethostname() will return that dhcp
> assigned name in NetBSD?
If dhcp server is providing a hostname, the dhcp client on your NetBSD machine
should be able to set it automatically. Comment out 'hostname=' directive from
your /etc/rc.conf and reboot, then run 'hostname' on the command line to see if
it has been set, if it's empty then dhcp server did not provide a valid hostname