Linux FTP Server Traffic Control And Throttle Port 21

To control and throttle FTP traffic on a Linux FTP server, you can use the tc command from the iproute2 package. The tc command can be used to set up traffic control rules and limit the bandwidth of the FTP traffic on port 21.

Here’s an example of how you can limit the FTP traffic to 100 kbps using the tc command:

 
# First, create a traffic control class
tc class add dev eth0 parent 1: classid 1:1 htb rate 100kbps

# Add a filter to match FTP traffic on port 21
tc filter add dev eth0 protocol ip parent 1:0 prio 1 u32 match ip dport 21 0xffff flowid 1:1

In this example, the tc class add command creates a new traffic control class and sets its rate to 100 kbps. The tc filter add command then adds a filter to match FTP traffic on port 21 and applies the traffic control class to it.

Note that this example assumes that the network interface is eth0. You should replace eth0 with the name of the appropriate network interface on your system.

You can check the status of your traffic control rules with the tc command. For example:

 
tc -s class show dev eth0

This will show the status of the traffic control classes for the eth0 interface.

Leave a Comment