### Install Dnsmasq Source: https://dnsmasq.org/docs/setup.html Installs Dnsmasq using the make install command. Ensure you have the necessary build tools. ```bash make install ``` -------------------------------- ### Send Encapsulated Vendor-Class Option Source: https://dnsmasq.org/docs/dnsmasq-man.html This example shows how to send an encapsulated vendor-class specific option to clients matching 'PXEClient'. The '0.0.0.0' is the mftp-address. ```bash --dhcp-option=vendor:PXEClient,1,0.0.0.0 ``` -------------------------------- ### Dnsmasq DHCP Host Configuration Examples Source: https://dnsmasq.org/docs/dnsmasq-man.html Use --dhcp-host to specify per-host DHCP parameters. This allows assigning a fixed IP address, hostname, and lease time to a device identified by its MAC address or client ID. It can also be used to ignore client-ids and use MAC addresses only. ```bash --dhcp-host=00:20:e0:3b:13:af,wap,infinite ``` ```bash --dhcp-host=lap,192.168.0.199 ``` ```bash --dhcp-host=id:01:02:03:04,..... ``` ```bash --dhcp-host=id:clientidastext,..... ``` ```bash --dhcp-host=laptop,[1234::56] ``` ```bash --dhcp-host=laptop,[1234:50/126] ``` ```bash id:* ``` -------------------------------- ### Tag MAC Address Prefix for Custom Options Source: https://dnsmasq.org/docs/dnsmasq.conf.example Apply a tag ('red') to all devices whose MAC addresses start with a specified prefix. This allows for group-based option assignment. ```dnsmasq dhcp-host=11:22:33:*:*:*,set:red ``` -------------------------------- ### Assign IP by Client Identifier Source: https://dnsmasq.org/docs/dnsmasq.conf.example Assign a static IP address to a device using its client identifier (e.g., a GUID or other unique ID). ```dnsmasq dhcp-host=id:01:02:02:04,192.168.0.60 ``` -------------------------------- ### Static DHCP Host Assignment by MAC Address Source: https://dnsmasq.org/docs/FAQ When a DHCP client sends a client ID, dnsmasq may assign a dynamic address if the MAC address has a static assignment but the client ID differs. This example shows how to configure static assignment using only the MAC address. ```dnsmasq dhcp-host=11:22:33:44:55:66,1.2.3.4 ``` -------------------------------- ### Assign Static IP, Hostname, and Lease Time Source: https://dnsmasq.org/docs/dnsmasq.conf.example Configure a device with a specific MAC address to receive a fixed hostname, IP address, and lease duration. ```dnsmasq dhcp-host=11:22:33:44:55:66,fred,192.168.0.60,45m ``` -------------------------------- ### Configure Special DNS Servers Source: https://dnsmasq.org/docs/setup.html Use the server option to specify a DNS server for a particular domain. This is useful for internal domains or custom DNS setups. ```dnsmasq server=/internal.myco.com/192.168.10.1 ``` ```dnsmasq server ``` -------------------------------- ### Configure MX Record for Mailhub Source: https://dnsmasq.org/docs/setup.html Use mx-host to serve an MX record for a specified address. By default, it points to the local machine. Use mx-target to specify a different host. ```dnsmasq mx-host=mail.example.com ``` ```dnsmasq mx-host=mail.example.com,mailserver.example.net ``` -------------------------------- ### Configure DNS Servers with DHCP Source: https://dnsmasq.org/docs/setup.html This script configures DNS servers for Dnsmasq when using DHCP. It processes a comma-separated list of DNS server IPs and writes them to the resolv.conf file. ```bash echo -n >|/etc/dhcpc/resolv.conf dnsservers=${DNS//,/ } for serv in $dnsservers; do echo "nameserver $serv" >>/etc/dhcpc/resolv.conf done ``` -------------------------------- ### Set NTP Server Options Source: https://dnsmasq.org/docs/dnsmasq.conf.example Configure the IP addresses of Network Time Protocol (NTP) servers to be provided to DHCP clients. ```dnsmasq dhcp-option=option:ntp-server,192.168.0.4,10.10.0.5 ``` -------------------------------- ### GetVersion Source: https://dnsmasq.org/docs/DBus-interface Retrieves the currently running version of Dnsmasq. ```APIDOC ## GetVersion ### Description Returns a string containing the version of dnsmasq running. ### Method DBus Method ### Endpoint uk.org.thekelleys.dnsmasq/uk/org/thekelleys/dnsmasq ### Parameters None ### Response #### Success Response - **version** (string) - The version string of Dnsmasq. ``` -------------------------------- ### Configure /etc/hosts File Source: https://dnsmasq.org/docs/setup.html Dnsmasq reads the /etc/hosts file for local hostname to IP address mappings. This is a standard configuration detail. ```dnsmasq /etc/hosts ``` -------------------------------- ### Assign IP by Hostname Source: https://dnsmasq.org/docs/dnsmasq.conf.example Assign a static IP address to a device based on the hostname it reports. An infinite lease time is specified. ```dnsmasq dhcp-host=bert,192.168.0.70,infinite ``` -------------------------------- ### Basic Authoritative Server Configuration Source: https://dnsmasq.org/docs/dnsmasq-man.html Configure dnsmasq to act as an authoritative server for a zone, specifying the external interface and the zone details. This requires corresponding DNS records in an external zone. ```bash --auth-server=server.example.com,eth0 --auth-zone=our.zone.com,1.2.3.0/24 ``` -------------------------------- ### Enable Host Entry from /etc/ethers Source: https://dnsmasq.org/docs/dnsmasq.conf.example Allow dnsmasq to use host entries defined in /etc/ethers for DHCP assignments when a client presents the specified hostname. ```dnsmasq dhcp-host=judge ``` -------------------------------- ### Configure DHCP Option 252 for Windows 7 Source: https://dnsmasq.org/docs/FAQ Use this configuration to provide an empty DHCP option 252 for Windows 7 if WPAD is not needed. This resolves issues where Windows 7 may fail to obtain an IP address due to missing this option. ```dnsmasq dhcp-option=252,"\n" ``` -------------------------------- ### Send Encapsulated Option Source: https://dnsmasq.org/docs/dnsmasq-man.html This demonstrates encapsulating option 190 ('iscsi-client0') within option 175. ```bash --dhcp-option=encap:175,190,iscsi-client0 ``` -------------------------------- ### Read MAC-IP Mappings from /etc/ethers Source: https://dnsmasq.org/docs/dnsmasq.conf.example Instruct dnsmasq to read and apply DHCP host configurations from the '/etc/ethers' file, similar to using '--dhcp-host' options. ```dnsmasq read-ethers ``` -------------------------------- ### Assign IP by InfiniBand Hardware Address and Derived Client ID Source: https://dnsmasq.org/docs/dnsmasq.conf.example Assign a static IP address to an InfiniBand interface using its hardware address and a client ID derived from a prefix and the latter part of the hardware address. ```dnsmasq dhcp-host=id:ff:00:00:00:00:00:02:00:00:02:c9:00:f4:52:14:03:00:28:05:81,192.168.0.61 ``` -------------------------------- ### Tag by MAC Address Pattern Source: https://dnsmasq.org/docs/dnsmasq.conf.example Assign a tag ('red') to clients whose MAC address matches a specified pattern. ```dnsmasq dhcp-mac=set:red,00:60:8C:*:*:* ``` -------------------------------- ### Send DHCPv6 DNS Server Options (Local and Remote) Source: https://dnsmasq.org/docs/dnsmasq.conf.example Configure DHCPv6 clients to use the dnsmasq server itself (represented by '::') and another specified IPv6 address as DNS servers. ```dnsmasq dhcp-option=option6:dns-server,[::],[1234::88] ``` -------------------------------- ### Defeat Wildcards in TLDs Source: https://dnsmasq.org/docs/setup.html Use bogus-nxdomain to specify an IP address that should receive NXDOMAIN responses for wildcard queries in top-level domains. ```dnsmasq bogus-nxdomain=64.94.110.11 ``` ```dnsmasq bogus-nxdomain ``` -------------------------------- ### Assign IP by String Client Identifier Source: https://dnsmasq.org/docs/dnsmasq.conf.example Assign a static IP address to a device using a string as its client identifier. ```dnsmasq dhcp-host=id:marjorie,192.168.0.60 ``` -------------------------------- ### Static DHCP Host Assignment by Client ID Source: https://dnsmasq.org/docs/FAQ To resolve issues with static DHCP assignments where client IDs differ between boot and OS startup, configure the static assignment using the client ID, which typically includes the MAC address. ```dnsmasq dhcp-host=id:01:11:22:33:44:55:66,1.2.3.4 ``` -------------------------------- ### GetServerMetrics Source: https://dnsmasq.org/docs/DBus-interface Returns per-DNS-server metrics. ```APIDOC ## GetServerMetrics ### Description Returns per-DNS-server metrics. ``` -------------------------------- ### Enable Self-MX Records Source: https://dnsmasq.org/docs/setup.html The selfmx option enables MX records pointing to local machines, useful for mailers that require an MX record and do not fall back to A records. ```dnsmasq selfmx ``` -------------------------------- ### Enable Query Logging Source: https://dnsmasq.org/docs/setup.html The log-queries option enables verbose logging of DNS queries handled by dnsmasq. It also causes SIGUSR1 to dump the cache to syslog. ```dnsmasq log-queries ``` -------------------------------- ### GetLoopServers Source: https://dnsmasq.org/docs/DBus-interface Retrieves loop servers (only available if compiled with HAVE_LOOP). ```APIDOC ## GetLoopServers ### Description (Only available if dnsmasq compiled with HAVE_LOOP) ### Method DBus Method ### Endpoint uk.org.thekelleys.dnsmasq/uk/org/thekelleys/dnsmasq ### Parameters None ### Response #### Success Response - **servers** (array of STRING) - A list of loop servers. ``` -------------------------------- ### Configure Hostname for DHCP Client Source: https://dnsmasq.org/docs/FAQ To ensure hostnames are sent by DHCP clients, configure the 'hostname' keyword in /etc/network/interfaces for most clients. For dhclient, add 'send host-name ' to /etc/dhclient.conf. ```bash send host-name daisy ``` -------------------------------- ### Configure IP Address Source: https://dnsmasq.org/docs/setup.html The address option can be used to specify an IP address for dnsmasq to bind to, or for other network-related configurations. ```dnsmasq address ``` -------------------------------- ### Send DHCPv6 DNS Server Options Source: https://dnsmasq.org/docs/dnsmasq.conf.example Provide IPv6 DNS server addresses to clients using DHCPv6. Note the obligatory square brackets around IPv6 addresses. ```dnsmasq dhcp-option=option6:dns-server,[1234::77],[1234::88] ``` -------------------------------- ### Configure Network Interface Source: https://dnsmasq.org/docs/setup.html The interface option specifies which network interfaces dnsmasq should listen on for DNS requests. ```dnsmasq interface ``` -------------------------------- ### Set IPv6 NTP Server DHCP Option Source: https://dnsmasq.org/docs/dnsmasq-man.html Configure the NTP server for IPv6 clients. IPv6 options use the 'option6:' prefix and require IPv6 addresses to be bracketed. ```bash --dhcp-option=option6:ntp-server,[1234::56] ``` -------------------------------- ### Assign Static IP by MAC Address Source: https://dnsmasq.org/docs/dnsmasq.conf.example Assign a specific hostname to a device based on its MAC address. ```dnsmasq dhcp-host=11:22:33:44:55:66,fred ``` -------------------------------- ### Tag by DHCP User Class String Source: https://dnsmasq.org/docs/dnsmasq.conf.example Assign a tag ('red') to clients whose DHCP user class string contains a specific substring (e.g., 'accounts'). ```dnsmasq dhcp-userclass=set:red,accounts ``` -------------------------------- ### Tag by DHCP Vendor Class String Source: https://dnsmasq.org/docs/dnsmasq.conf.example Assign a tag ('red') to clients whose DHCP vendor class string contains a specific substring (e.g., 'Linux'). ```dnsmasq dhcp-vendorclass=set:red,Linux ``` -------------------------------- ### Set NTP Server DHCP Option Source: https://dnsmasq.org/docs/dnsmasq-man.html Configure the NTP server address for DHCP clients using option number 42 or the name 'ntp-server'. ```bash --dhcp-option=42,192.168.0.4 ``` ```bash --dhcp-option=option:ntp-server,192.168.0.4 ```