Mamoru Iwaki
2010-Oct-07 13:09 UTC
How dhcp client can set its hostname properly on lease time
Hi, I'm using FreeBSD 8 stable as of 20101006. It is a dhcp client in a private local network, and xorg staff is installed. When I tried to use it from a remote pc with X11-forwarding set, xauth failed to set up .Xauthority as follows. /usr/local/bin/xauth: creating new authority file /home/hogehoge/.Xauthority /usr/local/bin/xauth: (stdin):1: bad display name "unix:10.0" in "remove" command /usr/local/bin/xauth: (stdin):2: bad display name "unix:10.0" in "add" command At this moment, hostname was not set (it's empty) because the FreeBSD box was a dhcp client. Meanwhile, if the hostname coresponding to the ip-address assigned by dhcp server was set manually, the above lines disappeared and X11-forwarding worked well. Now, my question is Are there good way for dhcp client to set its hostname properly on lease time? The following will be a possble workaround, but I'm wondering there can be a smart answer in FreeBSD itself. It is possible to resolve the hostname corresponding to a dhcp-delivered ip-address with a local name server. So, (1) resolve the corresponding hostname from the local name server, (2) set it as hostname, and (3) call them every time when dhcp lease is updated Cheers -- ----- Mamoru IWAKI Grad. Schl. Sci & Tech./Dept. Biocybernetics, Niigata University
Kurt Lidl
2010-Oct-07 14:16 UTC
How dhcp client can set its hostname properly on lease time
Regarding your posting to freebsd-stable. Probably what you want to do is have the DHCP server send the machine name when it offers a lease to the client. -Kurt
Brian Reichert
2010-Oct-07 15:14 UTC
How dhcp client can set its hostname properly on lease time
On Thu, Oct 07, 2010 at 09:37:52PM +0900, Mamoru Iwaki wrote:> Now, my question is > > Are there good way for dhcp client to set its hostname properly on lease > time?Depends on 'properly'. I've hacked dhclient exit scripts to synthesize a hostname, if one was not offered by the DHCP server. The host, under these circumstances, gets a hostname derived from the IP address and the supplied domain name, eg: '10-12-34-56.example.com'. This at least gets the box into a place where it has a hostname associated with the address on an external interface. No one else knows that hostname, however. YMMV.> > Cheers > > -- > ----- > Mamoru IWAKI > Grad. Schl. Sci & Tech./Dept. Biocybernetics, Niigata University-- Brian Reichert <reichert@numachi.com> 55 Crystal Ave. #286 Derry NH 03038-1725 USA BSD admin/developer at large
Torfinn Ingolfsen
2010-Oct-07 17:52 UTC
How dhcp client can set its hostname properly on lease time
On Thu, 07 Oct 2010 21:37:52 +0900 Mamoru Iwaki <1wkmmr@gmail.com> wrote:> Are there good way for dhcp client to set its hostname properly on lease > time?Well, you *can* have the dhcp client on FreeBSD send an identifier, and with that identifier the dhcp server can assign the client a static ip lease. If that static ip is registered in your local dns, you're all set. Doesn't work well if you use the client on another network who doesn't offer static ip's. YMMV.> The following will be a possble workaround, but I'm wondering there can > be a smart answer in FreeBSD itself. > > It is possible to resolve the hostname corresponding to a dhcp-delivered > ip-address with a local name server. So, (1) resolve the corresponding > hostname from the local name server, (2) set it as hostname, and (3) > call them every time when dhcp lease is updatedIsn't the proper way with dns to configure dynamic DNS updates, and allow the client to do that? HTH -- Regards, Torfinn Ingolfsen
Mamoru Iwaki
2010-Oct-10 10:54 UTC
How dhcp client can set its hostname properly on lease time
Hi, Thanks everyone for giving me useful reply. Now, my stupid problem has been solved by setting 'get-lease-hostnames true;' in dhcpd.conf file. Cheers (4:59), Mamoru Iwaki wrote:> Hi, > > I'm using FreeBSD 8 stable as of 20101006. It is a dhcp client in a > private local network, and xorg staff is installed. When I tried to use > it from a remote pc with X11-forwarding set, xauth failed to set up > .Xauthority as follows. > > /usr/local/bin/xauth: creating new authority file /home/hogehoge/.Xauthority > /usr/local/bin/xauth: (stdin):1: bad display name "unix:10.0" in > "remove" command > /usr/local/bin/xauth: (stdin):2: bad display name "unix:10.0" in "add" > command > > At this moment, hostname was not set (it's empty) because the FreeBSD > box was a dhcp client. Meanwhile, if the hostname coresponding to the > ip-address assigned by dhcp server was set manually, the above lines > disappeared and X11-forwarding worked well. > > > Now, my question is > > Are there good way for dhcp client to set its hostname properly on lease > time? > > > The following will be a possble workaround, but I'm wondering there can > be a smart answer in FreeBSD itself. > > It is possible to resolve the hostname corresponding to a dhcp-delivered > ip-address with a local name server. So, (1) resolve the corresponding > hostname from the local name server, (2) set it as hostname, and (3) > call them every time when dhcp lease is updated-- ----- Mamoru IWAKI Grad. Schl. Sci & Tech./Dept. Biocybernetics, Niigata University