0

I am building a black box NAS for a friend, that is going to run a few docker containers with things like NextCloud and a few other services. By black box I mean that it should be setup in a way that no configuration is required, it's just going to be plugged in to he's router and work.

I want to setup dnsmasq with a wildcard domain that should redirect all requests to a reversed proxy which will then internally redirect requests to the correct service. But this means that the DNS need to point to itself, which is problematic seen as this machine is meant to obtain it's IP via DHCP from the router.

address=/mydomain.com/<host_ip>

My only current idea is to have a systemd service run when network is online and then update the conf file with the hosts current IP, but this seams so hacky. Is there no way to automate this with dnsmasq itself?

1
  • DNS ≠ DHCP. Also, there's nothing stopping you running a DNS service on a machine that doesn't use it itself Commented Jul 8, 2023 at 13:30

1 Answer 1

0

(My answer reflects on a typical SOHO environment)

You can't do this without at least minor configuration on the client side (If we include router as well), because you need direct the client computer's request to the right ip address, where the services like NextCloud will be running.
As your friend's DHCP service has already one or more DNS server entries that (by default) correspond to one of the ISP's recursive DNS server, you would need to overrule this mechanism.
I can see that you want to implement this service with zero touch configuration required, but if you go for a local DNS server, then you have to at least set a fix ip address, that refers to in the DHCP settings on the router.

I suggest to do one of the following:

-Run a local Recursive DNS server, add a zone mydomain.com, set the A records that points to the reverse proxy's ip address and set this DNS server on the router. (In this case you will have full control over DNS settings with minuscule config on client side, But with more job to do and responsibility, because this have to also reply any web related DNS queries.

-Modify the hosts file on the client computer where you can add entries with the destination ip address (reverse proxy's ip) with each subdomain. (I would recommend this one in a small environment)
You can make this method more elegant by running a startup script that pulls the hosts file from FTP, so you can achieve a centralized solution, when it comes to updating the domain mapping.) This script must be be placed on each client devices, which can be cumbersome on mobile devices.

As you see, you need to consider responsiblity and client side configuration to find the right solution, but none of them involve 0% configuration on client side.

3
  • The idea is of cause to add this server to be used as DNS for the routers DHCP. The setup should only require some Router setup like changing the DNS and reserving the IP for the server in the DHCP stack. I am already running a similar setup at home, but that server uses static IP, because I can easily manage these things and the network is known.
    – dbergloev
    Commented Jul 8, 2023 at 16:11
  • I should maybe also mention, that everything is running in docker. Så the DNS cannot point to the reversed proxy, because it uses a private bridge. There is only one real IP, and that is the host, with some port forwarding like 53, 80, 443, ...
    – dbergloev
    Commented Jul 8, 2023 at 16:25
  • Well in any case, my question was whether this was possible or not. It seams that it's not. However my solution with using a systemd script to update the config when the network is brought up is working fine, so I will just stick with this for now.
    – dbergloev
    Commented Jul 8, 2023 at 23:17

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .