[Dnsmasq-discuss] DNS from dhcp-host while client is offline
Alkis Georgopoulos
alkisg at gmail.com
Fri Oct 8 19:28:07 UTC 2021
Hi Olaf,
I meant that you too generate the dnsmasq configuration files.
I.e. a script or a generation command is involved.
In your example, you maintained your information as a series of shell
variable assignments (e.g. `dnsdomain=home.arpa`).
Then you used the `tee` command to generate a dnsmasq configuration file
for a single client.
I assume that for many clients, you'd use a loop.
Using the sed command is similar although simpler as it avoids the need
for a loop. I use it like this:
1) I maintain all our information in a dhcp-hosts.csv file like the
following:
ac:22:0b:c5:9f:fb,set:ltsp0a1,10.0.1.31,g01pc01
ac:22:0b:2b:df:ba,set:ltsp0a1,10.0.1.32,g01pc02
This is already a valid dnsmasq configuration file.
2) After editing that file, I run the following command to convert it to
an addn-hosts.csv file:
sed -n
's/.*,\([0-9]*\.[0-9]*\.[0-9]*\.[0-9]*\),\([-a-z0-9]*\).*/\1\t\2/p'
dhcp-hosts.csv > addn-hosts.csv
So that way, we maintain a single dhcp-hosts.csv file, and we run a
single command to create the respective addn-hosts.csv file.
Dnsmasq then uses both of these configuration files.
Thank you for your time!
Alkis
On 10/8/21 10:12 PM, Olaf Hering wrote:
Am Fri, 8 Oct 2021 19:02:31 +0300
schrieb Alkis Georgopoulos <alkisg at gmail.com>:
> yeah I too settled for a sed command
Sorry, I do not use sed or anything.
If the MAC/ip/hostname triple is know in advance, create a static config
file with host-record= and dhcp-host=. Sorry if that was unclear.
But if you have a solution that you understand and that appears to work
for you, go for it.
Olaf
More information about the Dnsmasq-discuss
mailing list