Add DNS server on pfsense machine
I know pfsense machines have an included DNS solver, which creates a cache for all the clients connected.
I want to add a DNS server, like bind9 for ubuntu, and I want to create a DNS authoritative zone for the suffix name chosen for the pfsense machine.
Example: in the pfsense configuration I chosen "here" for the LAN suffix, and the name for the machine is "pfsense", so the DNS is this:
pfsense.here -> 192.168.1.1
I want to create many CNAME and A records in the "here" zone, like these:
- pfsense.here -> 192.168.1.1
- server.here -> 192.168.1.10
- dlna.here -> server.here
- gopro.here -> 192.168.1.15
In bind9 configuration I have already done this, but I want to do it in pfsense machine.
Is it possible? And how?
Gertjan last edited by Gertjan
No need to install bind.
Unbound - the resolver, covers you, it can do far more then just a simple DNS cache.
You could do this :
At the bottom of Services => DNS Resolver => General Settings you'l find "Host Overrides".
Just add your host over there.
Or this :
Consider that your server, dlna gopro all use DHCP, add static dhcp leases on the DHCP server page. Add the host name for evert device and on the Services => DNS Resolver => General Settings page check " Static DHCP - Register DHCP static mappings in the DNS Resolver".
Yes, I know I have to add static DHCP leases, in such a way as to assign the same private IP address to the MAC address which I want.
But the fact is to assign a different name (and more than one) from the DHCP client name.
So I want to separate the DHCP server from the DNS resolver.
Is it possible?
Gertjan last edited by
Well, DHCP and DNS are separate functionalities anyway.
You can add as many host overrides into the DS (resolver or forwarder) as you want. They can point to the same IP if needed.
Be careful : not having a DNS on pfSense can have nasty effect for the firewall itself : like the issue : "Help, my pfSense can upgrade neither install packages", etc.
You can install bind if you want, it's available as a pfSense package. But I agree it looks like Unbound can do everything you want.
It looks like you just need to add host overrides in Unbound for the hosts you want to resolve there.
Now I didn't understand good how to do.
There are two cases:
- if I want to override a existing DNS (e.g. "forum.netgate.com") assigning it an A record pointing to 10.45.2.43;
- if I want to create a new DNS zone, which can be the same domain of the pfsense machine or not, creating many A and CNAME records.
Can you explain please?
if I want to override a existing DNS (e.g. "forum.netgate.com") assigning it an A record pointing to 10.45.2.43;
As already said: make a Host override, Host: forum, Domain: netgate.com and assign it an internal IP 10.45.2.43. Your pfSense afterwards will answer any request for forum.netgate.com with 10.45.2.43 to your clients.
if I want to create a new DNS zone, which can be the same domain of the pfsense machine or not, creating many A and CNAME records.
You don't create a DNS zone per se. You don't need to, as you don't run a complete DNS server, that needs(!) a zone to load DNS entries. The DNS Resolver (unbound) can simply act on single Host Overrides and resolve the defined hostname to an IP.
So you want to create "dummy.here" and point it to 10.45.2.43? Do the same as above with the forum!
Afterwards check on a client on LAN with "host", "dig", "nslookup" (depending on your OS). It's as easy as that. If you configure pfSense in general settings to the domain "here" and configure DHCP accordingly, all static IP mappings you create with DHCP are also automatically known to the DNS resolver (check the corresponding box in the DNS resolver screen for that), so you can "populate" your "domain" .here with static IP mappings and overrides without having the need to create a complex DNS setup with bind.
I didn't understand only one step: if the pfsense domain is "here", DHCP and static IPs create the DNS resolver, can I add more hostnames in "here" domain in host override?
And if there is a DHCP client named "hello", and in DNS override I want to point "hello.here" to another IP, can I do it?
you don't have to register dhcp clients in unbound.
And then just create whatever host overrides you want.
Have I to disable the DHCP registration to override a DHCP client name?
You don't have to but having the same name that points to 2 different ips is never good thing. But you could have 2 or more names that point to the same IP.
No, you can add it as a host override and still register it. It overrides the dhcp lease registeration.
Not sure why you would want to that though.
I'm thinking like that because they could be some DHCP clients names already registered in host override section.
Indeed, I tried to add a host override name "pohp.here" which points to an external IP, but when a DHCP client named "pohp" connects, the DNS points to the DHCP client machine, not to the external IP.
Is it possible to override? Or have I to disable DHCP clients registration?
Why would you point pohp.here to an external IP if you have a client called pohp?
Really not understanding your use case... But if your going to put in by hand IP address for clients fqdn, then there is ZERO point to having them register dhcp address into unbound..
You have dhcp clients register in dns when your are NOT going to put in records by hand for them.
I did an example, now I can explain better:
- there is a DHCP client named "server";
- I want to point "server.here" to it;
- I add an host override "server.here" pointing to the machine written in step 1;
- there could be another machine which the DHCP client name is "server".
I'm writing this because I don't administer fully the LAN, and some customers can connect to the wifi, and there could be some inconvenient DHCP clients names.
Should have I to disable the DHCP registration or is there a way to stay secure?
Hmm, I tested that before posting and found it worked fine.
Are you sure you are seeing the same hostname and domain?
Edit: And it's still working after the client lease renewed.
there could be another machine which the DHCP client name is "server".
And why would you need to resolve those? So don't have dhcp register in unbound.. And just put in the host overrides for the stuff you want/need to resolve.
To be honest I really don't understand resolving dhcp clients by name in the first place.. If the box is important enough to you want to get to it by name.. Than it should have a reservation for dhcp so it always get the same IP. So register static dhcp. Or just set the box to be static IP and setup dns to resolve name to that IP, etc..
Well you could argue that clients with dynamic IPs are most likely to need DNS resolution to address them.
But I hear what you're saying.
Either way I have that setup here and it works exactly as expected. I suspect there is actually a mismatch here. For example you enter
client1somewhere and you think it should resolve to an override you have as
client1.domain1.netbut in fact your client is trying to resolve soemthing different like
client1.sub.domain1.netbecause something is misconfigured.
There is a difference between "clients" that get dhcp and "servers" he is using the name server.. While sure you might want to hand info out to the server via dhcp, so you can easy change stuff later like different router or dns, etc.
But server should have a dhcp reservation.
Random clients that are on and off the network, if you have a need to resolve them sure have register their names. But then why would you need to put in a host override? Why would you not just use different sub or domain then..
Just still not getting this use case.
Yeah, the easiest way to avoid this would just be to not add dynamic leases to Unbound.
It's true and easiest disabling the DNS for DHCP clients.
Thanks for all.