DNS Forwarding

Created by Yuriy Andamasov, Modified on Thu, 11 Jan at 5:06 PM by Srividya Anantapatnaikuni

Article review date
2024-01-08
Validated for VyOS versions
1.2.5, 1.3.5, 1.4

Use DNS forwarding if you want your router to function as a DNS server for the local network. There are several options, the easiest being 'forward all traffic to the system DNS server(s)' (defined with set system name-server):

vyos@vyos-rtr# set service dns forwarding system

Manually setting DNS servers for forwarding:

vyos@vyos-rtr# set service dns forwarding name-server 8.8.8.8
vyos@vyos-rtr# set service dns forwarding name-server 8.8.4.4

Manually setting DNS servers with IPv6 connectivity:

vyos@vyos-rtr# set service dns forwarding name-server 2001:4860:4860::8888
vyos@vyos-rtr# set service dns forwarding name-server 2001:4860:4860::8844

Setting a forwarding DNS server for a specific domain:

vyos@vyos-rtr# set service dns forwarding domain example.com server 192.0.2.1

Example 1: router with two interfaces eth0 (WAN link) and eth1 (LAN, with IP address 192.168.0.1). A DNS server for the local domain (example.com) is at 192.0.2.1, other DNS requests are forwarded to Google's DNS servers.

vyos@vyos-rtr# set service dns forwarding domain example.com server 192.0.2.1
vyos@vyos-rtr# set service dns forwarding name-server 8.8.8.8
vyos@vyos-rtr# set service dns forwarding name-server 8.8.4.4
vyos@vyos-rtr# set service dns forwarding listen-address 192.168.0.1

Example 2: Same as example 1 but with additional IPv6 addresses for Google's public DNS servers:

vyos@vyos-rtr# set service dns forwarding domain example.com server 192.0.2.1
vyos@vyos-rtr# set service dns forwarding name-server 8.8.8.8
vyos@vyos-rtr# set service dns forwarding name-server 8.8.4.4
vyos@vyos-rtr# set service dns forwarding name-server 2001:4860:4860::8888
vyos@vyos-rtr# set service dns forwarding name-server 2001:4860:4860::8844
vyos@vyos-rtr# set service dns forwarding listen-address 192.168.0.1

Was this article helpful?

That’s Great!

Thank you for your feedback

Sorry! We couldn't be helpful

Thank you for your feedback

Let us know how can we improve this article!

Select at least one of the reasons
CAPTCHA verification is required.

Feedback sent

We appreciate your effort and will try to fix the article