You can do that at both L3 (IP subnet) level, using
src-address(-list) and
dst-address(-list) in the
/ip firewall rules, and using
in-interface(-list) and
out-interface(-list) at L2 (LAN/VLAN) level, or use L2 for source and L3 for destination or vice versa.
The source (the L2TP client) can be identified by an IP address or by interface name. If you create a separate
/ip pool for each category of L2TP clients and use the name of that pool as a value of the
/ppp secret remote-address (or of
/ppp profile remote-address) for
/ppp secret of clients belonging this category, they may get dynamically assigned addresses but you can still refer to the address range matching the one used in that pool using
src-address in the rule.
Another possibility is to create a static interface name and link it to a particular
/ppp secret. This is a 1:1 mapping so you cannot assign the same static interface name to multiple users as the interfaces are tunnel ones.
So assuming you have users a1, a2 in privilege group A, user b1 in privilege group B and VLANs 10,20,30 accessible via interfaces
/interface vlan named
vlan-10,
vlan-20,
vlan-30 where privilege group A can access VLANs 10 and 30 and privilege group B can access VLANs 10 and 20, you could do it e.g. the following way:
/ip pool
add name=pg_A ranges=10.10.10.0-10.10.10.19
add name=pg_B ranges=10.10.10.20-10.10.10.39
/ppp secret
set [find name=a1] remote-address=pg_A
set [find name=a2] remote-address=pg_A
set [find name=b1] remote-address=pg_B
/interface list
add name=pg_A
add name=pg_B
/interface list member
add list=pg_A interface=vlan-10
add list=pg_A interface=vlan-30
add list=pg_B interface=vlan-10
add list=pg_B interface=vlan-20
/ip firewall filter
...
add action=accept chain=forward src-address=10.10.10.0-10.10.10.19 out-interface-list=pg_A
add action=accept chain=forward src-address=10.10.10.20-10.10.10.39 out-interface-list=pg_B
...
These firewall rules have to be placed at correct position in the chain and they assume that you have a tight firewall with "a drop everything" rule in the end of the chain preceded by rules constituting intended
action=accept exceptions from it. If you have a default hAP/hEX firewall which only filters traffic coming from WAN but lets traffic between LANs flow freely, you have to consider whether you want to invert the logic of the rules above (i.e. say "users from
pg_A must
not get to
vlan-20 whereas users from
pg-B must
not get to
vlan-30") or whether to invert the logic of the firewall from default accept to default drop.