limit bandwidth incoming range ip

Issues related to configuring your network
oscaroxy
Posts: 26
Joined: 2014/02/05 20:18:54

limit bandwidth incoming range ip

Post by oscaroxy » 2020/08/19 09:08:59

Hi,
do exist a way in order to limit the bandwidth incoming from a range ip?
for instance 192.168.1.1 - 192.168.1.100 and 192.168.1.120 - 192.168.1.255, so 20 ip are free, and other are limited.
not the number of the connection, like work iptables:

Code: Select all

iptables -A INPUT -p tcp --dport 80 -i eth0 -m state --state NEW -m recent --set
iptables -A INPUT -p tcp --dport 80 -i eth0 -m state --state NEW -m recent --update --seconds 10 --hitcount 10 -j DROP
I found "tc" command, but it work with single ip and not with range.
thanks

User avatar
jlehtone
Posts: 3263
Joined: 2007/12/11 08:17:33
Location: Finland

Re: limit bandwidth incoming range ip

Post by jlehtone » 2020/08/19 11:13:13

From what I've read, you can't limit incoming traffic at all (except drop at firewall).

oscaroxy
Posts: 26
Joined: 2014/02/05 20:18:54

Re: limit bandwidth incoming range ip

Post by oscaroxy » 2020/08/19 12:14:38

don't exist an application installable?
thanks


oscaroxy
Posts: 26
Joined: 2014/02/05 20:18:54

Re: limit bandwidth incoming range ip

Post by oscaroxy » 2020/08/19 16:02:58

can you give me the list of command?
not for a single ip, but for a range of ip, like my instance.
thanks a lot

BShT
Posts: 382
Joined: 2019/10/09 12:31:40

Re: limit bandwidth incoming range ip

Post by BShT » 2020/08/19 17:09:18

traffic shaping is an advanced network configuration, the better you can do is to read the manual and understand what you are doing

BShT
Posts: 382
Joined: 2019/10/09 12:31:40

Re: limit bandwidth incoming range ip

Post by BShT » 2020/08/19 17:11:08

but if you really want a fast food...


https://www.tldp.org/HOWTO/Adv-Routing- ... ingle.html

oscaroxy
Posts: 26
Joined: 2014/02/05 20:18:54

Re: limit bandwidth incoming range ip

Post by oscaroxy » 2020/08/19 18:01:01

the solution fast food is the solution I found, but that is for one IP and not for a range of IP, can you help me?
thanks

BShT
Posts: 382
Joined: 2019/10/09 12:31:40

Re: limit bandwidth incoming range ip

Post by BShT » 2020/08/19 18:33:10

tc filter add dev eth1 protocol ip parent 1:0 prio 1 handle 6 fw flowid 1:1

ipset create shaping hash:net

populate shaping with your IPs:

IPs=IPs.txt

for IPS in $(cat ${IPs} | egrep -v "^#"); do
ipset -A shaping ${IPS}

done

then:

iptables -A PREROUTING -t mangle -m set --match-set shaping src -j MARK --set-mark 6


NOT TESTED!!!

oscaroxy
Posts: 26
Joined: 2014/02/05 20:18:54

Re: limit bandwidth incoming range ip

Post by oscaroxy » 2020/08/20 07:08:40

mmmmmh, not easy for me, can you explain, please?

Post Reply

Return to “CentOS 7 - Networking Support”