gnirehtet icon indicating copy to clipboard operation
gnirehtet copied to clipboard

Add flag to bind to a particular local IP

Open matt-johnston-ecommistry opened this issue 5 years ago • 1 comments

In a situation with multiple Android devices & multiple local interfaces, I'd like to have each phone use a different local IP (and effectively, network interface) for network access. In theory this would be simple as using a separate local IP on the outgoing sockets, and let the OS handle the interface mapping (this works in Linux and OS X at least). My ideal configuration would be a command-line option to specify local IP that applied to that whole instance, then if needed for multiple devices multiple instances of gnirehtet can be started.

I'm happy to look at options to implement this myself, although some pointers to where in the code these packets are sent out would be appreciated (I'm not as familiar with Rust so trying to trace where this is actually generated out to the system is a little tricky).

Use Case: The user has multiple Android devices connected to a computer (e.g., for testing or automation).

The computer has multiple network interfaces or local IP addresses.

The goal is to assign each phone to a different outgoing interface, isolating traffic.

Feature Request: Add a command-line flag (like --bind-ip) to:

Bind the outgoing socket for each client to a specific local IP address.

Let the OS handle the routing through the correct interface based on the bound IP.

Example:

gnirehtet run --bind-ip 192.168.0.10 Why It Matters: Helps in network routing control, traffic shaping, or testing different gateway paths.

Useful in multi-device automation setups.

Technical Insight: The user asks for guidance on where in the code the network packets are sent so they can potentially:

Add a bind() call before connect() on the outgoing socket.

Implement this flag themselves (they mentioned they're not very familiar with Rust).

This would likely need changes in the Rust portion of Gnirehtet’s relay server — particularly in the sections that open TCP/UDP sockets for relaying traffic.

Conclusion: The feature request is valid and technically feasible.

It would require modifications in the relay server's socket handling logic, likely in the Rust code under:

relay/src/net/tcp.rs

relay/src/net/udp.rs

Implementing it would give advanced users more fine-grained control over multi-device network routing.

VaradGupta23 avatar Jul 15 '25 06:07 VaradGupta23