Skip to content

Add --ttl flag for configurable packet TTL#10

Open
schmiatz wants to merge 4 commits intothomseddon:masterfrom
schmiatz:master
Open

Add --ttl flag for configurable packet TTL#10
schmiatz wants to merge 4 commits intothomseddon:masterfrom
schmiatz:master

Conversation

@schmiatz
Copy link

  • Adds a --ttl flag (and TTL env var) to control the IP TTL on forwarded packets
  • Sets both IP_TTL and IP_MULTICAST_TTL via syscall on all forwarding sockets
  • Needed for multicast destinations (e.g. 233.x.x.x) where the OS defaults TTL to 1, causing packets to be dropped at the first hop

Usage

./replicator --listen-port=9000 --forward=233.84.178.1:1002 --ttl=64

When --ttl is not set (or set to 0), the OS default behavior is preserved.

Matthias Schmitz and others added 4 commits February 19, 2026 23:59
Uses golang.org/x/net/ipv4 to set the IP TTL on forwarding connections,
which is needed when forwarding to multicast addresses (OS defaults TTL to 1).

Co-Authored-By: Claude Opus 4.6 <[email protected]>
Use SetMulticastTTL via ipv4.PacketConn for multicast addresses (e.g.
233.x.x.x) since the kernel ignores the unicast TTL for multicast
traffic and defaults it to 1.

Co-Authored-By: Claude Opus 4.6 <[email protected]>
The ipv4.PacketConn.SetMulticastTTL wrapper does not work on connected
(DialUDP) sockets. Set the socket option directly via SyscallConn and
SetsockoptInt instead.

Co-Authored-By: Claude Opus 4.6 <[email protected]>
On connected UDP sockets the kernel may check either option depending
on the send path. Set both to cover unicast and multicast targets.
Removes golang.org/x/net/ipv4 dependency.

Co-Authored-By: Claude Opus 4.6 <[email protected]>
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

Successfully merging this pull request may close these issues.

1 participant