Operation not permitted
fenimore opened this issue · comments
Hi, I'm trying to use this library for sending some ARP requests, and I get an
operation not permitted
error when I try to create a client. I'm getting the interfacing, passing it's pointer to the NewClient
method. like so:
ifaces, _ := net.Interfaces()
// The third for me is the relevant one.
client, err := arp.NewClient(&ifaces[2])
if err != nil {
fmt.Println(err)
}
target := net.ParseIP("10.0.18.70")
err = client.Request(target)
if err != nil {
fmt.Println(err)
}
So I then get a nil error when I call client.Request, because the original client is not permitted. Is this the correct way to proceed? Should I be using sudo? When I do that it complains that the GOPATH isn't set, and things get tricky.
Yep, raw sockets require root permissions, or the CAP_NET_RAW
capability (see man 7 capabilities
).
It sounds like you're trying to use go run
instead of go build
? go build
the binary as your user and then use sudo
or set the capability on it to run it.
Thanks! This is it, now I'm getting a no IPv4 address available for interface, but atleast I'm accessing it :), I can take it from here.
Just to be clear, the problem went away when building the binary and running it as sudo.