Friday, November 17, 2017

Running DNS Server on Ubuntu Linux

Technitium DNS Server is build to be cross platform using the .NET Standard 2.0. You can run the DNS Server Portable App on Linux or macOS by using .NET Core 2.0 or Mono Framework. This post is written for Ubuntu Linux but, you can easily follow similar steps on your favorite distro.

Using .NET Core

Download the latest .NET Core runtime (tar.gz) file from here. Start Terminal and follow the steps below to run DNS Server on Ubuntu:

  1. Assuming the downloaded runtime file is in Downloads folder. Follow below step to install it. Skip this step if you already have it installed.
    $ cd ~/Downloads/
    $ sudo mkdir /usr/share/dotnet/
    $ sudo tar -xzvf dotnet-runtime-2.0.4-linux-x64.tar.gz -C /usr/share/dotnet/
    $ sudo ln -s /usr/share/dotnet/dotnet /usr/local/bin/
    $ sudo apt-get install libcurl4-openssl-dev
    
  2. Download DNS Server Portable App tar.gz file using wget as shown below.
    $ wget https://technitium.com/download/dns/DnsServerPortable.tar.gz
  3. Extract the files and start DNS Server.
    $ tar -xzvf DnsServerPortable.tar.gz
    $ cd DnsServer
    $ sudo ./start.sh
    
  4. Open the url http://localhost:5380/ to access the web console.

Using Mono Framework

Start Terminal and follow the steps below to run DNS Server on Ubuntu:

  1. Install Mono Framework. Skip this step if you already have it installed.
    $ sudo apt-get -y install mono-complete
  2. Install unzip. Skip this step if you already have it installed.
    $ sudo apt-get -y install unzip
  3. Download DNS Server Portable App zip file using wget as shown below.
    $ wget https://technitium.com/download/dns/DnsServerPortable.zip
  4. Extract the files and start DNS Server.
    $ unzip DnsServerPortable.zip
    $ cd DnsServer
    $ sudo mono DnsServerApp.exe
    
  5. Open the url http://localhost:5380/ to access the web console.

You may get this error shown below when you start DNS Server:

Unhandled Exception: System.Net.Sockets.SocketException: Address already in use
   at System.Net.Sockets.Socket.UpdateStatusAfterSocketErrorAndThrowException(SocketError error, String callerName)
   at System.Net.Sockets.Socket.DoBind(EndPoint endPointSnapshot, SocketAddress socketAddress)
   at System.Net.Sockets.Socket.Bind(EndPoint localEP)
   at DnsServerCore.DnsServer.Start()
   at DnsServerCore.DnsWebService.Start()
   at DnsServerApp.Program.Main(String[] args)
Aborted (core dumped)
This error means that another application is already running on the DNS UDP port 53. On Ubuntu, usually its dnsmasq or systemd-resolved service running. You may confirm this by running sudo netstat -nlpu command.

Follow the steps below to disable the dnsmasq service:
  1. Edit the NetworkManager.conf file to disable dnsmasq service:
    $ sudo nano /etc/NetworkManager/NetworkManager.conf
    
    Comment out the dns=dnsmasq line by adding # character at the beginning like this #dns=dnsmasq and exit the editor by pressing CTRL+X and enter y to save the file.
  2. Restart the computer to apply changes as shown below:
    $ sudo reboot now
    
  3. After system reboot, open Terminal and try again to start DNS Server.

Follow the steps below to disable the systemd-resolved service:
  1. Disable the systemd-resolved service and stop it:
    $ sudo systemctl disable systemd-resolved.service
    $ sudo service systemd-resolved stop
    
  2. Edit your /etc/NetworkManager/NetworkManager.conf using nano:
    $ sudo nano /etc/NetworkManager/NetworkManager.conf
    
    Put the following line in the [main] section of your /etc/NetworkManager/NetworkManager.conf as shown below:
    [main]
    dns=default
    
  3. Edit your /etc/resolv.conf using nano:
    $ sudo nano /etc/resolv.conf
    
    Edit the existing nameserver entry to the one shown below in your /etc/resolv.conf
    nameserver 127.0.0.1
    
  4. Restart network-manager:
    $ sudo service network-manager restart
    
  5. Now try again to start DNS Server.

That's it!

The DNS Server is running and you can configure your network with the IP address of this computer for DNS resolution.

Check out the web console to create zone, check cached zones, access DNS client tool and configure server settings.

The DNS Server creates a folder named config in the current folder which contains the server config and zone files. Make sure you copy this folder while moving the DNS server folder if you want all the zone files and config to persist.

If you have any trouble installing mono framework the refer to this official mono installation guide.

For any related queries, feel free to comment on this post.

4 comments:

  1. Hello my loved one! I wish to say that this post is amazing, nice written and come
    with approximately all significant infos. I would like to look
    more posts like this .

    ReplyDelete
  2. I have a problem regarding to hosting a hotspot with spoofed MAC address. None of my devices can connect to my hotspot unless I revert the MAC address back to original. Is there anyways to be able to host a hotspot with spoofed MAC Address?

    ReplyDelete
    Replies
    1. Send email to support@technitium.com with screenshots and details like OS version mobile device type etc.

      Delete
  3. I have a problem regarding to hosting a hotspot with spoofed MAC address. None of my devices can connect to my hotspot unless I revert the MAC address back to original. Is there anyways to be able to host a hotspot with spoofed MAC Address?

    ReplyDelete