dougbw / coredns_omada

CoreDNS plugin for TP-Link Omada SDN
Apache License 2.0
90 stars 9 forks source link

Feature Request: Multiple CNAMEs/Wildcard DNS for Omada Plugin #45

Open allenhutchison opened 2 months ago

allenhutchison commented 2 months ago

The plugin currently allows associating a single hostname with an IP address assigned by Omada. I would like to expand this functionality to either:

Support Multiple CNAMEs: Allow configuration of additional CNAMEs (aliases) pointing to the same IP address. For instance, assign sally.example.home and frank.example.home as CNAMEs to 192.168.0.4 (already assigned to bob.example.home).

Wildcard DNS Entry: Automatically create a wildcard DNS entry alongside the primary hostname. Example: If Omada assigns 192.168.0.4 to bob.example.home, the plugin would also create an A record for *.bob.example.home.

Use Case:

Thanks for considering these. I'd be happy to help implement if you can point me in the right direction.

dougbw commented 2 months ago

Hello, the first thing to mention is that CoreDNS has a large range of built-in plugins which can be used simultaneously, so where possible I would recommend using an existing plugin which offers the functionality you are looking for rather than extending this plugin.

In this case, the file plugin is probably what you are after: https://coredns.io/plugins/file/ - I will look at adding documentation/examples the next time I am updating this as you are not the first person to ask for similar functionality.

Saying that, I am open extending functionality of the Omada plugin providing there is a use case and it actually represents some configuration on the Omada controller (e.g DHCP reservations could have corresponding DNS records created).

Regarding CNAME/wildcards records specifically there is not really a good way to configure this anywhere on the Omada controller, so IMO it is better handled by another plugin

allenhutchison commented 2 months ago

Thanks for the reply. Yes I looked at the file plugin, but it wasn't clear to me that I could have this plugin and the file plugin both representing the same domain. I'll look at that in more detail.

I agree that this doesn't represent additional state from Omada. The wildcard solution was my preferred strategy, as I envisioned that as a simple way to keep all the config inside Omada by just setting a preference in this plugin to create wildcard subdomains for all omada names. Any other solution requires me to split the config between Omada and another system (file plugin or another name service) which is what I was trying to avoid with this feature request.

Thanks again for considering.

dougbw commented 2 months ago

There should not be any issues serving the same domain from multiple plugins - The plugins are specified in a particular order at compile time (see plugin.cfg which affects which order they are processed in.

In pre-built container images I have placed the Omada plugin above the file plugin, which means that the Omada plugin will attempt to resolve the query first, but if it cannot resolve it then it will be passed to the next plugin in the chain (file plugin in this case).

I will keep this issue around for the time being as I will do some investigation in to the options you mentioned when I get a chance.

dougbw commented 3 days ago

I havn't had a chance to work on this project for a while, but I just raised a PR with a solution. I recently added support for resolving DHCP reservations, and this can be used to represent a wildcard record e.g:

image

I did investigate automatically creating wildcard records for all clients - it looks straight forward to implement but I am concerned about it causing unexpected issues, so have gone with this DHCP reservation option for now.