How to throttle bandwidth on a Linux network interface?

Is there a way to constrain the bandwidth on a NIC in linux? I'd like to be able to simulate an arbitrarily slow connection.


The netem kernel module, controlled by iproute.

You need to compile Netem with the kernel:

Networking -->
   Networking Options -->
     QoS and/or fair queuing -->
        Network emulator

Once the netem module loaded, iproute's tc allows you things like:

tc qdisc add dev  tap0 root netem delay 50ms loss 50%

(50 % packet loss, extra delay of 50 ms)

Client side, right?

trickle should do what you want. If you're running Ubuntu (or Debian, I think), you can install it with sudo apt-get install trickle, and then run it. trickle -s -d 10 -u 10 firefox (or so, I haven't used it in a while) would run firefox, limiting its download and upload speed to 10 kilobytes a second.

I found a way to avoid my box from eating all the bandwidth available on network using a tool called 'wondershaper' in ubuntu. I hope it exist in other linux destros too. I can limit the bandwidth what my linux home pc can consume using following command.

sudo wondershaper eth0 1000 200

This limits the download limit to 1000 kilobits and uplaod to 200 kilobits. Refer to the man pages of wondershaper for more information/options.

NIST make a network simulator called NistNet. (link seems dead)

NistNet lets you make a router that emulates a comms link of your choosing.

For simplest operation you have it on a box with two NIC's between two networks.

For example, I had an application that had to work over a satellite link.

Data could go over the a 2Mbps link with BIG latency. Control had to go over a 128kbps link, with the same latency.

NistNet helped to get it all working on 128kbps.

Using NistNet I could simulate not only the bandwidth, but also the latency, and it will also drop packets for you, simulating a busy or unreliable link.

If you want to simulate an abitrary connection, don't just constrain the bandwidth, wind the latency up too.

Don't forget to fragment packets either. You can set nice small MTU's on the phony link.

IIRC adding packet jitter will let you find out if you can cope with out-of order packets.

I've personally used wondershaper in the past for this, though it was written for an opposite use case - making the most of your ADSL connection.

I'll have to try the others mentioned here though.

You can use locally installed squid proxy to limit bandwidth for example to test a web page on slow link:

  1. Install squid proxy from your distribution — on my Fedora it was as easy as yum install squid.
  2. Add the following to /etc/squid/squid.conf:

    delay_pools 1
    delay_class 1 1
    delay_access 1 allow all
    delay_parameters 1 16000/16000

    This will limit bandwidth to about 128 kbps (16000 Bps).

  3. Start squid: /etc/init.d/squid start
  4. Configure your browser to use proxy server localhost port 3128.

No one has yet mentioned ip_relay, named "iprelay" in the Debian repositories. It works as a TCP proxy, rather than intercepting calls the way trickle does, and will work with any application that can use a proxy (e.g. a web browser) or accept a user-defined destination port (telnet, ssh, ftp, curl, et cetera).

It's a little more difficult to set up, but often works in situations where trickle won't.

Category: linux Time: 2008-08-28 Views: 4

Related post

  • how to associate a Docker network interface to a Linux network interface (eth5) on Linux host? 2015-12-17

    My Linux host has 8 Ethernet interfaces, eth0 - eth7. I'm running three Docker 1.9 containers on this Linux host. How can I associate a network interface inside one Docker container to a specific Linux physical network interface (say eth5) on the hos

  • How to find out the number of network interfaces available in a linux system? 2015-07-02

    I need to loop over the network interfaces available in Linux. I'm interested in all kinds of interfaces (loopback, ethernet, vlan, bridge) - whatever shows up in ifconfig -a. Is there a way to enumerate the interfaces in Linux? By any command or by

  • How can I get information about an network interface uptime? 2013-07-08

    I have an Ubuntu machine and a Debian machine. On both I want to be able to see for how long an network interface has been connected. (That is, connected to a network getting an IP etc. Not the physical state of a cabel). Uptime in seconds or date +

  • How do I diagnose an onboard wired network interface that quit working? 2011-10-03

    I have an installation of 10.10 that has been working fine since I upgraded. One day I booted it and there was no network connectivity. The network indicator now says "Networking disabled". If I go to System > Administration > Network Tool

  • how to determine name/ip of primary network interface on centos x64 VPS 2011-12-26

    I am trying to install Virtualmin - GPL on a Centos x64 VPS. After downloading the script, I tried running it... At one stage this is the message that i received-- eth0: error fetching interface information: Device not found INFO - Unable

  • How to control the up order of network interfaces? 2013-07-01

    I have /etc/network/interfaces as follow. Every time the system boots up, the route is wrong so the gateway is not reachable. I'd have to ifdown br0 && ifup br0 to fix the route table and make everything work. How to fix this forever? auto lo ifac

  • Linux network interface broadcast statistics 2013-07-10

    I am looking for a way to see the number of Ethernet broadcast frames transmit/received by the network interfaces. I am familiar with many Linux commands,procs and options to get interface statistics (ifconfig , nstat (which shows ip broadcasts), /pr

  • How to find name of currently-active network interface? 2014-01-14

    I need to get the name of the network interface (e.g. eth0, wlan0) that is the currently-active one, the one sending and receiving traffic at the moment. When it's connected to WiFi, it would be wlan0 but when it's connected directly it would be eth0

  • How do I Control the Ordering of Network Interfaces? 2014-07-21

    I'm attempting to configure a machine with 3 NICs, the first two are built-in GbE controllers, the third is a 10GbE controller. Via NetworkManager, I've configured the 'first' GbE NIC (which at the time was eth0) to use a static IP address. The secon

  • Linux network interfaces take so long to come up 2015-01-23

    When any of the network interfaces on my x86 server comes up (1GbE port with igb driver, or 10GbE port with ixgbe driver), whether it's been done using ifup or by enabling the switch ports it's connected to, it takes on the order of 30 seconds before

  • How do you set up a second Network Interface Card to connect to a network printer? 2015-09-15

    I have an Ubuntu 15.04 box with a nic cabled to my router-modem for the internet. Now I'd like to install and set up a second nic with the only task of connecting to my printer (apple laserwriter w/ network adapter). How do I do this w/o causing conf

  • How to get a list of all network interfaces using ifquery 2015-11-22

    The documentation states that ifquery --list gives a list of all interfaces specified in /etc/network/interfaces (and includes). In fact in both Debian Jessie and Ubuntu 14.04 it lists all interfaces that have auto INTERFACENAME stanza and skips thos

  • Renaming Red Hat Enterprise Linux Network Interfaces 2015-12-22

    I have a virtual machine on vmware ESXi 6.0 running Red Hat Enterprise Linux 7.2. I have two network interfaces that I want to be named "eth0" and "eth1" respectively. They were originally named with the prefix "eno..." and t

  • How to log the activity of a network interface in a file 2012-12-18

    I need to write a "one-liner" in /etc/network/interfaces that ensures that when eth1 goes up/down a file /var/log/network.log is written with something like that UP/DOWN [DATE/TIME] EX: UP [10-12-2012/21:30:00] The format is [DD-MM-YY/HH-MM-SS]

  • Ubuntu: How to configure DNS servers in /etc/network/interfaces correctly for resolvconf? 2013-04-03

    All examples I have seen of configurations (/etc/network/interfaces) showed that you configure an interface and then underneath that gave the dns-* lines such as: auto eth0 iface eth0 inet static ... dns-nameservers dns-search m

  • How to change the DNS server across network interfaces? 2014-07-15

    The only consistent solution for changing your DNS server is to change it in each individual network interface. This means for Ethernet and for each wireless network you use. I'm looking for a way to set DNS servers globally. No matter what interface

  • How to get the name of a network interface that is down 2015-11-08

    I am using Ubuntu and am just curious as to tell the name of all network interfaces, even the ones I've taken down with sudo ifconfig wlan0 down (for example) as they no longer show up in ifconfig. --------------Solutions------------- You can use ifc

  • How to throttle bandwidth for ipalias in Linux 2015-05-14

    I want to slow the connection between some nodes to a virtual node inside one machine. (different nodes use different ip with ip-alias or with different ports) In Linux, is it possible to slow the bandwidth for a specific IP in ipalias? Or for a spec

  • How to monitor bandwidth on a Linux router by LAN IP 2012-05-31

    There are plenty of ways to monitor traffic on a specific interface or even by port. But if I am on a router and suspect one of the workstations is using more bandwidth then others, how to check? --------------Solutions------------- iftop will show t

iOS development

Android development

Python development

JAVA development

Development language

PHP development

Ruby development


Front-end development


development tools

Open Platform

Javascript development

.NET development

cloud computing


Copyright (C), All Rights Reserved.

processed in 1.330 (s). 13 q(s)