Skip to content

Add dns_gateway dynamic module example#56

Open
ovadiagal wants to merge 4 commits intoenvoyproxy:mainfrom
ovadiagal:go/wildcard-oneshot
Open

Add dns_gateway dynamic module example#56
ovadiagal wants to merge 4 commits intoenvoyproxy:mainfrom
ovadiagal:go/wildcard-oneshot

Conversation

@ovadiagal
Copy link

@ovadiagal ovadiagal commented Feb 4, 2026

Dynamic module approach to solving this issue: Retrieve DNS resolution results at runtime #41605

This dynamic module can be used to implement egress policies by hostname (see this blog by Cloudflare which has some good context)

diagram

In this dynamic module, you'll find:

dns_gateway/mod.rs

DNS gateway UDP listener filter. Intercepts DNS queries and returns synthetic responses for domains matching configured egress policies (exact or *. wildcard).

  • For matching A-record queries, allocates a virtual IP from the shared cache and responds with it
  • For matching non-A queries (e.g. AAAA), responds with NODATA (no IPv6 support yet)
  • For non-matching queries, passes through to the next filter

virtual_ip_cache.rs

Maintains a mapping between FQDN and virtual IPs.

  • dns_gateway calls virtual_ip_cache::allocate() to get a virtual IP for a domain (reuses existing IP if the domain was seen before)
  • cache_lookup calls virtual_ip_cache::lookup() to resolve a virtual IP back to its domain and metadata
  • IP space is bounded by the configured prefix_len; no eviction currently.

cache_lookup.rs

Network filter that runs on new TCP connections. Looks up the destination virtual IP in the shared cache and writes the resolved domain and policy metadata into Envoy filter state, making them available to downstream filters via:

  • %FILTER_STATE(envoy.dns_gateway.domain:PLAIN)%
  • %FILTER_STATE(envoy.dns_gateway.metadata.<key>:PLAIN)%

Additional details can be found in the README file in this PR

@ovadiagal ovadiagal changed the title . Add egress policy dynamic module example Feb 10, 2026
@ovadiagal ovadiagal force-pushed the go/wildcard-oneshot branch from 5401d45 to ba39360 Compare March 4, 2026 21:33
@ovadiagal ovadiagal changed the title Add egress policy dynamic module example Add dns_gateway dynamic module example Mar 4, 2026
@ovadiagal ovadiagal force-pushed the go/wildcard-oneshot branch from 4f2574e to a07a5ad Compare March 4, 2026 22:24
.
Signed-off-by: Gal Ovadia <ggalovadia@gmail.com>

.

Signed-off-by: Gal Ovadia <ggalovadia@gmail.com>

rename

Signed-off-by: Gal Ovadia <ggalovadia@gmail.com>

,

Signed-off-by: Gal Ovadia <ggalovadia@gmail.com>

work

Signed-off-by: Gal Ovadia <govadia@palantir.com>
Signed-off-by: Gal Ovadia <ggalovadia@gmail.com>

clean

Signed-off-by: Gal Ovadia <govadia@palantir.com>
Signed-off-by: Gal Ovadia <ggalovadia@gmail.com>

cleanuP

Signed-off-by: Gal Ovadia <ggalovadia@gmail.com>

update to latest sdk

Signed-off-by: Gal Ovadia <ggalovadia@gmail.com>

cleanup

Signed-off-by: Gal Ovadia <ggalovadia@gmail.com>

cleanup

Signed-off-by: Gal Ovadia <ggalovadia@gmail.com>

style match lib.rs

Signed-off-by: Gal Ovadia <ggalovadia@gmail.com>

add tests, readme,

Signed-off-by: Gal Ovadia <ggalovadia@gmail.com>

clean

Signed-off-by: Gal Ovadia <ggalovadia@gmail.com>

Update lib.rs

Signed-off-by: Gal Ovadia <ggalovadia@gmail.com>

Update README.md

Signed-off-by: Gal Ovadia <ggalovadia@gmail.com>
@ovadiagal ovadiagal force-pushed the go/wildcard-oneshot branch from 4a7b236 to 898d8d8 Compare March 4, 2026 22:33
@ovadiagal ovadiagal marked this pull request as ready for review March 4, 2026 22:35
@ovadiagal ovadiagal requested a review from mathetake as a code owner March 4, 2026 22:35
Signed-off-by: Gal Ovadia <ggalovadia@gmail.com>
Signed-off-by: Gal Ovadia <ggalovadia@gmail.com>
Signed-off-by: Gal Ovadia <ggalovadia@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant