Live data from Hacker News

Rootless Pings in Rust

bou.ke

11–20 of 87 posts

Re: Rootless Pings in Rust

#12
post #9

Worth noting you don't actually need to be fully root in Linux to do standard pings with your code, there's a couple of different options available at the OS level without needing to modify code. 1. You can just add the capability CAP_NET_RAW to your process, at which point it can ping freely 2. There's a sysctl that allows for unprivileged ping "net.ipv4.ping_group_range" which can be used at the host level to allow…

option 2 is what this blog is about, the example code creates a socket using that method

Re: Rootless Pings in Rust

#13

Why does Linux require root for this if you can do it anyway?

Linux requires root for raw sockets, which _can_ be used to send pings, but also numerous other things.

The trick used here only allows pings. This trick is gated behind other ACLs.

Re: Rootless Pings in Rust

#15
post #2

The Linux vs macOS behavioral differences in ICMP sockets documented by the article are critical: - Linux overwrites identifier and checksum fields - macOS requires correct checksum calculation - macOS includes IP header in response, Linux doesn't I think this is the kind of subtle difference that would trip up even experienced programmers

Do these behavioral differences have performance implications? Which approach is more efficient in practice?

Re: Rootless Pings in Rust

#16
This is interesting, but falls just short of explaining what's going on. Why does UDP work for ICMP? What does the final packet look like, and how is ICMP different from UDP? None of that is explained, it's just "do you want ICMP? Just use UDP" and that's it.

It would have been OK if it were posted as a short reference to something common people might wonder about, but I don't know how often people try to reimplement rootless ping.

Post reply on HN