In this tutorial, we will be installing dnsmasq on Ubuntu Server Latest. dnsmasq is a lightweight, easy-to-configure DNS server that can also provide DHCP and TFTP services. It is designed to be run on small networks and is particularly useful for home and office environments.
Firstly, it is recommended to update and upgrade the system before proceeding.
sudo apt update
sudo apt upgrade
Next, we will install dnsmasq using the apt package manager.
sudo apt install dnsmasq
Once installed, dnsmasq's default configuration file can be found at /etc/dnsmasq.conf
. A sample configuration file can be found at /usr/share/doc/dnsmasq/examples/dnsmasq.conf.example
.
We can modify the configuration file according to our needs. But before making any changes, it is recommended to make a copy of the original configuration file for backup purposes.
sudo cp /etc/dnsmasq.conf /etc/dnsmasq.conf.bak
We can now edit the configuration file to suit our needs. To edit the configuration file, run the following command:
sudo nano /etc/dnsmasq.conf
Here are some configurations that you might want to add:
To set a DNS server, we can add the following line to the configuration file:
server=8.8.8.8
To configure DHCP service, we can add the following lines:
interface=eth0
dhcp-range=192.168.1.100,192.168.1.150,12h
dhcp-option=3,192.168.1.1
dhcp-option=6,8.8.8.8
The interface
directive specifies the network interface on which to provide DHCP service. In this example, it's eth0
.
The dhcp-range
directive specifies the range of IP addresses to be assigned by the DHCP server. In this example, it's 192.168.1.100
to 192.168.1.150
.
The dhcp-option
directive specifies DHCP options to be provided to clients. In this example, dhcp-option=3,192.168.1.1
sets the default gateway, and dhcp-option=6,8.8.8.8
sets the DNS server.
After making the changes to the configuration file, we need to restart the dnsmasq service for the changes to take effect.
sudo systemctl restart dnsmasq
We can verify that dnsmasq is running and functioning properly by running the following command:
sudo systemctl status dnsmasq
This should display the status of the dnsmasq service and confirm that it is active.
dnsmasq is a simple and lightweight DNS server that can also provide DHCP and TFTP services. It's easy to configure and perfect for small networks. In this tutorial, we've shown you how to install, configure, and use dnsmasq on Ubuntu Server Latest.
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!