xapi-project / xcp-networkd

The XCP networking daemon
Other
14 stars 42 forks source link

Make dhclient send our hostname to the DHCP server #175

Closed johnelse closed 4 years ago

johnelse commented 4 years ago

This generates a config file of the form:

interface "xenbr0" {
  send host-name = gethostname();
  request subnet-mask, broadcast-address, time-offset, host-name, nis-domain, nis-servers, ntp-servers, interface-mtu, routers, domain-name, domain-name-servers;
}
robhoes commented 4 years ago

Hey John, why is this useful?

olivierlambert commented 4 years ago

Hey John, why is this useful?

As soon you enabled DHCP, it's very likely that you want to send the hostname in the request. This allows your DNS server to populate the record at the same time (this is the reason of this feature).

This way, in a DNS/DHCP enabled environment, you don't have to remember the IP address (or even knowing it), you can just rely on the hostname, so you can ssh or ping it directly with the hostname.

I would say that DHCP without it isn't really interesting. Also, as it's only something used for people who decided willingly to enabled DHCP.

robhoes commented 4 years ago

In the DHCP request options we actually request a hostname from the DHCP server, which is then configured on the host together with the IP address etc. So the DHCP server is in charge of hostnames and IP addresses, so that you don't need to manually set a hostname upon installing the host. Isn't that the common use case?

robhoes commented 4 years ago

Anyway, I'm happy to add this, to allow for additional DHCP use cases, as it seems to be complementary to the current config.

olivierlambert commented 4 years ago

About "common use case": it's hard to answer :thinking: IMHO, if one decides to enable DHCP, it's specifically to not have to deal with manual configuration in the infrastructure (on the DNS/DHCP server).

I can tell about our own use case: when you use a lot of XCP-ng/CH in a lab in nested to do tons of tests, it's really useful to not have to deal with fixed IP (therefore using DHCP) but also not to deal with tons of "ephemeral" IPs to memorize (you quickly remove/recreate hosts).

What's great with XCP-ng/CH installer: it generates a random host name, so you don't even have to select one manually. This will get rid of having to look at the IP address. Which is worth such a small modification. But again, it's just my opinion and I'm open to suggestions :+1:

robhoes commented 4 years ago

I'd probably set up the DHCP server to return random hostnames (e.g. a name plus an incremental number), but as I said, I'm happy to add this to allow for additional use cases.

nagilum99 commented 4 years ago

Whatever networks I've touched: We never had a DHCP giving names. It's common that e.g. Windows Clients have their name and tell DHCP, which then adds it to the (local) DNS server.

robhoes commented 4 years ago

I've done a squash-and-merge, combining the commit messages a little.