Dnsmasq can be used on a to create a route to and from a LAN pc as a DHCP server and can also be configured as a DNS cacher. Dnsmasq is lightweight and designed for networks with less that 50 computers.
Dnsmasq is in the repository and can be added by:
pacman -S dnsmasq
Dnsmasq as a DHCP Server
The dnsmasq configuration file needs to be configured. Edit
# Only listen to router LAN NIC, also opens up tcp/udp port 53 to localhost # and udp port 67 to world: interface=<LAN-NIC> # dnsmasq will open tcp/udp port 53 and udp port 67 to world to help with # dynamic interfaces. Dnsmasq will discard world requests to them, but the # paranoid might like to close them and let the kernel handle them: bind-interfaces # Dynamic range of IPs to make available to LAN pc dhcp-range=192.168.111.50,192.168.111.100,12h # If you’d like to have a static ip, bind the LAN computer's NIC MAC address: dhcp-host=aa:bb:cc:dd:ee:ff,192.168.111.22
Dnsmasq as a DNS Cacher
If you're using dnsmasq on a router dnsmasq is already setup to listen to DNS queries on localhost. If you're using dnsmasq on a client, edit
/etc/dnsmasq and add:
To be able to use DNS caching the dhcp client must be directed to localhost for DNS queries.
Dhcpcd has the ability to prepend or append nameservers to
/etc/resolv.conf by creating
echo "127.0.0.1" > /etc/resolv.conf.head
If you use dhclient (NetworkManager uses dhclient) add to
prepend domain-name-servers 127.0.0.1;
Dnsmasq runs as a daemon and can be started by:
To add dnsmasq to run at boot add dnsmasq to your
DAEMONS=(network dnsmasq ...)
To see if dnsmasq is working as a DHCP server and/or a DNS cacher. Dnscache logs are sent to
Test Dnsmasq as a DHCP Server
From the LAN pc make sure you have the network to set up a route with dhcp and start the network.
Test Dnsmasq as a DNS Cacher
First restart the network so that localhost gets prepended to
Then do a DNS lookup (dig is part of dnsutils):
dig http://archlinux.org | grep "Query time"
Do it again to test for a DNS cache query.