When setting up an Apache server, it's obviously possible to allow connections from a specific IP address [/range].

I have a dynamic IP and I'm wondering, if I use a DDNS service, whether it's possible to allow connections if the incoming IP matches the current DDNS IP? I'm aware you could make a task to run every few minutes, ping and update the config file with the current IP address, but that would require a service restart which I'd like to avoid if possible.

1 Answer 1


The forward-dns directive seems to be what you're after. According to the docs, it

simply queries the DNS for the host name and allows a client if its IP matches. As a consequence, it will only work with host names, not domain names. However, as the reverse DNS is not used, it will work with clients which use a dynamic DNS service.

So you can specify something like

<Location / >
    Require forward-dns your.ddns.server

and it will do a DNS query whenever a client connects, and denies the connection if it is not from the specified name. Two things to consider:

  1. The forward-dns directive is available from 2.4.19.
  2. Caching DNS servers can still cause some surprise.

You must log in to answer this question.

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