1

I've recently installed NetBSD 7.0.2, and I'm having trouble setting my hostname right.

I'm using DHCP, so I got dhclient=YES in my /etc/rc.conf.

Now, the documentation says, that there are several ways of setting the hostname. The prefered one is to put the hostname into a file. So /etc/myname contains a single line with the fully qualified domain name, etc.

This didn't help so I also added hostname=<my fqdn> into /etc/rc.conf, but it still doesn't honor my hostname settings.

This didn't help either, so I ended up editing /etc/defaults/rc.conf and set the appropriate settings there.

At this point I've run out of ideas. It's still not honering my selection, instead selecting a hostname for me, which is the name of my router plus a number.

  • You should check netbsd.gw.com/cgi-bin/man-cgi?dhcpcd+8+NetBSD-current which has many relevant options. – Julie Pelletier Jan 22 '17 at 5:46
  • Depending on the setup of your DHCP server, your hostname can be negotiated with the server, and you might have to accept the server's choice. A packet capture of the negotiation might show what's going on. Beware however that (contrary to the popular belief) DHCP is an enormously complex protocol. – Satō Katsura Jan 22 '17 at 7:46
  • @SatoKatsura: Your last remark made me smile. It may seem a bit abnormal to someone with very basic network understanding since it isn't IP based, but it's really quite simple. – Julie Pelletier Jan 22 '17 at 16:02
  • @JuliePelletier I suppose it depends on how you look at it. The basic exchange is indeed simple. It becomes really hairy when you get to the extensions (some 400 pages of description, IIRC). The vast majority of the time when it doesn't work, guess where's the culprit. – Satō Katsura Jan 22 '17 at 16:19
0

If you are using dhclient(8) (which is deprecated on NetBSD 6 and later), you need to add a send host-name clause to your /etc/dhclient.conf file. It should include the hostname you wish to use.

eg:
send host-name "eyeore";

  • I like your answer but it seems to be missing the better alternative to this deprecated configuration. :) – Julie Pelletier Jan 23 '17 at 4:14
  • The preferred alternative is dhcpcd(8). I believe the release notes since NetBSD 6.0 has stated that dhcpcd(8) has replaced dhclient(8), and dhclient(8) will be removed at some future date. – Eric Schnoebelen Jan 23 '17 at 20:14
  • dhcpcd(8) also sends the host name to the DHCP server by default. – Eric Schnoebelen Jan 23 '17 at 20:15
  • I've since fixed it using the supersede keyword – polemon Jan 24 '17 at 3:17

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.