Ubuntu comes with systemd-resolve which you need to disable since it binds to port 53 which will conflict with Dnsmasq port.
Run the following commands to disable the service:
sudo systemctl disable systemd-resolved
sudo systemctl stop systemd-resolved
Remove the symlinked resolv.conf file:
ls -lh /etc/resolv.conf
sudo rm /etc/resolv.conf
Create new resolv.conf file:
echo nameserver 1.1.1.1 | sudo tee /etc/resolv.conf
Install Dnsmasq:
sudo apt-get install dnsmasq
Configure Dnsmasq:
sudo nano /etc/dnsmasq.conf
add the configuration:
address=/.localdev/127.0.0.1
Create the resolver for the added address:
sudo mkdir /etc/resolver
sudo touch /etc/resolver/localdev
echo nameserver 127.0.0.1 | sudo tee /etc/resolver/localdev
Restart Dnsmasq:
sudo systemctl restart dnsmasq