Is it possible to limit output bandwidth between eth0 and lo?

I’m trying to limit the bandwidth between my eth0 output (nginx proxy) to my loopback inteface (apache) by filtering on destination port.

Incoming Packet -> Eth0 -> 0.0.0.0:80 Nginx -> tc qdisc class/iptable mangle 2525port -> 127.0.0.1:2525 Apache

I don’t know if it’s even possible I’m just experimenting.

My rules are the followings :

tc qdisc add dev eth0 root handle 1:0 htb
tc class add dev eth0 parent 1:0 classid 1:10 htb rate 2mbps ceil 2mbps prio 0
tc filter add dev eth0 parent 1:0 prio 0 protocol ip handle 10 fw flowid 1:10

iptables -A OUTPUT -t mangle -p tcp --dport 2525 -j MARK --set-mark 10

I also tried to with FORWARD chain but its still the same.

Answer

As Andrew mentionned I was wrong by thinking that I should filter the eth0. As soon as I changed the configuration to loopback instead of eth0 everything worked fine.

Attribution
Source : Link , Question Author : Arka , Answer Author : Arka

Leave a Comment