Tadeu Bento

OpenWrt: Custom DNS Server for Specific Devices

In a typical home or office network, all devices use the DNS servers specified by the router. However, there are scenarios where specific devices need to use a different DNS server e.g. TV set-top boxes. This guide will show you how to configure OpenWrt to assign a custom DNS server to specific devices using the uci command-line tool.

Here are some common scenarios where you might need to override the default DNS settings for certain devices:

Configuring OpenWrt for Device-Specific DNS

To assign a different DNS server to specific devices, follow these steps using uci:

1. Define a DHCP tag with a custom DNS server:

uci set dhcp.tag1="tag-dns-tv"
uci set dhcp.tag1.dhcp_option="6,212.55.154.174"

Here, tag-dns-tv is a DHCP tag that specifies the DNS server 212.55.154.174.

2. Assign the tag to a specific device:

uci add dhcp host
uci set dhcp.@host[-1].name='TV-Box'
uci set dhcp.@host[-1].mac="7C:00:00:00:00:77"
uci set dhcp.@host[-1].ip="172.20.1.200"
uci set dhcp.@host[-1].tag="tag-dns-tv"

This ensures that the device with MAC address 7C:00:00:00:00:77 (one of my ISP TV boxes) always receives the IP 172.20.1.200 and uses the DNS server set on the tag.

3. Apply the changes

uci commit dhcp
uci show dhcp
/etc/init.d/dnsmasq restart

These commands save the configuration and restart the dnsmasq service, making the changes take effect.

After applying these settings, restart your TV Box, and then it will be assigned the specified DNS server via DHCP.

Exit mobile version