LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Desktop
User Name
Password
Linux - Desktop This forum is for the discussion of all Linux Software used in a desktop context.

Notices


Reply
  Search this Thread
Old 04-24-2023, 05:54 AM   #1
Jason.nix
Member
 
Registered: Feb 2023
Posts: 567

Rep: Reputation: 10
Post The iptables rules and Internet speed


Hello,
I use the following iptables rules and I want to know can it reduce my Internet speed:
Code:
iptables -P INPUT DROP
iptables -P OUTPUT ACCEPT
iptables -P FORWARD DROP
iptables -A INPUT -m state --state ESTABLISHED,RELATED -j ACCEPT
iptables -A INPUT -i lo -j ACCEPT
iptables -A OUTPUT -o lo -j ACCEPT
iptables -N SYN_FLOOD
iptables -A INPUT -p tcp --syn -j SYN_FLOOD
iptables -A SYN_FLOOD -m limit --limit 5/s --limit-burst 10 -j RETURN
iptables -A SYN_FLOOD -j DROP
Any idea?


Thank you so much.
 
Old 04-29-2023, 07:54 AM   #2
Jason.nix
Member
 
Registered: Feb 2023
Posts: 567

Original Poster
Rep: Reputation: 10
Hello,
No idea?
 
Old 04-29-2023, 12:05 PM   #3
Jan K.
Member
 
Registered: Apr 2019
Location: Esbjerg
Distribution: Windows 7...
Posts: 773

Rep: Reputation: 489Reputation: 489Reputation: 489Reputation: 489Reputation: 489
From someone who's brain melted trying to understand anything iptables...

How about disabling it, test speed, enable, test speed?


https://kerneltalks.com/howto/how-to...l-temporarily/
 
1 members found this post helpful.
Old 04-29-2023, 12:26 PM   #4
astrogeek
Moderator
 
Registered: Oct 2008
Distribution: Slackware [64]-X.{0|1|2|37|-current} ::12<=X<=15, FreeBSD_12{.0|.1}
Posts: 6,269
Blog Entries: 24

Rep: Reputation: 4206Reputation: 4206Reputation: 4206Reputation: 4206Reputation: 4206Reputation: 4206Reputation: 4206Reputation: 4206Reputation: 4206Reputation: 4206Reputation: 4206
Quote:
Originally Posted by Jason.nix View Post
Hello,
I use the following iptables rules and I want to know can it reduce my Internet speed:
Code:
iptables -P INPUT DROP
iptables -P OUTPUT ACCEPT
iptables -P FORWARD DROP
iptables -A INPUT -m state --state ESTABLISHED,RELATED -j ACCEPT
iptables -A INPUT -i lo -j ACCEPT
iptables -A OUTPUT -o lo -j ACCEPT
iptables -N SYN_FLOOD
iptables -A INPUT -p tcp --syn -j SYN_FLOOD
iptables -A SYN_FLOOD -m limit --limit 5/s --limit-burst 10 -j RETURN
iptables -A SYN_FLOOD -j DROP
You need to define your use case and what your objective is much more clearly.

Your rules limit the number of new TCP requests which get through, but that is not equivalent to limiting "internet speed", not even close.

As your rules are applied to incoming requests I would conclude that this is for an internet exposed server of some sort, not a desktop machine. If so, these rules are inadequate for any real world purpose.

In general iptables rules cannot limit speed, that requires another tool named tc (for traffic control). See man tc for an introduction.

Last edited by astrogeek; 04-29-2023 at 12:27 PM. Reason: ptoy
 
Old 04-29-2023, 03:16 PM   #5
jefro
Moderator
 
Registered: Mar 2008
Posts: 22,011

Rep: Reputation: 3629Reputation: 3629Reputation: 3629Reputation: 3629Reputation: 3629Reputation: 3629Reputation: 3629Reputation: 3629Reputation: 3629Reputation: 3629Reputation: 3629
Kind of two things going on. One is software based filtering. Two is the amount of processing power that might be needed to enforce the rules. I can't guess that so I agree with need for testing on your use.

Generally the sales pitch for hardware based devices is that they are designed to operate closer to wire speeds.
 
Old 05-01-2023, 04:22 AM   #6
Jason.nix
Member
 
