mirror of
https://github.com/fosrl/newt.git
synced 2026-05-06 07:59:04 -05:00
[GH-ISSUE #247] newt: ICMP not working when TCP or UDP port restrictions are set #2061
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @rskallies on GitHub (Feb 27, 2026).
Original GitHub issue: https://github.com/fosrl/newt/issues/247
Originally assigned to: @oschwartz10612 on GitHub.
Describe the Bug
Hi,
I use the latest newt 1.10.1. When adding a private resource in Pangolin and only allow a port or port range for TCP or UDP but still allow ICMO then ping does not work.
Environment
To Reproduce
Add a private resource e.g. for the new SSH feature, allow ICMP, allow only port 22. Try to ping the resource.
When the private resource setting is left at its defaults TCP any UDP any ICMP on then ping works.
Expected Behavior
ICMP should work without needing to allow all TCP / UDP ports.
@rskallies commented on GitHub (Feb 27, 2026):
newt-icmp-fix.patch
newt: ICMP not working when TCP or UDP port restrictions are set
Summary
ICMP (ping) access to a private resource fails whenever TCP or UDP port restrictions
are configured, even when the ICMP toggle is explicitly enabled in the Pangolin UI.
ICMP only works when both TCP and UDP are set to allow all ports.
Affected file
netstack2/proxy.go--SubnetLookup.Match()Root cause
The
Match()function is the gatekeeper for all incoming packets. It decides whethera packet should be forwarded to the proxy stack or dropped. For TCP and UDP it checks
port ranges. For ICMP it was supposed to check only the
DisableIcmpflag.The original code checked
DisableIcmpfirst, then fell through to the port rangeloop for all other cases, including ICMP:
When
DisableIcmpis false (ICMP allowed) and port ranges are non-empty, ICMPpackets reached the port range loop. ICMP has no port concept, so
Match()iscalled with
port=0andproto=ICMPv4ProtocolNumber. Port 0 never matched anyTCP or UDP range, so the function returned
nil, blocking the ICMP packet.When no port restrictions are set (
PortRangesis empty), the early return atlen(rule.PortRanges) == 0fired before the loop, so ICMP happened to work.The Pangolin server correctly sends
disableIcmp: falsewhen the ICMP toggle isenabled regardless of TCP/UDP port restrictions. The bug was entirely in
Match().Fix
Handle ICMP before the port range check. If the protocol is ICMP, return immediately
based solely on the
DisableIcmpflag. Port ranges are irrelevant to ICMP.Patch
The patch file is
newt-icmp-fix.patchnext to this document.Apply with:
Additional change included in patch
Added
disableIcmpto the existing log line inclients/clients.go(threelocations) to make the effective ICMP setting visible in logs:
Verification
After applying the fix, with TCP restricted to port 6565 and ICMP enabled: