mail-in-a-box / mailinabox

Mail-in-a-Box helps individuals take back control of their email by defining a one-click, easy-to-deploy SMTP+everything else server: a mail server in a box.
https://mailinabox.email/
Creative Commons Zero v1.0 Universal
14.05k stars 1.44k forks source link

dynamics DNS with mailinabox DNS and pfsense #2183

Open feydreva opened 2 years ago

feydreva commented 2 years ago

Hello,

As recommended by mailinabox, I am using the internal DNS for my domain. Mailinabox run on a VPS as external service I would like to set up DYNDNS for my home address My home gateway is a pfsense box. Goal is to have my home address link to home.domain.xxx

pfsense offer a "custom" set up for dyndns : custom DYNDNS pfsense

I have enter my username and password for update URL, I have used : https://box.domain.xxx/admin/dns/custom/home.domain.xxx/A

but it seem that it does'nt work. Have you tried this set up ? could you guide me through it ? anything I could do to get the dyndns thing working with mailinabox DNS and pfsense ?

There are the log from pfsense : https://gist.github.com/feydreva/e3d67f696ebb34a1a987eb824a322465

thank you !

nomandera commented 2 years ago

I do not know of any native way to make this work with pfsense or OPNsense.

The framework on both ends has all the functionality to do it but no one has ever put enough time into it since other solution are so much less effort.

This is on my wish list because in theory it is probably a small change firewall or MIAB side to make this work

yodax commented 2 years ago

This requires customizing your git MIAB fork (don't do this if you're not comfortable merging/rebasing every release) and I don't have time to support it or make it into a PR. (the nginx stuff was copied from another user, I don't remember who so I sadly can't credit them)

You can add a section to nginx converting the GET to a PUT. That way you can use the pfSense custom dynamic dns option.

diff --git a/conf/nginx-primaryonly.conf b/conf/nginx-primaryonly.conf
index 31bf009..1cf2454 100644
--- a/conf/nginx-primaryonly.conf
+++ b/conf/nginx-primaryonly.conf
@@ -14,6 +14,15 @@
                add_header Content-Security-Policy "frame-ancestors 'none';";
        }

+       location /dynamicdns/ {
+            proxy_method PUT;
+            proxy_pass http://127.0.0.1:10222/;
+            proxy_set_header X-Forwarded-For $remote_addr;
+            add_header X-Frame-Options "DENY";
+            add_header X-Content-Type-Options nosniff;
+            add_header Content-Security-Policy "frame-ancestors 'none';";
+       }
+

Under pfsense add a custom dns (or two if using ipv6) Configure the interfaces, set the username as to the MIAB admin user and the same for the password.

The use this as the url: https://box.tld/dynamicdns/dns/custom/desireddomain.tld

Under result Match add this: OK|updated DNS: kroes.email This handles both the initial set and the later updates.

jvolkenant commented 2 years ago

pfsense's dynamic DNS only supports GET requests, updating IP in MIAB only supports PUT. If you happen to be familar with Haproxy in pfsense, you can support dynamic DNS with no changes to MIAB.

Generally speaking, I've done this to work around having to make changes to MIAB.