How to specify iperf client port
Asked Answered
H

6

14

Is there a way to force an iperf client to use a specific port number as its outgoing port instead of letting iperf on choosing a random port to use?

Hectic answered 8/4, 2012 at 18:44 Comment(0)
C
6

Actually neither of these answers is correct: they specify the destination port, not the client port. It seems client port is random (but consistent in one run), without a way to specify it

Update 2019: recent versions --cport option to specify client port

Circinate answered 30/1, 2014 at 11:15 Comment(2)
Iperf3 v3.1 introduced the —cport option to specify client port.Clapboard
You can do it with -B <localbindip>:<localbindport> as joe d's answer suggested in iperf2Downstairs
B
9

iperf 3 user documentation https://iperf.fr/iperf-doc.php reveals you can assign a specific client port with --cport <port> and -B --bind option. Check iperf3 user documentation for further details. Here is an example of using client's port number 5500.

Server runs on 10.0.0.2:

> iperf3 -s 

Client runs on 10.0.0.1:

> iperf3 -c 10.0.0.2 -B 10.0.0.1 --cport 5500
Boggle answered 5/8, 2016 at 15:39 Comment(3)
Would you care to explain what is the difference between -p and --cport ? Thank youIdonah
--cport is an option in IPERF3 to specify client-side port while -p or --port to specify server-side port. More info see link.Boggle
Worth noting that while the main portions of the test use these ports, (-p <server port>, —cport <client port> -B <client ip>), a keen observer will discover at least one other port being used in the TCP handshaking. serverfault.com/questions/901719/undefined-iperf3-portsClapboard
A
7
-p, --port #    $IPERF_PORT The server port for the server to listen on and the client to connect to. This should be the same in both client and server. Default is 5001, the same as ttcp.

-p option denotes the port # to be use in client or server.Then you need to set the same port to server side and client site.

For example Server

iperf -s -p 10000

Client

iperf -c SERVER_IP -p 10000 -t60
Aleenaleetha answered 7/10, 2013 at 8:48 Comment(2)
The -p option only specifies the server’s port.Clapboard
This is the correct answer and solved it for me. On the server side (listening) I had to specify a port, and then on the client side (my computer) I then specifed the port that I had defined for the server. This answer states it clearly by defining it.Stonebroke
C
6

Actually neither of these answers is correct: they specify the destination port, not the client port. It seems client port is random (but consistent in one run), without a way to specify it

Update 2019: recent versions --cport option to specify client port

Circinate answered 30/1, 2014 at 11:15 Comment(2)
Iperf3 v3.1 introduced the —cport option to specify client port.Clapboard
You can do it with -B <localbindip>:<localbindport> as joe d's answer suggested in iperf2Downstairs
W
3
iperf -c <remoteip> --port <remoteport> -B <localbindip>:<localbindport>

I have been able to do this using the above.

Widera answered 30/7, 2018 at 15:4 Comment(1)
This should be the correct answer. I could do this with iperf2. For iperf3 I use --cportDownstairs
I
0

This how I solved it for me on specific host (224.25.7.0) and port (25700):

sudo apt install perf on each machine

On listen side (10.14.17.14):

iperf -s -u -B 224.25.7.0%eno1 -i 1 -p 25700

eno1 is the interface name (you can replace by the ip address of the machine)

On sending side (10.14.17.13):

iperf -c 224.25.7.0 -u --ttl 5 -t 5 -B 10.14.17.13 -p 25700

Docker

To test in a docker container or k8s pod, you can use the bagoulla/iperf image:

sudo docker run --net=host --rm bagoulla/iperf:2.0 -s -u -B 224.25.7.0%eno1 -i 1 -p 25700

You can replace the args to what ever you need insteadd

Isometric answered 20/12, 2021 at 23:20 Comment(0)
L
-2

try: server side-

iperf -s -i1 -fm -w512k -p1

client side-

iperf -c <ipadr> -i1 -fm -w512k -p1

-p option indicates port no.

Lysimachus answered 2/9, 2012 at 15:15 Comment(1)
This is not a clear answer. The port that you are specifying for the client is the port the client will use when connecting to the destination host. The question here is if we can force the client to connect on the local endpoint to a specific port.Byrann

© 2022 - 2024 — McMap. All rights reserved.