I broke out this from my WG topic, as WG part is resolved.
Basically, I have site-to-site Wireguard link that works fine.
Link is between Site A (192.168.0.x) and site B (192.168.1.x). Right now, traffic is open in both directions.
I would like to create a traffic rule that allows site A to create a session to site B (basically , site A to ping IP's in site B) but not other way around.
P.S.
Creating a zone for whole WG interface was proposed, but my WG server has multiple peers with different needs so I would prefer to solve this with traffic rules, if possible.
It is necessary to have separate zones to do any meaningful firewalling. If most peers are allowed to forward, you could have a forwarding which will be the default, and rules to deny certain peers based on their src_ip. (Unlike most IP based firewalling) this is secure against a peer attempting to elevate access by changing its IP, since then it would not be in the wireguard allowed_ips and Wireguard would block everything from the peer.
If you do this approach, the deny rules must be listed first in the file above the config forwarding. Firewall rules are checked in order and the first one to match is the final decision.
OK, understood. If I move whole WG interface to separate zone, can I still do fine grained config on different WG peers? (I have 4 peers, using 10.0.0.2,3,4,5 in WG)
The Wireguard config would not change. The firewall would act on packets from the inward facing wgX interface after they have been decrypted and left Wireguard.
Yes, but better just duplicate the (same) rule on Router A. This way, the traffic will originally be stopped on router B (and will not pass through the tunnel at all), but in case of intrusion, it will be stopped by router A.
Thank you for your help. I am almost there! Adding the rule to Router B (cottage) did indeed stop traffic from B to A.
But when I duplicated the rule to Router A and tried to test it (by only aving it enabled on router B) it did not not stop the traffic. (I double-checked and restarted the firewall as well). Any hint on what I am doing wrong?
Of course you have to reverse the sense of src and dest when implementing a rule on the other end of the link, and be sure to put your block rule above the default allow all forwards. (Or if you are writing it as an allow rule, the default needs to be to block).
This is on router A, right?
There are hits on the rule, so some traffic has definitely been rejected.
If the rule on Router A doesn't work as expected, I have only one explanation; The wireguard interface on Router B is assigned to a firewall zone where masquerading is enabled, so Router A sees this traffic originating from Router B's wireguard IP address.
I can access any IP on LAN A (192.168.0.x) from any IP on LAN B (192.168.1.x) despite having this rule on LAN A router:
config rule
option name 'Block-B-to-A'
option src '*'
option dest '*'
option src_ip '192.168.1.0/24'
option dest_ip '192.168.0.0/24'
list proto 'all'
option target 'REJECT'
Only way to block B to A traffic is to enable this rule on router B. That is fine, but there is a potential security risk with having client device deciding what is allowed and what is not allowed.
Basically, I would like to prohibit one of four WG peers (which is using 10.0.5.5 to connect LAN A to B) from accessing LAN A.
When I enable rule on router A, devices on network B cannot ping devices on network A except router A. Also, if I ping A from router B shell everything is still open/pingable.
Basically everything behaves as it should, except router A (only) is still pingable from B unless rule is enabled on both A and B.