> ## Content Index
> Fetch the complete content index at: https://blog.alphavps.com/llms.txt
> Use this file to discover other available public pages before exploring further.

# How to Configure iptables Rate Limiting on Ubuntu 24.04 VPS
- URL: https://blog.alphavps.com/how-to-configure-iptables-rate-limiting-on-ubuntu-24-04-vps/
- Published: 2026-02-23T08:26:13.000Z
- Updated: 2026-09-08T15:18:07.000Z
- Author: Karim Buzdar
- Tags: Tutorials, Ubuntu, Security, #series-linux-firewalls

It is essential to secure your Ubuntu 24.04 Virtual Private Server (VPS) to prevent brute force attacks, port scans, botnet traffic, and other malicious activities. Iptables rate-limiting is one of the easiest and most effective security methods. It limits the number of connections or packets that an IP can send in a given timeframe. This simple method enhances Linux VPS Security by preventing repeated SSH Login attempts, blocking automated Bots, and reducing DDoS-like Spikes. 

This guide will show you how to configure Ubuntu 24.04 iptables with a clear explanation of each command. Your VPS will remain fast, stable, and secure.

## Why Use iptables Rate Limiting on Ubuntu 24.04?

Linux servers are frequently exposed to:

- SSH brute-force attacks
- Excessive connection attempts
- DDoS spikes
- Botnet login floods

These problems can be solved by using iptables' rate-limiting feature.

- Only allowing a certain number of connections each minute
- Automatically blocking abusive IP addresses
- Reduce server load
- Hardening SSH and other critical services

This is a lightweight and native firewall that provides high-quality security for any VPS.

## How to Configure iptables Rate Limiting on Ubuntu 24.04 VPS

You can configure iptables to limit the number of connections an IP is allowed to make in a certain time period on an Ubuntu VPS. This will protect your server against brute force attacks and abusive traffic. Limit SSH connections to three per minute with the "recent" module and "limit" module of iptables, and then set general rate limits on TCP, ICMP, and suspicious port scanning behavior. Save the rules permanently using iptables-persistent to ensure they are retained even after reboots. Iptables will automatically drop excessive or suspicious traffic once configured. This provides strong and lightweight security to your Ubuntu VPS.

### Step 1: Install iptables (Already Included in Ubuntu)

Ubuntu 24.04 comes with iptables already installed. To apply the rate-limit rule, you only need to make sure that iptables has been installed and is active.

```bash
sudo apt install iptables -y
```

![](https://blog.alphavps.com/content/images/2025/12/data-src-image-70c6011e-89da-405c-91ee-e150de93da0a.png)

### Step 2: Rate Limit SSH Connections

This rule limits SSH connections to three per minute per IP. This stops brute-force tools that attempt dozens of password guesses per second. If an IP exceeds the limit, iptables drops its packets, instantly stopping attacks.

```bash
sudo iptables -A INPUT -p tcp --dport 22 -m state --state NEW -m recent --set
sudo iptables -A INPUT -p tcp --dport 22 -m state --state NEW -m recent --update --seconds 60 --hitcount 3 -j DROP
```

![](https://blog.alphavps.com/content/images/2025/12/data-src-image-e0d4b0c2-694f-4b8e-9820-5a1a5b4930e2.png)

### Step 3: Add a General Connection Rate Limiting Rule

This blocks IPs making too many connections to your VPS too quickly (useful for DDoS protection). Protecting web servers, APIs, and other services that are accessible to the public by limiting connections to 25 per minute.

```bash
sudo iptables -A INPUT -m limit --limit 25/minute --limit-burst 50 -j ACCEPT
```

![](https://blog.alphavps.com/content/images/2025/12/data-src-image-083e26cd-2be3-4bc9-8bd0-5df8c736b583.png)

### Step 4: Limit ICMP (Ping) Rate

This stops ping floods, a type of DDoS attack based on ICMP. Attackers use ping flooding to consume bandwidth. By limiting ping requests, you can ensure that your VPS is responsive and prevent abuse.

```bash
sudo iptables -A INPUT -p icmp -m limit --limit 1/s --limit-burst 3 -j ACCEPT
```

![](https://blog.alphavps.com/content/images/2025/12/data-src-image-5cbafa48-cae9-41f5-af89-4cc583d7ffcc.png)

### Step 5: Protect Against Port Scanning

This rule blocks IPs that make suspicious connection attempts.Rate limiting is a way to block port scanners before they can detect services running on your VPS.

```bash
sudo iptables -A INPUT -m recent --name portscan --update --seconds 60 --hitcount 5 -j DROP
```

![](https://blog.alphavps.com/content/images/2025/12/data-src-image-b99074d0-28d6-4746-b472-672ea61b8e5c.png)

### Step 6: Save Your iptables Rules Permanently

If you have not saved the iptables rule, it will be reset when you reboot. Your rate-limiting protection will remain active even after a server restart.

```bash
sudo apt install iptables-persistent -y
```

![](https://blog.alphavps.com/content/images/2025/12/data-src-image-3c4e54e0-5a77-438d-9b6c-30df1c6bc0fe.png)

After that, save the current IP states:

![](https://blog.alphavps.com/content/images/2025/12/data-src-image-1049e1e5-8858-4373-bd6b-88c6de23d755.png)

Save and Reload the states:

```bash
sudo netfilter-persistent save
sudo netfilter-persistent reload
```

![](https://blog.alphavps.com/content/images/2025/12/data-src-image-4b09575d-1752-432c-a36c-8c1bdae49741.png)

### Step 7: Verify Your Current Rate-Limiting Rules

By checking your rules, you can ensure that all rate-limit filters are working as expected and have been correctly applied.

```bash
sudo iptables -L -v
```

![](https://blog.alphavps.com/content/images/2025/12/data-src-image-ed08083c-2ea1-4b12-9b86-44a0765eacf2.png)

### Step 8: Test Rate Limiting

Test SSH login attempts, or run a Connection Flood from another machine. If you exceed the limit, the VPS should drop your connections, confirming that iptables rate limiting is active and protecting your server.

```bash
ssh user@server_ip_address
```

![](https://blog.alphavps.com/content/images/2025/12/data-src-image-994426d9-53cf-4ccb-ba6f-9015075711a3.png)

## Best Practices for iptables Rate Limiting on Ubuntu VPS

- Use SSH key authentication for stronger security
- Reduce noise by changing SSH ports
- Fail2Ban and rate-limiting can be combined
- Set limits that are not too high to avoid blocking legitimate users
- Save your changes after you make them.

## Conclusion

Configuring iptables for rate-limiting on Ubuntu VPS 24.04 is the easiest yet most powerful way to protect your server against brute force attacks, port scanning, and abusive traffic. You can improve server performance and security by using a few firewall settings. Iptables rate-limiting is a crucial security measure that will keep your Linux VPS stable and safe, whether you are running a cloud server, web server, or development environment.

Ready to power your projects with speed and reliability—without breaking the bank? Our [**Cheap VPS**](https://alphavps.com/cheap-vps.html?ref=blog.alphavps.com)solution delivers the performance, stability, and flexibility every developer needs.