How to Configure aria2 DNS Server on Ubuntu
This guide explains how to configure the aria2 download manager to use a specific DNS server on Ubuntu. Changing the DNS settings can improve download speeds, bypass regional restrictions, or resolve connectivity issues caused by default ISP DNS servers. You will learn how to modify the configuration file or use command-line arguments to set custom DNS addresses like Google DNS or Cloudflare immediately.
Install aria2 on Ubuntu
Before configuring DNS, ensure aria2 is installed on your system. Open your terminal and run the following command to install the package using apt:
sudo apt update
sudo apt install aria2Set DNS Using Command Line Arguments
For one-off downloads, you can specify the DNS server directly in the
command. Use the --async-dns-server flag followed by the IP
address of the desired DNS provider. For example, to use Google Public
DNS:
aria2c --async-dns-server=8.8.8.8 https://example.com/file.zipYou can specify multiple DNS servers by separating them with commas. This provides redundancy if the primary server fails:
aria2c --async-dns-server=8.8.8.8,1.1.1.1 https://example.com/file.zipConfigure DNS Permanently via Configuration File
To make the DNS setting permanent for all downloads, edit the aria2
configuration file. If the file does not exist, create it at
~/.aria2/aria2.conf. Open the file using a text editor like
nano:
nano ~/.aria2/aria2.confAdd or modify the following line to set your preferred DNS servers. This example uses Cloudflare and Google DNS:
async-dns-server=1.1.1.1,8.8.8.8
Save the file and exit the editor. Any subsequent aria2 commands or daemon instances will now use these DNS servers automatically.
Verify DNS Configuration
To confirm that aria2 is using the specified DNS server, you can
enable verbose logging during a download. Run a download command with
the -V flag to see detailed output, including DNS
resolution information:
aria2c -V --async-dns-server=8.8.8.8 https://example.com/test.fileLook for lines in the output indicating DNS resolution to ensure the correct IP addresses are being queried.