How to Install Dnsmasq on Manjaro

Dnsmasq is a lightweight DNS and DHCP server that can be used to provide DNS resolution and DHCP IP address assignment to a small network. It is available on many Linux distributions, including Manjaro. In this tutorial, we will go through the steps to install dnsmasq on Manjaro.

Prerequisites

Before you begin, make sure your Manjaro system is up to date by running the following command in the terminal:

sudo pacman -Syu

Step 1: Install Dnsmasq

To install dnsmasq, run the following command in the terminal:

sudo pacman -S dnsmasq

This will download and install dnsmasq and all its dependencies.

Step 2: Configure Dnsmasq

By default, dnsmasq is not configured to run as a DNS server or DHCP server. To configure it, you need to create a configuration file.

Create a new configuration file for dnsmasq in the /etc directory by running the following command:

sudo nano /etc/dnsmasq.conf

This will open the configuration file in the nano text editor.

Add the following lines to the configuration file:

# Listen on the local interface only
interface=lo

# Bind dnsmasq to a specific IP address
bind-interfaces

# Only use resolv.conf for nameservers, not for domain search
no-resolv

# Add local IP addresses to resolv.conf
no-poll
server=/mylocaldomain.com/192.168.1.1

# Set the DHCP range
dhcp-range=192.168.1.50,192.168.1.150,255.255.255.0,12h

The above configuration sets dnsmasq to listen only on the local interface, binds it to a specific IP address, and adds local IP addresses to resolv.conf. It also sets the DHCP range to assign IP addresses from 192.168.1.50 to 192.168.1.150, with a lease time of 12 hours.

Step 3: Start Dnsmasq

To start dnsmasq, run the following command in the terminal:

sudo systemctl start dnsmasq

To enable dnsmasq to start at boot, run the following command:

sudo systemctl enable dnsmasq

Step 4: Test Dnsmasq

To test if dnsmasq is working correctly, try pinging a local hostname. If dnsmasq is correctly configured, it should resolve the hostname to an IP address.

ping mylocalhost.mylocaldomain.com

Conclusion

Congratulations! You have successfully installed and configured dnsmasq on Manjaro. It is now ready to provide DNS resolution and DHCP IP address assignment to your local network.

If you want to self-host in an easy, hands free way, need an external IP address, or simply want your data in your own hands, give IPv6.rs a try!

Alternatively, for the best virtual desktop, try Shells!