I’m trying to make a (simple?) config. RB has 1 uplink port, and has 3 private ports with separated ip subnets.
I have to make a masquerading router to internet, which proiritizes the upload and download between the 3 subnets. I googled a lot, but could not find any solution for this.
The common problem with installing the solutions found on internet to my setup is: all example uses one ethernet interface as main parent for download, but I have 3 interfaces, where the donwload traffic can exit my router.
You will need to use a master parent queue whose parent is “global” and then a sub-queue for each LAN in question.
You’ll need to use packet marks to distinguish the traffic for the sub queues - and this marking should probably be done in the forward chain of the mangle table - because prerouting chain happens before the nat table, which makes me think that the packets will still have the WAN’s IP address as the destination address when they go through the prerouting chain (but I could be wrong).
The way to flag your connections for packet marking is going to be to use 3 connection-marking rules in the mangle->prerouting chain based on in-interface=lan1, lan2, and lan3
(also include a criteria that connection-mark=no-mark so that once a connection is flagged, it stays flagged)
Then after those 3 rules, add 3 more rules that do mark-packet based on the connection marks:
in-interface=wan connection-mark=lan1 action=mark-packet new-packet-mark=lan1down passthrough=no
And for upstream marking, add 3 packet mark rules to the post-routing chain:
out-interface=wan connection-mark=lan1 action=mark-packet new-packet-mark=lan1up
You can then make an upstream queue tree parented to the wan interface where the three lan sub-queues are looking for the upstream packet marks.
I fighting with same problem
On internet is a lot of examples but usually based on 5.x ROS code with is incompatibile with 6.x code.
Second problem is that even on 6.x code there where some changes (like global-in dissapered and now is just global and so on).
At the moment i use PCQ with equall bandwitch for every user IP using just one queue:
/queue simple print
Flags: X - disabled, I - invalid, D - dynamic
0 name=“queue3” target=192.168.0.0/16 parent=none packet-marks=“” priority=8/8
queue=pcq-upload-default/pcq-download-default limit-at=0/0 max-limit=49M/49M burst-limit=0/0 burst-threshold=0/0
burst-time=0s/0s bucket-size=0.1/0.1
Few control question:
do You use bridging?
do You use masquarade or SNAT?
According to my knoweladge this are important things.
ZeroBytes - If I use SNAT should I mark on prerouting (upload) and post-routing (dwonload)?
I’d say prerouting is usually the go-to chain for mangle in my experience.
Now that I’ve read back over my earlier post, I’d say that the IP address doesn’t matter because if marking packets based on connection mark, you can just do that in prerouting all the time in basic cases - I suggested 3 packet mark rules in postrouting so that at this point, the output interface is known and the packets can be re-marked with the “upstream” marks based on the connection mark. (the connection mark is the same for both directions in the flow)
The NAT isn’t really important in this case - once a connection gets marked, it stays marked until the connection is closed or times out, so the IP is irrelevant. The connection mark can happen in prerouting because we know that no new connections from the WAN are possible, so we know that a new, unmarked connection is coming in via some LAN interface - and this can be used to mark the flow as lan1, lan2, etc…
I see in Connection mark tab a lol session with empty name or (unknown 1) as a name - whot is going on?
In Bytes/Packet coulmns counter are increasing - so it seems that are working but why isnt mangled properly?
Prioritizing the traffic does not work. It dropps whole connections on LAN1 at the moment when a device on LAN2 begins to transmit (testing with speedtest.net)
about upload:
lan1 drop because your lan2 has high priority.
another: where is limit and max-limit for lan3?
if your upload max-limit is 5M, then sum of all tree lan’s limit need to be equal to 5M. try in this way, and without different priority.
exactly same case in downloads.
change and test again)
LAN3 is not set yet, because I’m testing it with two clients.
Again: I don’t want to set exact max-limits per subnet (I can make that with simple queues, and don’t need the queue tree).
My goal:
LAN1 lowest priority but guaranteed 2M down, 1M up
LAN2 middle priority but guaranteed 4M down, 2M up
LAN3 highest priority.
If no uses LAN2 or LAN3, the LAN1 clients can get all the bandwith.
If LAN2 users are online, than their traffic is prioritized before the LAN1 traffic, so LAN1 can get the 2M/1M and LAN2 the rest of the available.
If LAN3 user are online than they can get the bandwith what they need, but keep the guaranteed for LAN1 and LAN2.
i understand what you want, but when use priority there is no “guarantee” nothing for classes with low priority. these with high priority probably may get all bandwidth. in my opinion htb work predictable and fair if you use equal priority and set correct numbers for limit and max limit.
Equal priority, max-limit set on each subchain to the same as global max-limit, and some limit-at parameters depends on needed priority (LAN1 20Mbit, LAN2 40Mbit, LAN3 40Mbit) worked for me.