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.1 (recommended) or Mono Framework. This post is written for Ubuntu Linux but, you can easily follow similar steps on your favorite distro.

Using .NET Core

Install the latest .NET Core runtime from here. Start Terminal and follow the steps below to run DNS Server on Ubuntu:

  1. Download DNS Server Portable App tar.gz file using wget as shown below.
    $ wget https://technitium.com/download/dns/DnsServerPortable.tar.gz
  2. Extract the files and start DNS Server.
    $ tar -xzvf DnsServerPortable.tar.gz
    $ cd DnsServer
    $ sudo ./start.sh
    
  3. 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 update
    $ sudo apt-get -y install mono-complete
    $ sudo mozroots --import --ask-remove
    
  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.

Technitium DNS Server Released!

Technitium DNS Server is an open source tool that allows anyone to run DNS server on their computer or local network. Its aimed towards software developers who like to simulate live production scenarios on their laptop or local network setup for testing or debugging purposes. However, it can be used for any DNS related requirement. Applications of using your own local DNS server is limited only by the your imagination!

Technitium DNS Server Web Console

The DNS server is cross platform and can be deployed on Windows, Linux or macOS (using Mono Framework or .NET Core). The DNS portable console app allows running the service instantly with zero initial configuration, just run the executable and its ready. The DNS server provides web console access that allows it to be accessible over network.

A unique feature available with this server is to enable/disable hosted zones with a single click allowing switching between staging/testing setup to live production setup instantly. Once a zone is disabled, the DNS server will start recursively resolving the domain and use cached results. When the zone is enabled, the records hosted on the server override the cached results. This reduces a lot of efforts when trying to achieve similar thing using hosts file. Hosted records can be set with low TTL values to force the operating system DNS client to re-query.

The DNS server has many standard features like recursion, caching, wildcard sub domains, forwarders, IPv6 support etc. A very useful and frequently used feature is the DNS Client tool included with the web console. This DNS Client tool is a general purpose DNS resolver that can be used to query any name server accessible over the network. The DNS Client can also perform recursive query on its own and display results from the authoritative name server for the given domain. The recursive query feature saves time by automatically finding out the authoritative name servers via the root servers. DNS Client is also available as a separate online tool at dnsclient.net website.

Apart from just resolving queries, the DNS Client also provides a very useful feature to import records from the output of the query into the local DNS. This feature is really useful when you quickly want to copy existing records for a given domain. You can query with type ANY which would list out all possible records or use specific type needed, and import them in one go into the local server zone. You may then edit a few records with value that you need for testing and its ready to use. With query type ANY, its advised to use TCP protocol since the UDP protocol may not accommodate all the records resulting in a truncated response.

Technitium DNS Server include following features:

  • Fully manageable local DNS server.
  • Wildcard sub domain support.
  • Disable/Enable hosted zones for quick switching between staging & production.
  • DNS Client tool for resolving queries.
  • Import records feature allows to import records of live domain using DNS Client.
  • Recursive querying support.
  • Web console for allowing access over network.
  • DNS caching with cache viewer interface in web console.
  • Forwarders setup to allow chaining other DNS server to reduce response time.
  • IPv6 network support in DNS server core for querying.
  • Built-in system logs and query logs.
  • Cross platform implementation for running on Linux or macOS using Mono Framework or .NET Core.

There are many applications of having a self hosted local DNS server. Some of them are:

  • Software developers or web developers can simulate live setup without need to use hosts file.
  • Security researchers can use it in their lab setups for spoofing domain names while performing experiments.
  • Users can keep watch on domain being used by various applications using the Cached Zone listing.
  • Block certain domains to partially or fully fail a website/application feature. User can block domain by creating an empty zone such that the application/website using that domain can no longer get the right IP address to the server failing all requests.

It must be noted that this DNS server is not suitable to be used for production or any critical application. The software is released as alpha version denoting that its not yet stable and may have bugs.

Technitium DNS Server is open source and available under GNU General Public Licence (GPL) v3 on GitHub.

Comments and feedback are things that help push new features and improve usability, and thus are most welcome. Send your feedback to support@technitium.com or leave your comments below.