I used to run dnsmasq on a Debian server, so when I started using LEDE/OpenWRT, I set it up the same way, with my hostnames in the /etc/hosts file and corresponding entries in /etc/dnsmasq.conf
I was slightly puzzled that the hostnames did not appear in LuCI, and II have now realised that there appears to be another way of setting this up - via the /etc/config/dhcp file.
Can anyone tell me what the advantages and disadvantages of the two methods are? Is there a reason I should not do it the way I have at the moment?
Files at "/etc/config" are used bu "uci" (LEDE's configuration tool) to dynamically build the configuration files used by other programs. Before dnsmasq starts, uci will create a temporary configuration file, mixing the contents of "/etc/config/dhcp" and "/etc/dnsmasq.conf", and pass it to dnsmasq.
The intention is that you should use "/etc/config/dhcp" for general options supported by uci / LuCi, and "/etc/dnsmasq.conf" for other specific options not supported by uci / LuCi.
Thank you, eduperez. I will try moving my additional hostnames into /etc/config/dhcp and see how well that works. It sounds simpler as at the moment I am adding entries to two files - /etc/hosts and /etc/dnsmasq.conf, which I need to keepin sync.
You can configure (almost) everything via uci and /etc/config/dhcp alone, using /etc/dnsmasq.conf obviously works as well, but it provides less feedback to the rest of the system about your settings. I'm using /etc/config/dhcp to configure around 200 static dhcp leases (IPv4+IPv6)/ hostnames, a dozen cnames and some mx entries.
Hi, how you configure those?
Thanks for the advice here. I've had a go, but I'm not sure how (or if) I can support the configuration I'm looking for via /etc/config/dhcp - can you give some more advice?
Some of my PCs have more than one OS installed. At present, I give each OS a different hostname and (via /etc/hosts and /etc/dnsmasq.conf) assign a different IP address to each. This simplifies things like SSH as it treats each OS install as a completely separate machine.
However, as far as I can see, /etc/config/dhcp assigns both IP address and hostname based on the MAC address, and of course the machine's MAC address does not change when I boot into a different operating system.
So - is there a way of assigning an IP address based on the hostname presented by the PC, using /etc/config/dhcp, instead of basing it on the MAC address?
https://openwrt.org/docs/user-guide/base-system/dhcp_configuration has all the details, but I don't really see your use case being covered.
Yes, I had looked at that page but could not see a way of handling this. I guess I'll stick to doing it directly via the hosts and dnsmasq.conf files. From what you and eduperez have said, that should not cause any problems.