166
22.1 Legacy Series / Re: how to deal with IPv6?
« on: May 24, 2022, 07:02:55 pm »
Ah, yes, of course, you're right 

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.

And that's it, in my opinion. What do you think?

But there is an alias 'WAN net'. What does that mean? Internet?
Nope. That's a common misunderstanding.
"X net" is the network directly connected to interface X. Regardless of which interface, so also for WAN. Some ISP might give you a routed /29 or /30 istead of a point to point link, so that's what "WAN net" ends up being.
It's what I thought ...I did configure something like that using interface groups. It's not great but it works.Could you post an example, please? Is there something like an "<interface group> net" object, which would sum up all the directly connected networks?
IIRC when you define an interface group, a net object like that is created and you can work with "deny from any to interface group", "allow from interface group to any" or something similar.
I don't have that setup active anymore so I can not look it up.
Op>
Have you tried making rules based on "Nets" ? Under the Source/dest in the rule you create, there should be some built in aliases named "<interface name> net". That should at least cover all devices onthat interface, even if the interface subnet changes.
So how is my argument not justified? What's your argument on this? Maybe I don't need to do what I'm trying to do.I said that your argument is justified - read the sentence again.

Ok, so what I might want isn't possible. Wouldn't it be a nice feature to have?Ironically ipfw, the "native" FreeBSD firewall has got a "via <interface>" clause for ingress and egress. But as far as I know nobody has written a polished firewall appliance product on top of it.
No problem ... I still don't understand how a rule on the LAN interface that blocks outbound traffic from the guest network could accomplish anything. Why and how would there be traffic from the guest netwok outbound on the LAN interface?Well, a machine on the guest network sends a packet to a machine on the LAN network. That packet goes in to the firewall on the guest interface and out of the firewall on the LAN interface ...
The "inbound/outbound" distinction is strictly from the firewall's point of view.An outbound rule on the LAN interface that blocks everything from <group> /would block traffic coming out of the firewall before the traffic could enter the LAN interface and go out of the LAN interface/.Exactly.
There's some confirmation in the help text when creating a rule; it says: "[Source] -> IN -> [Firewall] -> OUT -> [Destination]".
That's why I think outbound rules could simplify that a lot. Which remains to be proven, of course. I'll update this thread when I have something actually working.Try something like this.
Like when you put together a steering wheel, the wheels go underneath?
Not excatly ... For simplicity, let's assume that I have a LAN and a guest VLAN. With IPv4, the common way to set it up is to block everything to all private networks and then allow everyhing to anywhere so that devices on the guest VLAN have internet access. That nicely protects your LAN because all devices on the LAN have IP addresses within the private networks which can not be reached from the devices on the guest VLAN.This is a gross oversimplification, IMHO, because e.g. I run several setups where the "internal" networks do not use private but globally routable addresses. Yes, for IPv4 ...
With IPv6, that doesn't work because suddenly, all the devices on the LAN have not only addresses within private networks but also have public IP addresses; and your LAN is unprotected because the rule on the guest VLAN that allows everything to everywhere also allows access to the devices on your LAN and you can't reasonably block that, especially not when the IP addresses of the devices on the LAN keep chaning all the time.
But I do understand your problem. If you allow "everything" that implies the guest network can reach all other directly connected networks as well as "the Internet".
I am not arguing that your requirement is not justified -
there simply is no way in PF to specify "from this interface in only to that interface (WAN) out".
So let's turn back to your simplified example: I was suggesting that you create an outbound rule on the LAN interface that reads "block everything from guest network".
You can create group of all directly connected networks and place a "block everything from <group> outbound" on all of the networks, because there will never be traffic coming out of interface X with source address of net X. Unless it's generated by the firewall itself, but that is taken care of by the default "permit everything from the firewall itself" rule.
So the additional burden for blocking is reduced to 1 rule per interface and maintaining a group of all networks attached to all the interfaces. Not optimal but the best I could think of. I am going to test this in the coming weeks and if successful put it in production. Currently I have block rules with various destination networks spread "everywhere" and I am just as annoyed by that as you are, that's why I am also looking for a solution.
There will probably be things to consider with respect to rule order and the application of "quick", that's why I don't have an example ready for you.
HTH,
Patrick

Try something like this.
Everything you do not explicitly allow is blocked in OPNsense. But now I better understand your problem. Yes, there is no "destination interface" in pf rules. Which would be necessary to have a true zone based firewall.
But while the general advice is to filter on ingress, I think in any multi-tenant or similar scenario filtering on egress can be helpful.
So you have one or multiple separate server networks (zones) and a LAN for general use and a general "permit all" rule for the LAN. Do I get that correct?
You could use an outbound rule in the "server" interface like "deny from LAN net". That should work even with a changing "LAN net". I do not have a ready-made config yet, but I am actively exploring this route, because I did replace a zone based firewall with OPNsense and in one situation I have multiple hosting tenants that should all be able to reach "the Internet", but only reach other tenants at the same services those want accessable publicly. I think that's very similar to your requirements. And I think outbound rules might be the way to go in that case.
HTH,
Patrick
For outgoing IPv6 access, you can usually allow any -> any, so the only question is incoming IPv6 traffic.
You do not have to allow access from a "limited" VLAN to your LAN, but that is not any different from IPv4.
For incoming access, you block everything and only explicitely allow specific device via firewall aliases like I described. There is no such thing as a privacy issue here, because the key point in allowing access to a specific device is "specific" - you have to "name" it somehow:
First off, that is something completely decoupled of if that same device has another IPv6 address which it uses to access the internet from inside out - you can well use IPv6 privacy extensions for that indepedently of how it is being access from outside. Effectively, you will have to use a dynamic DNS service of one kind or the other (otherwise you cannot know the current IPv6 prefix and thus not the full IPv6 of the device in question).
Having cleared that out of the way, the only question could be if you can guess anything from the lower 64 bits of the IPv6. The answer is yes, if you use SLAAC, because the contained MAC gives away the manufacturer of the device. But as I said, you could as well use DHCPv6 with artifical addresses.
Don't use the (changing) address in the rule. Just state which applications (protocols, ports) are to be allowed and set the address to "any".
If you have different policies for particular devices, put all devices that share a common policy behind one interface for that group.
If you don't have enough interfaces, use a VLAN capable switch and VLANs.
HTH,
Patrick
The main problem people frequently face is thinking of privilege per IP address. And that does not easily carry over into the IPv6 world.
I am rather old school in my thinking about firewalls and have used products that support and encourage the use of zones or "burbs" (from suburb) as Sidewinder originally called them. So you say machines in this zone may access these services in that zone. And never use IP addresses anywhere, at least not for outbound connections. When doing reverse NAT to servers in a DMZ or similar, of course you often cannot avoid explicit addresses.
So my general recommendation is to put machines of like privileges all together in a separate VLAN and specify rules per interface which OPNsense easily facilitates. And do not worry about particular addresses too much. Rather assume that IP addresses can and will be forged. Always put untrustworthy devices behind a separate interface.
HTH,
Patrick