Menu
User

DropVPS Team

Writer: Cooper Reagan

How to Limit Bandwidth Per Port or IP on Ubuntu 25.04

How to Limit Bandwidth Per Port or IP on Ubuntu 25.04

Publication Date

12/31/2025

Category

Articles

Reading Time

2 Min

Table of Contents

Limiting bandwidth per IP or port helps prevent abuse, control resource usage, and keep services stable on a VPS.

Step 1: Install Required Traffic Control Tools

Ubuntu uses the tc utility for bandwidth shaping.

sudo apt update
sudo apt install iproute2 -y

Step 2: Identify the Network Interface

Before applying limits, confirm your active network interface.

ip addr

In most VPS setups, the interface is eth0.

You may want to review this related article: How to Monitor Network Traffic on a Linux VPS

Step 3: Limit Bandwidth for a Specific IP Address

This example limits an IP to 1Mbps download speed.

sudo tc qdisc add dev eth0 root handle 1: htb default 30
sudo tc class add dev eth0 parent 1: classid 1:1 htb rate 1mbit
sudo tc filter add dev eth0 protocol ip parent 1:0 prio 1 u32 match ip dst 192.168.1.100 flowid 1:1

Replace 192.168.1.100 with the target IP address.

Step 4: Limit Bandwidth for a Specific Port

Apply a bandwidth limit to traffic targeting a specific port.

sudo tc class add dev eth0 parent 1: classid 1:2 htb rate 512kbit
sudo tc filter add dev eth0 protocol ip parent 1:0 prio 2 u32 match ip dport 3000 0xffff flowid 1:2

This is useful for limiting API services or game servers.

Step 5: Verify Active Bandwidth Limits

Check applied traffic control rules.

sudo tc -s qdisc show dev eth0
sudo tc -s class show dev eth0

Packet counters confirm that limits are working.

Step 6: Remove or Reset Bandwidth Limits

To remove all traffic shaping rules:

sudo tc qdisc del dev eth0 root

This instantly restores normal bandwidth. For better control, combine traffic shaping with firewall filtering.

Linux VPS
U
Loading...

Related Posts