Using gopacket/pcap without root permission

Hello there!

I am making a Go program that uses gopacket/pcap to read and write raw packets. On windows, this Go program is safe to ship as it doesn’t need any special permissions to run (winpcap is installed prior to running).

On macOS and Linux however, I get permission denied when I try to do this. The solution I know of is to run the program using sudo, however as I’ve understood it, having a Go program run in root space is not a good idea.

Therefore I am wondering if there is a better way to make my Go program that uses gopacket/pcap to read/write packets not run as root, but rather open those permissions up to my Go binary to run in userspace.

Any help is appreciated!

I found solutions for macOS and linux here.
Updated linux specific command to enable permissions here.

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.