# DNS Forwarding+upstream Proxy

**URL:** <https://community.ipfire.org/t/dns-forwarding-upstream-proxy/13099>\
**Category:** DNS\
**Created:** [28 October 2024 08:50 UTC](https://community.ipfire.org/t/dns-forwarding-upstream-proxy/13099 "2024-10-28T08:50:07Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![mumpitz](https://community.ipfire.org/user_avatar/community.ipfire.org/mumpitz/32/15450_2.png) [@mumpitz](https://community.ipfire.org/u/mumpitz)\
**Post date:** [28 October 2024 08:50 UTC](https://community.ipfire.org/t/dns-forwarding-upstream-proxy/13099/1 "2024-10-28T08:50:07Z")

</div>

Hello,

I run Ipfire in recursor mode for DNS.

The affected machine goes through the Squid proxy to the Internet. Squid is configured with an upstream proxy.  
I use the firewall rule from the docs [Redirecting Services](https://www.ipfire.org/docs/configuration/firewall/rules/redirect-services) to redirect all DNS query to Ipfire.

First I observed a DNS leak by the recursor mode (but even using a DNS Server) plus the DNS server upstream Proxy, but second one is not that serious. Without the DNS forwarding activated.

Is it possible to use the DNS forward option with upstream Proxy for internet domains without DNS Leaks ?  
The [doc](https://www.ipfire.org/docs/configuration/network/dnsforward) say it can also be used for Geo un-blocking services, but this would not work if a DNS Leak appears.

Second I tried to resolve certain domains via 1.1.1.1 in the DNS forwading settings, but received the following error message from unbound:

> error: SERVFAIL : all the configured stub or forward servers failed, at zone “internet domain” from 1.1.1.1 got SERVFAIL

This circumstance, that unbound outputs an error, simultaneously prevents the DNS leak of the Ipfire and by the DNS server of the upstream proxy, the page loads normally.  
This is a working solution in my case, but this is not the desired result of DNS Forwading.

Why I get this error from unbound?

Btw, i use a FireFox Browser with configured ipfire squid Proxy and activated Option “Proxy DNS when using SOCKS v5”.

---

<div class="post-metadata">

**Author:** ![bbitsch](https://community.ipfire.org/user_avatar/community.ipfire.org/bbitsch/32/7420_2.png) [@bbitsch](https://community.ipfire.org/u/bbitsch)\
**Post date:** [30 October 2024 09:02 UTC](https://community.ipfire.org/t/dns-forwarding-upstream-proxy/13099/2 "2024-10-30T09:02:34Z")

</div>

DNS forward and Squid upstream proxy are two distinct processes.  
DNS does the resolution of URLs/FQDNs to IP addresses. Forwarding just defines some additional servers for distinct local devices.  
Squid proxies the web access ( HTTP/HTTPS ), a part of the data traffic. Usually the destination is resolved yet to an IP. The upstream proxy just adds another proxy instance in the access path to a web server.

Could you elaborate your settings, please.

---

<div class="post-metadata">

**Author:** ![mumpitz](https://community.ipfire.org/user_avatar/community.ipfire.org/mumpitz/32/15450_2.png) [@mumpitz](https://community.ipfire.org/u/mumpitz)\
**Post date:** [30 October 2024 23:44 UTC](https://community.ipfire.org/t/dns-forwarding-upstream-proxy/13099/3 "2024-10-30T23:44:26Z")

</div>

> [@bbitsch](#):
>
> Could you elaborate your settings, please.

As I understand the instructions for DNS forwarding, you can use a separate DNS server for certain target addresses (FQDN) than the one distributed via the DHCP.

This is going to get wild, but without knowing the context, the error cannot be narrowed down to that extent.

Let’s leave the upstream proy out of the equation for now, but you can use it to prove that the routing is basically working.

Ipfire runs in forward block mode. Whitelist

DNS:  
The Ipfire with unbound runs with the recursor mode and is the DNS server for all clients, all requests on port 53 are redirected to the ipfire using a firewall rule.  
DNS requests from IPfire in TLS mode and striker Qname.  
However, the problem also occurs when I select a DNS server. e.g. 5.9.164.112 (Digitalcourage)

DNS Forwarding:  
I use “[ipleak.net](http://ipleak.net)” and “[browerleaks.com](http://browerleaks.com)” as the destination address (FQDN) and for the DNS server “1.1.1.1”.

Client 1 is restricted with the Windows Firewall, which only allows two connections to the outside, a VPN exit whose port in the IPfire is only released to certain fixed IP addresses and access to the IPfire itself.  
In multi-tab mode, the Firefox browser of client 1 has the option of specifying a separate proxy server for each group. Group 1 uses the Squid proxy of the Ipfire.  
The DNS via Socks5 option in the proxy settings must be activated. I will also explain why.

Let’s assume I deactivate the DNS forwarding option and call the domain [ipleak.net](http://ipleak.net).  
This provides me with my IP and the same IP as DNS because Ipfire itself is the DNS server.

If I now activate DNS Forwarding, I expect that my IP is still displayed, but the DNS server is 1.1.1.1 or one of cloudflare’s DNS servers.  
Instead, Firefox can’t find the address and I get the error message in the unbound log mentioned in the initial post.  
Under connections I also see Ipfire trying to connect on port 53 with 1.1.1.1.  
I do not get an entry in the log that this call is blocked.

So where is the error?

How do I use this error and what does the upstream proxy enable?

If I now switch an upstream proxy in front of the Squid and deactivate DNS forwarding, call [ipleak.net](http://ipleak.net) again, the so-called DNS leak occurs.  
I am shown the IP of the upstream proxy and the corresponding DNS server plus the IP of the Ipfire. That’s not what I wanted.

If I now activate DNS Forwarding, unbound generates the same error message again BUT the page can be accessed and the IP of the IPfire has disappeared.  
It only recognizes the IP of the UPstream proxy and its DNS server.

Actually it would have been enough for me that the IP of the Ipfire disappears as DNS and 1.1.1.1 is displayed.  
Due to the errors in unbound I played around a bit and got the same result even without recursor mode.

Why does the DNS over Socks Proxy option have to be activated for this? The Firefox APi unfortunately has the strange habit of sending a DNS query to everything and everyone else, which then ensures that all DNS servers used are displayed, including those of the VPN connection from Windows or those of the other socks proxy connections that are defined in multitab mode.

So why I get this unbound errors with DNS Forwarding?

P.s. Same results with [browserleaks.com](http://browserleaks.com), but [dnsleaktest.com](http://dnsleaktest.com) or dnstools.check do not show the DNS leaks so not recommend for this tests.

---

<div class="post-metadata">

**Author:** ![mumpitz](https://community.ipfire.org/user_avatar/community.ipfire.org/mumpitz/32/15450_2.png) [@mumpitz](https://community.ipfire.org/u/mumpitz)\
**Post date:** [1 November 2024 14:23 UTC](https://community.ipfire.org/t/dns-forwarding-upstream-proxy/13099/4 "2024-11-01T14:23:52Z")

</div>

Here are a few more results from the console of the Ipfire, which show that DNS forward should work in principle, but it just doesn’t work as described.  
With DNS forwarding activated, I cannot access the address with the default DNS, but there is no automatic redirection either.  
However, if I use the entered address manually, I get a response even with DNSSEC support.

> cat /etc/resolv.conf  
> search localdomain  
> nameserver 127.0.0.1  
> options edns0 trust-ad

> host [google.com](http://google.com)  
> [google.com](http://google.com) has address 216.58.206.78  
> [google.com](http://google.com) has IPv6 address 2a00:1450:4001:81d::200e  
> [google.com](http://google.com) mail is handled by 10 [smtp.google.com](http://smtp.google.com)

With DNS forwarding activated

> host [ipleak.net](http://ipleak.net)  
> Host [ipleak.net](http://ipleak.net) not found: 2(SERVFAIL)

With DNS forwarding disabled

> host [ipleak.net](http://ipleak.net)  
> [ipleak.net](http://ipleak.net) has address 95.85.16.212  
> [ipleak.net](http://ipleak.net) has IPv6 address 2a03:b0c0:0:1010::509:d001  
> [ipleak.net](http://ipleak.net) mail is handled by 10 [mx.airvpn.org](http://mx.airvpn.org).

With DNS forwarding activated

> host [ipleak.net](http://ipleak.net) 1.1.1.1  
> Using domain server:  
> Name: 1.1.1.1  
> Address: 1.1.1.1#53  
> Aliases:  
> [ipleak.net](http://ipleak.net) has address 95.85.16.212  
> [ipleak.net](http://ipleak.net) has IPv6 address 2a03:b0c0:0:1010::509:d001  
> [ipleak.net](http://ipleak.net) mail is handled by 10 [mx.airvpn.org](http://mx.airvpn.org).

> dig [google.com](http://google.com) +dnssec +short @192.168.1.1  
> 216.58.206.78  
> dig [google.com](http://google.com) +dnssec +short @1.1.1.1  
> ;; communications error to 1.1.1.1#53: timed out  
> 216.58.212.142

With DNS forwarding disabled

> dig [google.com](http://google.com) +dnssec +short @1.1.1.1  
> 216.58.206.46

> dig [ipleak.net](http://ipleak.net) +dnssec +short @1.1.1.1  
> 95.85.16.212

With DNS forwarding activated

> dig [ipleak.net](http://ipleak.net) +dnssec @1.1.1.1  
> ; \<\<\>\> DiG 9.20.1 \<\<\>\> [ipleak.net](http://ipleak.net) +dnssec @1.1.1.1  
> ;; global options: +cmd  
> ;; Got answer:  
> ;; -\>\>HEADER\<\<- opcode: QUERY, status: NOERROR, id: 63674  
> ;; flags: qr rd ra; QUERY: 1, ANSWER: 1, AUTHORITY: 0, ADDITIONAL: 1
> 
> ;; OPT PSEUDOSECTION:  
> ; EDNS: version: 0, flags: do; udp: 1232  
> ;; QUESTION SECTION:  
> ;[ipleak.net](http://ipleak.net). IN A
> 
> ;; ANSWER SECTION:  
> [ipleak.net](http://ipleak.net). 86400 IN A 95.85.16.212
> 
> ;; Query time: 48 msec  
> ;; SERVER: 1.1.1.1#53(1.1.1.1) (UDP)  
> ;; WHEN: Fri Nov 01 15:14:34 CET 2024  
> ;; MSG SIZE rcvd: 55

> dig [ipleak.net](http://ipleak.net) +dnssec
> 
> ; \<\<\>\> DiG 9.20.1 \<\<\>\> [ipleak.net](http://ipleak.net) +dnssec  
> ;; global options: +cmd  
> ;; Got answer:  
> ;; -\>\>HEADER\<\<- opcode: QUERY, status: SERVFAIL, id: 11845  
> ;; flags: qr rd ra; QUERY: 1, ANSWER: 0, AUTHORITY: 0, ADDITIONAL: 1
> 
> ;; OPT PSEUDOSECTION:  
> ; EDNS: version: 0, flags: do; udp: 1232  
> ;; QUESTION SECTION:  
> ;[ipleak.net](http://ipleak.net). IN A
> 
> ;; Query time: 113 msec  
> ;; SERVER: 127.0.0.1#53(127.0.0.1) (UDP)  
> ;; WHEN: Fri Nov 01 15:18:12 CET 2024  
> ;; MSG SIZE rcvd: 39

---

<div class="post-metadata">

**Author:** ![mumpitz](https://community.ipfire.org/user_avatar/community.ipfire.org/mumpitz/32/15450_2.png) [@mumpitz](https://community.ipfire.org/u/mumpitz)\
**Post date:** [10 November 2024 14:39 UTC](https://community.ipfire.org/t/dns-forwarding-upstream-proxy/13099/5 "2024-11-10T14:39:24Z")

</div>

The solution I have found so far protects me from an unnecessary DNS leak from my ISP. I have changed two things, I have moved away from recursor mode and use a different DNS server, the Quad9 servers are now entered in Ipfire.  
Funnily enough, this is practically also a system-wide DNS forward, except that no errors are shown in the log, I suspect the first DNS server generates errors during DNSSEC verification.  
But why a fallback and thus a DNS leak occurs in the interaction of Recursor mode and DNS Forward, I unfortunately cannot answer and would call it a bug, since geo-localization would not work with this behavior.

---

<div class="post-metadata">

**Author:** ![mumpitz](https://community.ipfire.org/user_avatar/community.ipfire.org/mumpitz/32/15450_2.png) [@mumpitz](https://community.ipfire.org/u/mumpitz)\
**Post date:** [28 November 2024 12:03 UTC](https://community.ipfire.org/t/dns-forwarding-upstream-proxy/13099/6 "2024-11-28T12:03:13Z")

</div>

@bbitsch

leaving aside the topic described above for the moment.  
These are my settings for unbound and the upstream proxy.

 ![Screenshot (1036)](https://community.ipfire.org/uploads/default/original/2X/b/b88778cacaab52c007cb055628bc26cff8dd7da6.png)

 ![Screenshot (1037)](https://community.ipfire.org/uploads/default/original/2X/8/8ed8b7defcb4c31c8de44f63e9b8af711bac884b.png)

 ![Screenshot (1038)](https://community.ipfire.org/uploads/default/original/2X/6/64d2a992727d5a156cc6e87b6c55f7351afde956.png)

The DNS of the upstream proxy has the same IP as the proxy.  
The validation errors in the log only appear when the upstream proxy is running; otherwise, only the block message appears.

> [@I created a test version of a RPZ add-on and I am looking for feedback](https://community.ipfire.org/t/i-created-a-test-version-of-a-rpz-add-on-and-i-am-looking-for-feedback/11934/218):
>
> EDIT: I’ve put [cisco.com](http://cisco.com) in RPZ’s blocklist. If I do a HTTP request I get 4 block messages ( one for my PC; 3 for 127.0.0.1, the proxy I suppose ) in the first access, each further try produces 2 messages.

my browser is forced to use the Ipfire Proxy, so i get no block messages for.  
The address 127.0.0.1 is shown under connections, but nothing will block here.
