All the child queues of a single parent queue with PCQ behaviour are created automatically and get the same treatment. The behaviour depends on the classifier which says what connections to aggregate into one child queue. If you set that classifier to client-side IP address, all connections of each client device will be handled by a single child queue; if you set it to client address and port, each individual connection will have its own child queue.
If each client gets from you several individual IP addresses, one per each end device, with a single common parent queue for all clients and a single auto-created child queue per client IP address (PCQ classifier = client IP address), then if client A has a single device connected and client B has 9, client A will get 10 % of the available bandwidth and client B will get 90 %.
the goal is to replicate a typical one circuit per apartment setup, just like it would be if each had their own connection/router.
...
Anyway, I would like to understand the src-nat method you speak of so could you possibly write in words the way to achieve this?
Below is a picture of the conventional "one circuit per apartment" case where you assign a single IP address to each client and it is their choice whether they use it for a single end device or place there a NATing router and connect as many devices as they wish to it; you can see traffic of all client devices as a traffic of that single IP address, so each such client connection gets the same share of the total bandwidth if they are treated using PCQ with local side IP address used as classifier.
multi-router setup code
internet
| provider rtr
---------------------------------
| p.p.p.23 |
| NAT |
| DHCPs |
| a.a.a.1 |
---------------------------------
| |
| client rtr C | client rtr D
------------ ------------
| a.a.a.c | | a.a.a.d |
| NAT | | NAT |
| DHCPs | | DHCPs |
| c.c.c.1 | | d.d.d.1 |
------------ ------------
| | | | | |
c.c.c.2 | c.c.c.4 d.d.d.2 | d.d.d.4
| |
c.c.c.3 d.d.d.3
I assume that in your actual setup, your router performs the functionality of the clients' routers in terms that you have created one IP subnet per client, each in its own VLAN, and you deliver the VLANs to the clients by a network of switches, where each client has got several access ports to a single VLAN as follows:
single-router multi-subnet setup code
internet
| provider rtr
---------------------------------
| p.p.p.23 |
| NAT |
| VLAN C VLAN D |
| DHCPs C DHCPs D |
| c.c.c.1 d.d.d.1 |
| trunk |
---------------------------------
||
|| client switch(es)
------------------------------------
| trunk |
| |
| .......... .......... |
| : VLAN C : : VLAN D : |
------------------------------------
| | | | | |
c.c.c.2 | c.c.c.4 d.d.d.2 | d.d.d.4
| |
c.c.c.3 d.d.d.3
So at L3, your router handles a handful of IP addresses, one per each of the clients' end devices.
The convenience of the PCQ is that the child queues are generated automatically and dynamically using the classifier. However, you can only choose from predefined values of the classifier, and the most coarse resolution step available is an IP address - you cannot say that traffic of a whole subnet of a given size should be treated as a single stream (and thus by a single child queue). So to treat all the clients' subnets equally, each by its own child queue, you have to create these child queues yourself, using the subnet address as a target (or translating it into a packet mark, I keep saying I haven't needed to dive into the queue trees yet).
The other approach to it is to translate each client's subnet to a single IP address, just like the traditional architecture does, and use PCQ on these addresses, but do that on a single router. There is no big deal in NATing every client subnet to its own IP address on a single machine; the complex part is to make the router further process the packet after it got src-nated.
virtual multi-router setup code
internet
| provider rtr
---------------------------------
| p.p.p.23 |
| NAT |
| a.a.a.1 |
? ?
? ?
? ?
| a.a.a.c a.a.a.d |
| NAT NAT |
| VLAN C VLAN D |
| DHCPs C DHCPs D |
| c.c.c.1 d.d.d.1 |
| trunk |
---------------------------------
||
|| client switch(es)
------------------------------------
| trunk |
| |
| .......... .......... |
| : VLAN C : : VLAN D : |
------------------------------------
| | | | | |
c.c.c.2 | c.c.c.4 d.d.d.2 | d.d.d.4
| |
c.c.c.3 d.d.d.3
The whole trick how to fill in the question-marked part of the picture is described in the post to which I gave a link in my previous post - you have to use an IPIP tunnel in order to create an interface through which you can send the packet "out of the router" after NATing it, because normally src-nat is only done as the packet is leaving the device, but to still be able to treat the packet further because the other end of the IPIP tunnel is another interface on the same device. So each packet from the client passes through the routing and firewall twice. In the first pass, where it comes in via the VLAN interface, you only do the "virtual client router" src-nat and route it "out" via the IPIP tunnel; in the second pass where it comes "in" via the IPIP tunnel, you do the PCQ handling with the tunnel interface as PCQ target and local side IP address as PCQ classifier, and then do the "provider router" NAT and route it out your WAN uplink.
So the whole picture then looks as follows:
virtual multi-router setup code
internet
| provider rtr
---------------------------------
| p.p.p.23 |
| NAT |
| a.a.a.1 |
| IPIP-to-client |
|...............|.................|
| IPIP-to-provider |
| a.a.a.c a.a.a.d |
| NAT NAT |
| VLAN C VLAN D |
| DHCPs C DHCPs D |
| c.c.c.1 d.d.d.1 |
| trunk |
---------------------------------
||
|| client switch(es)
------------------------------------
| trunk |
| |
| .......... .......... |
| : VLAN C : : VLAN D : |
------------------------------------
| | | | | |
c.c.c.2 | c.c.c.4 d.d.d.2 | d.d.d.4
| |
c.c.c.3 d.d.d.3
The link I gave before addresses much more than that, so it is probably repelling a bit, but for your case neither the IPsec/L2TP related information nor the script taking care of dynamic change of
to-addresses value in the
src-nat rule are relevant, so it boils down just to establishing an IPIP tunnel whose both endpoint interfaces are on the same router and a tiny bit of
in-interface based policy routing.