From fff3e52f82222bbe68022becf3ee698b02af395c Mon Sep 17 00:00:00 2001 From: Antonio Ojea Date: Fri, 16 Jul 2021 12:28:57 +0200 Subject: [PATCH] bump rlimit so the eBPF map and program can be loaded --- README.md | 3 ++- nk.go | 8 ++++++++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index d4fcd67..a0a247b 100644 --- a/README.md +++ b/README.md @@ -5,7 +5,8 @@ netcat version using raw sockets to avoid iptables and/or other OS filtering mec ## Requirements It only works on Linux with a Kernel version > 5.2 -It requires CAP_NET_RAW privileges +It requires CAP_NET_RAW and CAP_SYS_RESOURCE capabilities +... or just run it with `sudo` ;) ## Install diff --git a/nk.go b/nk.go index 1a344d6..eb16456 100644 --- a/nk.go +++ b/nk.go @@ -110,6 +110,14 @@ func main() { os.Exit(1) } + // Increase rlimit so the eBPF map and program can be loaded. + if err := unix.Setrlimit(unix.RLIMIT_MEMLOCK, &unix.Rlimit{ + Cur: unix.RLIM_INFINITY, + Max: unix.RLIM_INFINITY, + }); err != nil { + log.Fatalf("setting temporary rlimit: %s", err) + } + if !flagListen { err = connect(ctx, args) if err != nil {