DEV Community

Khadijah (Dana Ordalina)
Khadijah (Dana Ordalina)

Posted on

dnsmasq commands

When using the following commands, you can use either the short or long version. Both versions are listed here separated by a comma.

--E,--expand-hosts

Add the domain to simple names in /etc/hosts in the same way as DHCP-derived names

Example: You want to prepare your network to use your own domain example.com.

-d, --no-daemon
Use debug mode: don’t fork to the background, don’t write a pid file, don’t change user id, generate a complete cache dump on receipt on SIGUSR1, log to stderr as well as syslog, don’t fork new processes to handle TCP queries

Example: You need to use debug mode.
Enter fullscreen mode Exit fullscreen mode

-q, --log-queries
Log the results of DNS queries handled by dnsmasq

Example: You want to log queries in debug mode.
Enter fullscreen mode Exit fullscreen mode

-v, --version
Prints the version number

Example: You need to know what version of dnsmasq you are using.
Enter fullscreen mode Exit fullscreen mode

-p ,--port=<port>
Listen on instead of the standard DNS port (53). Setting this to zero completely disables the DNS function, leaving only DHCP and/or TFTP.

**<port>**
Enter fullscreen mode Exit fullscreen mode

Specifies which port you want to use

Example: You want to disable DNS so you use the argument: –port=0
Enter fullscreen mode Exit fullscreen mode

-i, --interface=
Listen only on the specified interface(s). Dnsmasq automatically adds the loopback (local) interface to the list of interfaces to use when the --interface option is used.

<interface name>
Specifies what network interface you want to use (e.g. eth0, wlan).
Enter fullscreen mode Exit fullscreen mode

Example: If you only want dnsmasq to listen on eth0 then you can use: --interface=eth0

-2, --no-dhcp-interface=
Do not provide DHCP or TFTP on the specified interface, but do provide DNS service

<interface name>
Specifies what network interface you want to use (e.g. eth0, wlan).

Example: You want to disable DHCP on your WLAN you can use:
--no-dhcp-interface=wlan0
Enter fullscreen mode Exit fullscreen mode

-a, --listen-address=
Listen on the given IP address.

<ipaddr>
Specifies the IP address you want dnsmasq to listen on.
Enter fullscreen mode Exit fullscreen mode

Example: You want dnsmasq to listen to your IP address and the loopback so you use: –listen-address=127.0.0.1,192.168.56.10

Both --interface and --listen-address options may be given. If both are given, the set of both interfaces and addresses is used. If no --interface option is given, but --listen-address is, dnsmasq will not automatically listen on the loopback interface. To achieve this, its IP address, 127.0.0.1, must be explicitly given as a --listen-address option.

--clear-on-reload
Whenever /etc/resolv.conf is re-read, clear the DNS cache. This is useful when new nameservers may have different data than that held in cache.

Example: You have new nameservers and want to prepare to restart the network.

-F,--dhcp-range=[network-id,<start-addr>,<end-addr>,<default lease time>]
Enable the DHCP server. Addresses will be given out from the range to and from statically defined addresses given in dhcp-host options. If the lease time is given, then leases will be given for that length of time.

network-id
Enter fullscreen mode Exit fullscreen mode

Specifies which interface you want to hand out addresses to (e.g. eth0, wlan).


Specifies the beginning of the range of addresses you want to hand out.


Specifies the end of the range of addresses you want to hand out.

<default lease time>
Enter fullscreen mode Exit fullscreen mode

Specifies the length of time assigned IP addresses will be valid for before needed to renew the lease. The lease time is in seconds, or minutes (eg 45m) or hours (eg 1h).
Example: You need to enable DHCP on your network so you use: dhcp-range=eth0, 192.168.0.50,192.168.0.150,12h

Top comments (0)