I want to register my device with DNS-SD and I have to register it in the domain assigned by the DHCP server. But how do I get the domain assigned by the DHCP server?
How should I know that a DHCP server has come up on the network and assigned my device new network configuration? Also if DHCP server does not assign a domain, I shall register the service in local domain.
Can I extract domain from resolv.conf?
dhclient
periodically runs a script calleddhclient-script
(incidentally, this is also the script that updates the domain name when using DHCP).dhclient-script
will check for the existence of/etc/dhcp/dhclient-up-hooks
and run it when a new lease is assigned. Put your DNS-SD registration code inside that script.The current domain name can be retrieved using
dnsdomainname
.