Registered: Feb 2023
Posts: 567

Original Poster
Rep: Reputation: 10
Quote:
Originally Posted by astrogeek View Post
You need to define your use case and what your objective is much more clearly.

Your rules limit the number of new TCP requests which get through, but that is not equivalent to limiting "internet speed", not even close.

As your rules are applied to incoming requests I would conclude that this is for an internet exposed server of some sort, not a desktop machine. If so, these rules are inadequate for any real world purpose.

In general iptables rules cannot limit speed, that requires another tool named tc (for traffic control). See man tc for an introduction.
Hello,
Thank you so much for your reply.
I mean downloading through the Internet.
What do you mean?
Quote:
If so, these rules are inadequate for any real world purpose.
 
Old 05-01-2023, 07:29 AM   #7
Turbocapitalist
LQ Guru
 
Registered: Apr 2005
Distribution: Linux Mint, Devuan, OpenBSD
Posts: 7,343
Blog Entries: 3

Rep: Reputation: 3744Reputation: 3744Reputation: 3744Reputation: 3744Reputation: 3744Reputation: 3744Reputation: 3744Reputation: 3744Reputation: 3744Reputation: 3744Reputation: 3744
Quote:
Originally Posted by Jason.nix View Post
I mean downloading through the Internet.
What do you mean?
Read the iptables ruleset that you posted, it won't affect a desktop system in any meaningful way. As mentioned tc is used for traffic shaping, in conjunction with either iptables or nftables. The latter is preferable, so if you are starting out, ignore iptables and focus on nftables instead.

One thing about traffic shaping rules is that they can only really affect outgoing bandwidth. Random Early Detection might be an option for influencing incoming connections but by and large traffic shaping only affects outgoing data.
 
Old 05-01-2023, 10:45 AM   #8
astrogeek
Moderator
 
Registered: Oct 2008
Distribution: Slackware [64]-X.{0|1|2|37|-current} ::12<=X<=15, FreeBSD_12{.0|.1}
Posts: 6,269
Blog Entries: 24

Rep: Reputation: 4206Reputation: 4206Reputation: 4206Reputation: 4206Reputation: 4206Reputation: 4206Reputation: 4206Reputation: 4206Reputation: 4206Reputation: 4206Reputation: 4206
Quote:
Originally Posted by Jason.nix View Post
Hello,
Thank you so much for your reply.
I mean downloading through the Internet.
What do you mean?
What I meant about the rules being inadequate was that if this were for a server (which apparently it is not) then those rules would not provide any useful level of function. For an internet facing server you would want to manage connections by protocol, port and probably other parameters.

If this is for a desktop computer, presumably behind a router, you should probably not see any NEW or SYN packets from the outside world unless you have enabled selected pass through in the router. So limiting the number of SYN packets will not really affect anything and those rules serve no useful purpose here either.

As mentioned, you can only control the speed (actually bandwidth) of outgoing traffic because the sender determines how fast incoming traffic arrives. Typically, to limit download speed from the internet you want to delay outgoing ACK packets as a function of the total number of bytes received per second. You can do this with iptables/tc, but if you simply want to limit the bandwidth of specific large downloads so as to allow other uses like web browsing to continue at the same time, perhaps using a utility which allows you to throttle bandwidth like wget would provide a simpler solution.

So the real qusetion is, what problem are you actually trying to solve?
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] /etc/udev/rules.d/40-libsane.rules and /etc/udev/rules.d/S99-2000S1.rules missing LABEL=libsane_rules_end mumahendras3 Slackware 6 03-09-2020 02:27 AM
Why the iptables rules slow down net transposrt speed? luofeiyu Linux - Networking 4 02-23-2017 02:51 AM
auditctl -l not showing any rules even though i have rules written in audit.rules alphaguy Linux - Security 1 02-07-2014 05:28 PM
iptables v1.2.9: Unknown arg `/sbin/iptables' Try `iptables -h' or 'iptables --help' Niceman2005 Linux - Security 4 12-29-2005 08:20 PM
Is there a tool to monitor Internet connection speed and also network speed? xleft4dexy Linux - Networking 4 10-14-2003 10:29 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Desktop

All times are GMT -5. The time now is 05:15 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration