Skip to main content

iperf3 is a tool that can be used to test the network bandwidth between two EC2 instances. This guide will show you the installation process and basic usage to get you started. For the sake of example, we will be setting up two instances of the Amazon Linux AMI, but feel free to skip the following Instance Setup section if you already have two instances set up.

If you want to follow along, check out the Live Lab for this guide provided by Linux Academy. If you have an account with us, you can use free AWS resources in an environment that’s been prepared for this guide. It’s a great way to follow along. Once you start the lab, you’ll be provided a video that explains the steps in this guide.

Note: The commands used in this guide are specific to the Amazon Linux AMI. If you’re using a different AMI for your instances, you may have to modify the commands appropriately.


Instance Setup

We will begin by setting up two new EC2 instances using the Amazon Linux AMI from the EC2 Management Console on AWS. Here’s how:


  • Log into AWS and click the “Services” dropdown menu from the navigation bar up top. Click “EC2” under the Compute section to launch the EC2 Management Console.
  • Select the “Launch Instance” button.
  • You will be presented with a list of AMIs to choose from. Select the Amazon Linux AMI at the top of the Quick Start tab (you should see it listed by default).
  • You will have the option of selecting an Instance Type. For this example, I will leave the default selection of t2.micro that is eligible for the free tier. Make sure yours is selected and click the Next: Configure Instance Details button in the bottom right of the page.
  • The next page allows you to configure the instance details. You can leave most of the defaults, but change the Number of instances option to 2 and Auto-assign Public IP to Enable. Once you’ve changed the appropriate settings, click the Review and Launch button.
  • This final step allows us to review our settings. iperf3 requires an incoming HTTP rule, so we need to click the Edit security groups link.
  • Choose the Add Rule button at the bottom left of the list. In the Type dropdown, choose the HTTP option. The default settings satisfy the requirements, so click the Review and Launch button once have added the HTTP entry to the list. Note: All sources are allowed by default. This won’t be a concern for this example, but you should consider changing this if you are setting up something more permanent.
  • You will be taken back to the review page. Verify the settings are correct and click the Launch button.
  • Finally, you will be given the option to create a new key pair or choose a new one. It is probably best to create a new one for this guide. I will give mine an appropriate name of iperf-keypair and download it to my downloads folder. You may find it easiest to follow along if you do the same. Once the key pair has been created and downloaded, click the Launch Instances button.
AWS will now set up our instances with the settings we provided, which would have the instance state of “running” in a few minutes with the green circle. I will also rename my instances to that I can easily distinguish between them, and I suggest you do the same. Name one instance iperf-A and the other iperf-B.
Installing iperf3
Let’s begin the installation of iperf3 by connecting to our iperf-A instance via SSH. To get connection details on AWS, check only the desired instance (iperf-A) and choose the Connect button above the list.
Following the details on the connection popup, we must first ensure that the keypair we downloaded earlier is not publicly viewable.
  1. Open a terminal window and use cd navigate to where you downloaded the keypair: cd ~/Downloads
  2. Change the permissions to the desired setting: chmod 400 iperf-keypair.pemStarting the server
    Use the details from your connection window to connect to the instance (be sure to use your instance hostname instead)

    ssh -i "iperf-keypair.pem"

    After accepting the fingerprint, you will be logged into the instance via SSH in your terminal window.

Starting the server

Use the details from your connection window to connect to the instance (be sure to use your instance hostname instead)

ssh -i "iperf-keypair.pem"

After accepting the fingerprint, you will be logged into the instance via SSH in your terminal window.

Now we can install `iperf3` using yum (be sure to watch the output because you’ll need to confirm things along the way):

sudo yum --enablerepo=epel install iperf iperf3

Now that it’s installed, we’re ready to start the `iperf3` server on port 80:

sudo iperf3 -s -p 80

If all went correctly, you should see “Server listening on 80”


Running the tests


Open a second terminal window to connect to our iperf-B instance. Navigate back to AWS and use the Connect button to get the details of our iperf-B instance. Since we are using the same key for both, we have already ensured the iperf-keypair.pem file has the correct permissions and can skip that step and immediate connect to the instance (be sure to update the following command with the proper hostname for this instance):


ssh -i "iperf-keypair.pem"

Accept the fingerprint, then install iperf3 on this second instance, just as we did on the first (again, watch the output).


sudo yum --enablerepo=epel install iperf iperf3

Now we are ready to run iperf3 on the second instance and test the bandwidth between the two. We will instruct it to run a test using the IP address of the iperf-A instance (recall that we have the server running on port 80). Retrieve the IP of that instance from AWS. You will see the IP listed under the “Public IP” tab in the list of instances.

Once you have the IP of the iperf-A instance, you’re ready to run the following command in the second terminal window (replace X.X.X.X with the IP address of the iperf-A instance you just located). For this example, we’ll instruct to run a test on the iperf-A client ip (-c <IP>) it to give output on an interval of 1 second (-i 1) for a total time of 10 seconds (t 10) and to use port 80 (-p 80):


sudo iperf3 -c X.X.X.X -i 1 -t 10 -p 80

You will begin to see output of the tests.
















The reported speeds may vary between subsequent tests, but they should give you a fairly accurate idea of your possible bandwidth between instances to help identify possible bottlenecks in your infrastructure.


Comments are disabled for this guide.