Sample Header Ad - 728x90

Configuring dnsmasq so I can use short host names

2 votes
1 answer
642 views
I have set up dnsmasq on my local network that consists of Linux/macOS computers. I have added a line like this in my /etc/dnsmasq.d/home.lan file: dhcp-host=dc:cd:2f:bf:44:12,printer,192.168.0.3 I was hoping/expecting that would mean I can use a command like: ping printer from all the machines on my network, but it cannot resolve it. I know that dnsmasq is working to some extent because the printer requests an IP address when it starts up and configures itself to the correct IP address above. I want to keep all DNS/DHCP configuration in /etc/dnsmasq.d/home.lan as far as possible, rather than editing /etc/hosts or anything else, either on the DNS server or any clients. I researched and found this so I also tried adding: host-record=printer,192.168.0.3 but that didn't help either. --- Here is my config file, running on latest Raspberry Pi OS with the latest dnsmasq: # General configuration domain-needed bogus-priv no-resolv no-hosts server=8.8.8.8 server=1.1.1.1 dhcp-range=192.168.0.3,192.168.0.200,4h dhcp-authoritative # Set default gateway and DNS server for DHCP clients dhcp-option=option:router,192.168.0.1 dhcp-option=option:dns-server,192.168.0.2 # Logging log-facility=/var/log/dnsmasq.log log-queries # Reserved IPs dhcp-host=c8:7f:5f:df:0f:08,router,192.168.0.1 dhcp-host=dc:ab:3f:bf:bb:ab,dnsserver,192.168.0.2 dhcp-host=dc:cd:2f:bf:44:12,printer,192.168.0.3 --- As requested in the comments, if I try this: dig printer @192.168.0.2 I get: ; > DiG 9.18.28-1~deb12u2-Debian > printer @192.168.0.2 ;; global options: +cmd ;; Got answer: ;; ->>HEADER<<- opcode: QUERY, status: NXDOMAIN, id: 18880 ;; flags: qr rd ra; QUERY: 1, ANSWER: 0, AUTHORITY: 0, ADDITIONAL: 1 ;; OPT PSEUDOSECTION: ; EDNS: version: 0, flags:; udp: 4096 ;; QUESTION SECTION: ;printer. IN A ;; Query time: 0 msec ;; SERVER: 192.168.0.2#53(192.168.0.2) (UDP) ;; WHEN: Tue Aug 20 13:25:32 BST 2024 ;; MSG SIZE rcvd: 36 In the log at /var/log/dnsmasq.log, I see: query [A] printer from 192.168.0.2 config printer is NXDOMAIN --- Note that my router is at 192.168.0.1 and the machine running dnsmasq is at 192.168.0.2
Asked by Sophie Bertillon (83 rep)
Aug 20, 2024, 10:53 AM
Last activity: Aug 24, 2024, 05:26 PM