Azure / azure-relay-bridge

Azure Relay Bridge - A cross-platform command line tool to create VPN-less TCP tunnels from and to anywhere
MIT License
120 stars 48 forks source link

MacOS - Unable to use loopback addresses other than 127.0.0.1 #74

Closed neil-119 closed 2 weeks ago

neil-119 commented 8 months ago

For some reason, I'm unable to use any address other than 127.0.0.1 on Macs. For example:

sudo ifconfig lo0 alias 127.0.0.2 up

When I debug the library, I am able to bind to this address, and in fact I even get a reply preamble in BridgeSocketConnectionAsync() in TcpLocalForwardBridge.cs with values [1, 0, 0]. The part where it fails is StreamPump.cs -- the source ReadAsync() on the stream returns zero bytes read after a minute and timing out, and this happens to both the hybrid connection stream and the tcp stream as source.

However, if I switch it back to 127.0.0.1, it gets back a positive value for the bytes read immediately and works fine.

neil-119 commented 8 months ago

@clemensv I noticed you wrote the original docs for Macs -- would you have any ideas?

clemensv commented 8 months ago

Since 127.0.0.1 works, this sounds like a configuration issue in the Mac networking stack. I'm skeptical there's anything we can fix in this repo to make that work. Since you can bind to the address, setting up the alias has apparently worked, but the timeout with zero bytes read basically says that an existing connection broke.

I don't have a Mac myself at the moment to test/verify.

neil-119 commented 8 months ago

@clemensv Interestingly, we are able to bind to the alias IP from other applications fine (e.g. I can spin up an ASP.NET web API and bind it to that alias and serve requests through it fine). It only errors out with the Relay. Is there any possibility to get on a screen share session?

clemensv commented 2 weeks ago

Works verifiably in the macOS test phase for the tests we run; calls https://github.com/Azure/azure-relay-bridge/blob/master/test/unit/macos_unblock_testip.sh beforehand