DNS – How to Provide Different IP for Server Based on Client Network with Unbound

domain-name-systemsplit-dnsunbound

We have an intranet DNS server using Unbound in FreeBSD. We have another file server with multiple network IP, First one is 10.10.10.10 and Second one in 192.168.10.10.

Is there any way that DNS server provide different IP for this file server based on the client network?

Eg:
For the user from 10.10.x.x network, fileserver ip should be 10.10.10.10
For the user from 192.168.x.x network, fileserver ip should be 192.168.10.10.

Best Answer

How to provide different IP for a server based on client network

The jargon for that is normally "split horizon DNS".

In Unbound that is implemented via "tags and views" functionality. Those make it possible to send specific DNS answers based on the IP address of the client.

The tags functionality makes it possible to divide client source addresses in categories (tags), and use local-zone and local-data information for these specific tags.

A view is a named list of configuration options. The supported view configuration options are local-zone and local-data.

A view is configured using a view clause. There may be multiple view clauses, each with a unique name. For example:

view:
    name: "firstview"
    local-zone: example.com inform
    local-data: 'example.com TXT "this is an example"'
    local-zone: refused.example.nl refuse

...

Mapping a view to a client can be done using the access-control-view element:

 access-control-view: 10.0.5.0/24 firstview