TechnitiumSoftware / DnsServer

Technitium DNS Server
https://technitium.com/dns/
GNU General Public License v3.0
3.83k stars 399 forks source link

[Feature request] Allow manual override/additions to Geo Distance app #867

Closed Tivin-i closed 3 months ago

Tivin-i commented 4 months ago

Would like to request the ability to add manual additions to the Geo Distance Apps.

The use case is when using private networks over overlay networks such as wireguard/tailscale/netbird/OpenVPN and being able to route the addresses to the closest resources.

I tried recompiling the maxdb, but seems I am screwing up somewhere but can't figure out where.

ShreyasZare commented 4 months ago

Thanks for the feature request. There is a better solution to this which is by combining Split Horizon app with the Geo Distance app.

For this, you first add an Split Horizon APP record which uses CNAME class path. Here you configure your private networks and use a domain name which has A/AAAA records that have your private IP for the server. Then you have an catch-all entry for 0.0.0.0/0 where you specify the domain name for the APP record of the Geo Distance app.

For your actual domain name, use a CNAME entry that points to the split horizon APP record. You can have multiple CNAME entries for all your servers that point to the same APP record thus reusing the same config.

This setup will thus check if request is from private IP and provide private IP for the server and for other cases it will cause the Geo Distance app to respond with closest server IP.

Tivin-i commented 4 months ago

Yea, that's what I have been doing so far (I think). However some of the servers are not in the same Geo, connected over wireguard.

Singapore - webserver + GaleraDB US - webserver + GaleraDB

Instead of using a proxy to route traffic between the databases, the databases have replication set between them, and the webservers would connect to the closest database (as it is mostly read operations).

I do find out that US webserver connects to Singapore database in this scenario.

Correct me if I misunderstood your recommendation below, I am a bit lost when you explain the catch all entry for the geo distance app:

APP record for test-1.example.com

{ "public": "api.example.com", "100.64.0.0/10": "api.int.example.corp", "0.0.0.0/0": "api.example.com" Not sure if this is what you meant }

GEO Distance APP api.example.com [ { "name": "sg-db-1", "lat": "1.3370", "long": "103.8933", "addresses": [ "2.3.4.5" ] }, { "name": "sg-db-2", "lat": "1.2897", "long": "103.8501", "addresses": [ "13.4.52.6" ] }, { "name": "hk-db-1", "lat": "22.3302", "long": "114.1595", "addresses": [ "10.2.4.8" ] } ]

A record for api.exmple.com api 3600 IN A 1.2.3.4

A record for api.int.example.corp api 3600 IN A 4.3.2.1

ShreyasZare commented 4 months ago

Correct me if I misunderstood your recommendation below, I am a bit lost when you explain the catch all entry for the geo distance app

If the public keyword works for your scenario then you can use it. The public entry will match with any public IPv4/6 address. The 0.0.0.0/0 entry will match with any IPv4 address.

The setup for the Split Horizon APP record will depend on how you want the client request to be routed. Since you have wireguard VPN setup, you have to configure it based on your topology to serve the closest IP to the client.

The Geo Distance app will purely work based on the IP location database and there is no configuration possible to change how it works.

Tivin-i commented 4 months ago

Yea, I figured that when trying to mess with the mmdb file. For now it seems that geolocation would serve the first entry of the file when it is a private IP, hence wanted to post this feature request to manually be able to adjust a private IP to geolocation

ShreyasZare commented 4 months ago

Geo location database is something that cannot be customized since it needs to be updated frequently to keep up with changes.

Tivin-i commented 4 months ago

So I have this thought. Is it possible to have processing done before geo distance app? Such as mapping private IPs/ranges to public ones?

ShreyasZare commented 4 months ago

So I have this thought. Is it possible to have processing done before geo distance app? Such as mapping private IPs/ranges to public ones?

You can have multiple features in same app but it will just make it difficult to configure and use since it will be very specific to your use-case and not something generalized. Which is why the different features are split up into different apps and you can combine those to use as per your scenario with CNAME.

Tivin-i commented 4 months ago

Yea, I completely get it. is there some documentation of the order apps are executed in?

Get Outlook for iOShttps://aka.ms/o0ukef


From: Shreyas Zare @.> Sent: Sunday, February 25, 2024 4:04:48 PM To: TechnitiumSoftware/DnsServer @.> Cc: Tivin @.>; Author @.> Subject: Re: [TechnitiumSoftware/DnsServer] [Feature request] Allow manual override/additions to Geo Distance app (Issue #867)

So I have this thought. Is it possible to have processing done before geo distance app? Such as mapping private IPs/ranges to public ones?

You can have multiple features in same app but it will just make it difficult to configure and use since it will be very specific to your use-case and not something generalized. Which is why the different features are split up into different apps and you can combine those to use as per your scenario with CNAME.

— Reply to this email directly, view it on GitHubhttps://github.com/TechnitiumSoftware/DnsServer/issues/867#issuecomment-1962849745, or unsubscribehttps://github.com/notifications/unsubscribe-auth/AMXAROER2J6OZ2NVJVYDPPLYVLWCBAVCNFSM6AAAAABDMIECQ2VHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTSNRSHA2DSNZUGU. You are receiving this because you authored the thread.Message ID: @.***>

ShreyasZare commented 4 months ago

Yea, I completely get it. is there some documentation of the order apps are executed in?

The order depends on how you chain your CNAME APP records. If you create Geo Distance APP record that returns CNAME for Split Horizon APP record then the order will be first Geo Distance and then Split Horizon.

Tivin-i commented 4 months ago

Understood. Thank you!

Get Outlook for iOShttps://aka.ms/o0ukef


From: Shreyas Zare @.> Sent: Sunday, February 25, 2024 8:17:16 PM To: TechnitiumSoftware/DnsServer @.> Cc: Tivin @.>; Author @.> Subject: Re: [TechnitiumSoftware/DnsServer] [Feature request] Allow manual override/additions to Geo Distance app (Issue #867)

Yea, I completely get it. is there some documentation of the order apps are executed in?

The order depends on how you chain your CNAME APP records. If you create Geo Distance APP record that returns CNAME for Split Horizon APP record then the order will be first Geo Distance and then Split Horizon.

— Reply to this email directly, view it on GitHubhttps://github.com/TechnitiumSoftware/DnsServer/issues/867#issuecomment-1962917519, or unsubscribehttps://github.com/notifications/unsubscribe-auth/AMXAROGKHAE7ZBBCOJLK3KDYVMTUZAVCNFSM6AAAAABDMIECQ2VHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTSNRSHEYTONJRHE. You are receiving this because you authored the thread.Message ID: @.***>