6

I want headless server (running Ubuntu Server 19.10) to be listening for iperf3 request constantly, even after reboot. Currently, I can run it on the terminal using the -c and -d flags which runs it as a daemon (which I think just means in the background).

sudo iperf3 -s -D

But I want it start in this mode all the time on boot, so it is always listening in the background.

When I've done this kind of before, it's involved systemd, which I am not familiar with too much. Don't think there was mention of systemd when I read up on iperf3 program, so is it even compatible with it (or is that statement itself nonsensical?)

Only ever used systemd in very limited ways before when been instructed to in tutorials so not up to speed on its scope.

3
  • is there already a service for it? try sudo systemctl enable iperf3? Jun 18, 2020 at 7:08
  • I get Failed to enable unit: Unit file iperf3.service does not exist.
    – exharris
    Jun 18, 2020 at 7:18
  • ah, okay then. see my answer. Jun 18, 2020 at 7:23

2 Answers 2

13

Since Ubuntu doesn't seem to provide a systemd service for iperf3d, we'll have to write it ourselves.

See https://gist.github.com/auipga/64be019018ef311deba2211ced316f5e, and I'll quote it here as well.

[Unit]
Description=iperf3 server
After=syslog.target network.target auditd.service

[Service]
ExecStart=/usr/bin/iperf3 -s

[Install]
WantedBy=multi-user.target

put this file in /etc/systemd/system/iperf3.service and then sudo systemctl enable iperf3.

3
  • Thank you. Was 'service for iperf3d' in your first sentence a typo, or is iperf3d something different I need to know about...
    – exharris
    Jun 18, 2020 at 7:39
  • it's just iperf3. adding a "d" to program names is just convention to indicate that the program is a daemon. don't worry about it. Jun 18, 2020 at 7:50
  • ok thanks. I presume this is what the d in systemd is.
    – exharris
    Jun 19, 2020 at 10:41
1

For the lazy people like me, here is an easier version of what is listed above. You just need to copy/paste to terminal and the server will be up.

apt-get -y install gdebi iperf3 

cat <<- EOF >   /etc/systemd/system/iperf3.service
[Unit]
Description=iperf3 server
After=syslog.target network.target auditd.service

[Service]
ExecStart=/usr/bin/iperf3 -s

[Install]
WantedBy=multi-user.target
EOF

sudo systemctl enable iperf3
service iperf3 start

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .