OPNsense Forum

English Forums => Web Proxy Filtering and Caching => Topic started by: andbaum on January 22, 2019, 10:23:50 AM

Title: Transparent Proxy with IPv6
Post by: andbaum on January 22, 2019, 10:23:50 AM
I'm trying to implement a transparent squid proxy with OPNSense. In IPv4 everything works, but the IPv6 way doesn't do anything. The settings seem correct to me.

My guess: Squid is IPv6 capable

cat /var/log/squid/cache.log
[...]
2019/01/22 10:00:54 kid1| Accepting NAT intercepted HTTP Socket connections at local=[::1]:3128 remote=[::] FD 14 flags=41

but IPv6 NAT redirect is not implemented in BSD (so in OPNSense).
I can create an IPv6 rule under "Firewall: NAT: Port Forward" but it seems to be ignored by the system. Is this correct?

Yours, Andreas
Title: Re: Transparent Proxy with IPv6
Post by: andbaum on January 28, 2019, 07:18:12 PM
No one out there having a transparent proxy with IPv6 enabled?  :-\
Title: Re: Transparent Proxy with IPv6
Post by: franco on January 30, 2019, 12:47:15 PM
This seems to be the case still: https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=203735


Cheers,
Franco
Title: Re: Transparent Proxy with IPv6
Post by: andbaum on February 03, 2019, 06:22:43 PM
Really sad - update to 19.1 (BTW: cool product 8)) didn't fix it?
Does anyone know a workaround how to bring IPv6 http traffic transparent over the OPNsense squid?

Yours,

Andreas
Title: Re: Transparent Proxy with IPv6
Post by: hbc on February 28, 2019, 02:52:55 PM
Quote from: andbaum on January 22, 2019, 10:23:50 AM
but IPv6 NAT redirect is not implemented in BSD (so in OPNSense).
I can create an IPv6 rule under "Firewall: NAT: Port Forward" but it seems to be ignored by the system. Is this correct?


you mean this rule is ignored? :o

rdr on lagg0_vlanXXXX inet6 proto tcp from (InterceptNets:network) port 1024:65535 to any port = http -> <Host_localhost> port 3128 round-robin


That would explain why there are just ipv4 source addresses in squids access.log  ::) Either rule is ignored or there are no clients that use direct ipv6 web traffic because of using wpad.dat proxy configs.

I will have to tcpdump and have a look.

Update: I dumped 90mins and there was very little ipv6 http traffic, but it failed. Just SYN was logged. That is correct, because since I thought port 80 was directed transparently through proxy, there is no firewall rule to pass ipv6:80.

Keen to know how to use transparent IPv6 proxy.

See https://github.com/opnsense/core/issues/1784

Continuing to talk to myself:

I found https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=193568

There is this comment:
Quote
Your PF rule redirects a packet to ::1, but doesn't change the receiving interface.  Thus, it violates scoping rules.  You can tell by running 'netstat -s -f inet6 | grep "violated scope"' before and after generating the traffic that you want to redirect.  The check is in in6_setscope().

The simple workaround is to change your rdr rule to redirect to your actual link-local, site-local, or global IPv6 address instead of ::1.

Will try to redirect to receiving interface instead local
Title: Re: Transparent Proxy with IPv6
Post by: hbc on March 01, 2019, 10:32:18 AM
Update:
Success. Hurray  8) It is really this scope thing. But it seems I possibly also found a little bug (at least if you are not running HA CARP).

Since I could not use ::1 for ip6 redirects (the scope thing), I had to use the local ip6 address of the interface. But while squid binds to all ip4 addresses for activated interfaces (like expected), it does NOT bind to its corresponding  ip6 addresses unless you configured an ip6 CARP address.

So in a CARP world everything is ok, because the redirect rule for transparent proxy should use the CARP ip due to rule sync. In a standalone scenario maybe you would have to define an IP alias and redirect to its ip6 or developers have to fix OPNsense to add all ip6 addresses for listening (maybde the better way. Why just listen on ip4 on dual stack system?).

Well, this was the positive news. The ip6 redirect worked BUT I get an error in squid about malformed URL.
But sometime its good to write about things, because when writing these lines I think I got an idea. The local ip ::1 is configured for intercept, the CARP ip6 which I used instead not.

So as next step I will make a manual change to squid config and add the 'intercept' option and hope that requests are processed right. ATM I get TAG_NONE/400 when doing ip6 transparent redirect.

Final result:
Transparent ip6 proxy works if:


So except for the intercept option, you can do everything from gui and which each change in web proxy configuration, you manually have to set 'intercept' or you patch the generating file.
Title: Re: Transparent Proxy with IPv6
Post by: BigSnicker on January 11, 2020, 06:24:39 PM
I'm trying to enable an IPv6 Transparent proxy and found this thread.

Both my original attempt to use an ::1 loopback address and this thread's suggestion to use a link-local interface doesn't seem to work.

Is this the latest and greatest on the issue?
Title: Re: Transparent Proxy with IPv6
Post by: hbc on January 14, 2020, 10:17:25 AM
What do you mean? You need an out of the box solution with gui options? Then you should create a feature request on github.

The manual way works perfect:

Of course first you have to make sure that ipv6 works. Means your clients get an ipv6 address (dhcpv6, slaac, ra), your dns returns AAAA records, etc.

Then your clients resolve dns name, get AAAA record, browser contacts ipv6 address, opnsense redirects to local squid on its interface ipv6 address, squid fetches content and returns content. Voilá.
Title: Re: Transparent Proxy with IPv6
Post by: fabian on January 14, 2020, 04:50:23 PM
I would think that it makes sense to allow that out of the box.
Title: Re: Transparent Proxy with IPv6
Post by: BigSnicker on January 14, 2020, 07:46:22 PM
My IPv6 works fine (in fact, as someone moving over from pfsense, it was easier to configure and seems to acquire ipv6 addresses more reliably than pfsense).

I'll go through that checklist and see if I can get it working fine, but yes, as IPv6 become more ubiquitous, surely having total feature parity with IPv4 should be an objective, including the very elegant way that IPv4 transparent proxy configuration has been set-up.

One of the big differentiators I find with OPNSense vs.pfsense is that much of the management has been simplified, particularly wrt package configuration.   This would be a great way to continue investing in that OPNS way of doing things.

I'll report back after I have a few moments to try the manual approach.
Title: Re: Transparent Proxy with IPv6
Post by: hbc on January 15, 2020, 01:55:22 PM
Quote from: fabian on January 14, 2020, 04:50:23 PM
I would think that it makes sense to allow that out of the box.

Well, I added a pull request that would add the ipv6 addresses as listeners. Since not familar how to get the lan interface ipv6 address, I could not add a patch that would extend the sample forwarding rule that exists for ipv4 to ipv6, but I made a remark in my pull request. For devs it should be an easy part to extend the "transparent_proxy" template in firewall_nat_edit.php
Title: Re: Transparent Proxy with IPv6
Post by: ctr on April 18, 2020, 04:16:21 PM
If you put those statements into an include dir it also survives a reconfig in the GUI.
I'm using /usr/local/etc/squid/pre-auth/39-ipv6-bind.conf
Title: Re: Transparent Proxy with IPv6
Post by: tokade on September 28, 2020, 08:07:37 PM
Hi all,

thanks to this thread I could get my transparent proxy work with IPv6.

Only two things still give me some question marks:

Any suggestions what is wrong or what other parameters I can set?

Kind regards
Torsten