Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Linux: Please use socket with IPPROTO_ICMP instead of socket_raw #4

Open
jcdutton opened this issue Nov 5, 2023 · 0 comments
Open

Comments

@jcdutton
Copy link

jcdutton commented Nov 5, 2023

The equivalent in C:
Use the non raw socket.:
create_socket(&rts, &sock4, AF_INET, hints.ai_socktype, IPPROTO_ICMP,
hints.ai_family == AF_INET);
Instead of:
socktype = SOCK_RAW;
sock->fd = socket(family, SOCK_RAW, protocol);

Also please enable DF bit with something like this:
rts.pmtudisc = IP_PMTUDISC_DO is the options have it set.

The benefit of using the IPPROTO_ICMP method, is that then non-root users can use the ping.
Also, the SOCK_RAW is disabled entirely on Linux Ubuntu, so not even root can do it, and one gets this back from the program:
OsError(13, "Permission denied (os error 13)")
A temp fix for Ubuntu so that at least root can do SOCK_RAW is:
sudo sysctl "net.ipv4.ping_group_range=0 1"
But the better fix is using IPPROTO_ICMP instead.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant