Hi, I’m trying to setup Mangle rules for Linksys PAP2T so I can prioritise it in Queue Tree. I am trying to get Mangle
to detect the PAP2T’s traffic by IP address but it only seems to detect the outgoing traffic and not incoming traffic. I’m using ROS 5.5 on RB750GL, please help.
Please post the output of “/ip address print detail”, “/ip route print detail”, “/interface print”, “/ip firewall export”, and an accurate network diagram.
/ip route print detail
Flags: X - disabled, A - active, D - dynamic,
C - connect, S - static, r - rip, b - bgp, o - ospf, m - mme,
B - blackhole, U - unreachable, P - prohibit
0 A S dst-address=0.0.0.0/0 gateway=192.168.254.1
gateway-status=192.168.254.1 reachable eth1-WAN distance=1 scope=30
target-scope=10
1 ADC dst-address=192.168.2.0/24 pref-src=192.168.2.1 gateway=eth4-LAN
gateway-status=eth4-LAN reachable distance=0 scope=10
2 ADC dst-address=192.168.3.0/24 pref-src=192.168.3.254 gateway=eth3-farm
gateway-status=eth3-farm reachable distance=0 scope=10
3 ADC dst-address=192.168.253.0/24 pref-src=192.168.253.254
gateway=eth2-backup gateway-status=eth2-backup reachable distance=0
scope=10
4 ADC dst-address=192.168.254.0/24 pref-src=192.168.254.254 gateway=eth1-WAN
gateway-status=eth1-WAN reachable distance=0 scope=10
/interface print
Flags: D - dynamic, X - disabled, R - running, S - slave
# NAME TYPE MTU L2MTU MAX-L2MTU
0 R eth1-WAN ether 1500 1598 4074
1 R eth2-backup ether 1500 1598 4074
2 R eth3-farm ether 1500 1598 4074
3 R eth4-LAN ether 1500 1598 4074
4 R eth5-LAN ether 1500 1598 4074
I am trying to get Mangle to detect the PAP2T’s traffic by IP address but it only seems to detect the outgoing traffic and not incoming traffic.
I don’t see any mangle attempts by IP address. How are you defining the traffic sourced from the PAP2T? If you’re going to go by IP assuming its IP is 192.168.2.100 the rules would look something like this, and would account for traffic in both directions based on connection state:
On a side note, it only makes sense to prioritize outbound traffic - there’s no point prioritizing inbound traffic because your WAN interfaces are the limiting factor. By the time the packets arrive on your WAN port it’s too late to do anything about them, you either received them or you didn’t.
You should be able to see in the screenshot, the PAP2T’s address is 192.168.2.2.
eg.
prerouting dst address=192.168.2.2 in interface=eth1-WAN
postrouting src address=192.168.2.2 out interface=eth1-WAN
Basically, can you give please an example of what is the correct way to have it?
I might want to cap the speeds on some computers with Mangle/Queue Tree in future too so I need to know the correct dst/src address setup.
These Mangle rules are really confusing me.
Thanks.
The best way to do this is the one I posted, which only takes into account one direction of traffic, and then marks the other direction based on state:
That marks all connections sourced from 192.168.2.2 with a connection mark of ‘pap2t’. This connection mark is available for investigation by the router for all packets that belong to that connection. The second rule then marks all packets with that connection mark (so all packets, both ways) with a packet mark of ‘pap2t’.
So I’ll have one packet mark counting both traffic directions, how will that work with Queue Tree?
Would it be counting download traffic in the upload queue and upload in the download queue?
Thanks.
Typically you’d either use interface queues, which only see packets leaving through an interface. That’s how you get direction.
If you’re going to use global queues you’re right, you’d remark based on direction with two marks (e.g. connection mark and in-interface, with two distinct marks for upload and download.
Something I just noticed in your earlier example, does passthrough need to be disabled on the packet mark?
This is my current setup now and seems to be working fine:
Strictly speaking, no, passthrough in this case can be left set to “yes”. However, if you’re done dealing with a packet what’s the point of processing rules further below that either - best case - don’t match so the CPU is churning for no good reason, or - worst case - do match even though you did not mean for them to match, overwriting the work done previously that you meant to get done? Best practice is to bail out when you’re done.
Edit: missed the chain question. What chain you use depends on your queue tree parent. For example, global-in happens before forward, so you’d have to mark in prerouting to use it. If you’re using interfaces you can use any chain you please as they happen after postrouting. Depending on your chain choice NAT may also come into place. In your case you’re marking the connection based on an inside local IP, so the only NAT that would come into play is source NAT. That happens after postrouting, so you can use any chain for marking that you like.
So there’s no general answer, it depends on the situation. In your case the chains as you have them are fine.
Yes I took a look through the wiki and the packet flow pages but sometimes they confused
me more than clarifying anything, everything seems to be working fine now.
Thanks for the help.