DNS Forwarding in VyOS

Created by Yuriy Andamasov, Modified on Thu, 11 Jan at 4:49 PM by Srividya Anantapatnaikuni

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

Use DNS forwarding if you want your router to function as a DNS server for local networks. The minimal information required for DNS Forwarding to work is:

  • Networks from which the router would accept DNS queries.
  • Router IP address, or addresses, in which the router would accept the DNS queries.
  • Name server's IP address that the router would use to forward DNS queries.

Commands to be executed on VyOs router to enable DNS Forwarding:

vyos@vyos-rtr# set service dns forwarding allow-from 
vyos@vyos-rtr# set service dns forwarding listen-address 
vyos@vyos-rtr# set service dns forwarding name-server 

Example1: router with LAN network 192.168.1.0/24 and IP 192.168.1.1. Also, 192.168.2.0/24 and IP 192.168.2.1/24 assigned to another VLAN, and forward DNS queries to Googles servers

vyos@vyos-rtr# set service dns forwarding allow-from 192.168.0.0/16
vyos@vyos-rtr# set service dns forwarding listen-address 192.168.1.1
vyos@vyos-rtr# set service dns forwarding listen-address 192.168.2.1
vyos@vyos-rtr# set service dns forwarding name-server 8.8.8.8
vyos@vyos-rtr# set service dns forwarding name-server 2001:4860:4860::8888

If forwarding for specific domains is required, use next command:

vyos@vyos-rtr# set service dns forwarding domain  server 

For example, forwarding domain example.com queries to name server 192.168.2.20:

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

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