This guide shows you how to identify what is consuming your Linux instance’s bandwidth and how to reduce or stop it. You’ll learn to monitor live traffic, pinpoint the process or connection responsible, and apply fixes ranging from simple service restarts to firewall rules.
What You’ll Need
- Root or sudo access to your Linux instance
- SSH access (or a console session)
- Basic familiarity with the command line
- Package manager (apt, yum, dnf, etc.) to install tools if needed
Step-by-Step
- Check overall traffic with
vnstatoriftop
Install a traffic monitor if you don’t have one. On Debian/Ubuntu:sudo apt install vnstat iftop. On RHEL/CentOS:sudo yum install vnstat iftop. Runvnstat -dto see daily totals, orvnstat -mfor monthly. For a live view, runsudo iftop– you’ll see a list of connections and their transfer rates. Pressqto quit. - Identify the top bandwidth consumers with
nethogs
Install nethogs (sudo apt install nethogsorsudo yum install nethogs). Runsudo nethogsto see which processes are using the most bandwidth in real time. This is the quickest way to find a rogue process like a misconfigured backup or a compromised script. - List active connections with
ss
Usess -tupto show TCP/UDP connections with the owning process (requires root). Look for many connections to the same IP or port, or connections to unexpected remote hosts. TheStatecolumn showsESTABfor active connections; many inSYN-SENTcould indicate a scanning or flooding issue. - Check per-interface traffic with
iporcat /proc/net/dev
Runip -s linkto see RX/TX bytes and packets per interface. Compare over time to see if traffic is growing.cat /proc/net/devgives the same raw numbers. If you have multiple interfaces, this helps isolate which one is saturated. - Look for suspicious processes with
psandtop
Runtop -o %CPUto sort by CPU usage. A process using high CPU while also sending traffic is a red flag. Useps aux --sort=-%cpu | headto see the top CPU consumers. Check for unfamiliar process names or paths like/tmp/. - Inspect system logs for clues
Check/var/log/syslogor/var/log/messagesfor repeated errors, failed login attempts, or service restarts. Usejournalctl -xeon systemd systems. Look for patterns like a service crashing and restarting, which can cause repeated downloads or uploads. - Stop or restart the offending service
Once you’ve identified the process (e.g., a web server, a sync tool, or a database), restart it withsudo systemctl restart <service>. If it’s a one-off script, kill it withsudo kill <PID>. For a service you don’t need, disable it:sudo systemctl disable --now <service>. - Block unwanted traffic with firewall rules
Useufw(Ubuntu) orfirewalld(RHEL) to block specific IPs or ports. For example, to block an IP with ufw:sudo ufw deny from 203.0.113.5. To block a port:sudo ufw deny 8080. With firewalld:sudo firewall-cmd --permanent --add-rich-rule='rule family="ipv4" source address="203.0.113.5" reject'thensudo firewall-cmd --reload. - Rate-limit or throttle bandwidth if needed
For a service that must run but is using too much, usetc(traffic control) to limit its rate. For example, to limit an IP to 1Mbps:sudo tc qdisc add dev eth0 root handle 1: htb default 10and thensudo tc class add dev eth0 parent 1: classid 1:10 htb rate 1mbit. This is advanced; test carefully. - Monitor after the fix
Re-runvnstat -doriftopto confirm traffic has dropped. Keep an eye on it for a few hours to ensure the issue doesn’t return.
Common Mistakes
- Ignoring IPv6 – Traffic may be going over IPv6 while you only monitor IPv4. Use
ss -6to see IPv6 connections. - Killing the wrong process – Always verify the PID with
ps -p <PID>before killing. - Blocking your own IP – If you use a firewall rule, make sure you don’t lock yourself out. Test with a rule that allows your IP first.
- Not checking for malware – High traffic can be a sign of a compromised system. Run a rootkit checker like
rkhunterorchkrootkit. - Forgetting to save firewall rules – With
iptables, rules are lost on reboot unless you save them. Useiptables-saveor the distribution’s persistent mechanism.
Tips
- Use
nloadfor a simple real-time graph of total bandwidth per interface. - Set up
vnstatto run as a daemon so you have historical data to compare. - If you suspect a DDoS, check
ss -sfor connection stats and consider using a CDN or cloud provider’s DDoS protection. - Keep your system updated to patch vulnerabilities that could be exploited to generate traffic.
- Use
lsof -ito list open network files and their owning processes – useful for spotting unexpected listeners.
Troubleshooting
- Tools not installed? If you can’t install packages due to no internet, use built-in commands:
ss,ip,ps, andcat /proc/net/devare always available. - Traffic is high but no process shows it? It could be kernel-level (e.g., a network driver issue) or a hardware problem. Check
dmesgfor errors. Also trytcpdump -i eth0to see raw packets. - Firewall rules not working? Ensure the service is using the port you think. Use
ss -tlnpto see listening ports and their processes. - Traffic returns after reboot? A service may be set to start at boot. Check
systemctl list-unit-files | grep enabledand disable anything you don’t need. - Can’t kill a process? Try
sudo kill -9 <PID>as a last resort. If it keeps respawning, look for a parent process or a cron job that restarts it.
Frequently Asked Questions
How do I see which IP is using the most bandwidth?
Use sudo iftop -n to show IPs without DNS resolution, sorted by bandwidth. The top entries are the biggest consumers.
What is the difference between iftop and nethogs?
iftop shows traffic per connection (IP and port), while nethogs shows traffic per process. Use both to get a complete picture.
Can I limit bandwidth for a specific user?
Yes, with tc (traffic control) you can shape traffic by IP, port, or even user ID. It’s complex; consider using a tool like wondershaper for simpler setups.
Why is my bandwidth usage high even when I’m not doing anything?
Background services like system updates, package repositories, or cloud agent telemetry can run automatically. Check vnstat -d to see when the traffic occurs and correlate with cron jobs.
Is high outbound traffic always bad?
Not necessarily – if you run a web server or backup service, outbound traffic is normal. The key is to compare against your baseline and investigate sudden spikes.
How do I permanently block an IP address?
Use your firewall’s persistent rules. For ufw: sudo ufw deny from <IP>. For firewalld: sudo firewall-cmd --permanent --add-rich-rule='rule family="ipv4" source address="<IP>" drop' and reload.
Related
General steps for current mainstream versions; menus can differ by device and version. See the disclaimer or report an error.
More in this bed
- PowerPoint vs Keynote: Key Differences
- How to Sign Out of OneDrive in Windows 10
- Reduce Memory Use in Windows When RAM Is Low
- How to Set Up and Use Credential Manager on Windows 10
- Fix Microsoft Edge Battery Drain on Windows 11
- Type to Siri Instead of Talking on iPhone (iOS 11)