Skip to content

icmp ping broken on osx under su account with PingOptions  #34879

@ispysoftware

Description

@ispysoftware

icmp ping broken on osx under su account

General

in a dotnet core app calling ping works if not running under the super user account. If you run it as root it fails with operation not supported errors.

using dotnet core v3.1.201 on OSX Mojave

sample app provided. Output:

seans-Mac-mini:Agent sean$ dotnet testping.dll
found 192.168.15.1
found 192.168.15.7
found 192.168.15.0
found 192.168.15.17
found 192.168.15.10
found 192.168.15.19
found 192.168.15.9
found 192.168.15.24
found 192.168.15.12
found 192.168.15.20
found 192.168.15.6
found 192.168.15.5
found 192.168.15.18
Found 13 addresses

seans-Mac-mini:Agent sean$ sudo dotnet testping.dll

ping: 192.168.15.3 :System.AggregateException: One or more errors occurred. (An exception occurred during a Ping request.)
---> System.Net.NetworkInformation.PingException: An exception occurred during a Ping request.
---> System.Net.Sockets.SocketException (45): Operation not supported
at System.Net.Sockets.Socket.UpdateStatusAfterSocketErrorAndThrowException(SocketError error, String callerName)
at System.Net.Sockets.Socket.SetSocketOption(SocketOptionLevel optionLevel, SocketOptionName optionName, Int32 optionValue, Boolean silent)
at System.Net.Sockets.Socket.SetSocketOption(SocketOptionLevel optionLevel, SocketOptionName optionName, Int32 optionValue)
at System.Net.Sockets.Socket.set_DontFragment(Boolean value)
at System.Net.NetworkInformation.Ping.GetRawSocket(SocketConfig socketConfig)
at System.Net.NetworkInformation.Ping.SendIcmpEchoRequestOverRawSocketAsync(IPAddress address, Byte[] buffer, Int32 timeout, PingOptions options)
at System.Net.NetworkInformation.Ping.SendPingAsyncCore(IPAddress address, Byte[] buffer, Int32 timeout, PingOptions options)
at System.Net.NetworkInformation.Ping.SendPingAsyncInternal(IPAddress address, Int32 timeout, Byte[] buffer, PingOptions options)
--- End of inner exception stack trace ---
...
testping.zip

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions