tcpdump as a systemd service on Proxmox hosts

Matthew Daniel

Active Member
May 3, 2018
14
3
43
51
Has anyone here attempted to run tcpdump as a systemd service on Proxmox hosts? Can you please share your tcpdump.service file and any other configuration info?
I'm struggling to get it running and would like tcpdump to start on boot to monitor some DNS issues I'm logging on port 53
 
Hey,

this should work, you probably also want to specify a file with -w.

Code:
[Unit]
After=network.target
 
[Service]
ExecStart=/usr/bin/tcpdump ...
ExecStop=/bin/kill -s TERM $MAINPID
 
[Install]
WantedBy=multi-user.target
 
Hey,

this should work, you probably also want to specify a file with -w.

Code:
[Unit]
After=network.target
 
[Service]
ExecStart=/usr/bin/tcpdump ...
ExecStop=/bin/kill -s TERM $MAINPID
 
[Install]
WantedBy=multi-user.target
Thanks, Hannes. I had something similar set up that kept refusing to start.

I could run tcpdump via the command line with the following attributes:
tcpdump -i ens18 -K -n port 53 -s 0 -w /var/log/tcpdump_$(hostname -s)_port53_$(date +%Y%m%d-%H%M%S).pcap

I had to tweak this in the tcpdump.service file to get it to run:

ExecStart=/bin/bash -lc '/usr/bin/tcpdump -i ens18 -K -n port 53 -s 0 -w /var/log/tcpdump_$(hostname -s)_port53_$$(date +%%Y%%m%%d-%%H%%M%%S).pcap'

All sorted now. Cheers
 

About

The Proxmox community has been around for many years and offers help and support for Proxmox VE, Proxmox Backup Server, and Proxmox Mail Gateway.
We think our community is one of the best thanks to people like you!

Get your subscription!

The Proxmox team works very hard to make sure you are running the best software and getting stable updates and security enhancements, as well as quick enterprise support. Tens of thousands of happy customers have a Proxmox subscription. Get yours easily in our online shop.

Buy now!