Using WireGuard to connect to service on my laptop

I’ve been able to setup WireGuard so that I can connect directly to my app from my laptop without it being publicly accessible (removing the service config from fly.toml)

But I would also like to be able to allow my app to connect to a service running on a port on my local machine (graphite running the statsd protocol on UDP port 8125). Is that possible to do? I don’t think I saw mention of it in various discussion I’ve seen about WireGuard on fly.io, but I might not have understood because I’m not as familiar with “peers” and “6PN addresses” and whatnot :sweat_smile:

Thanks!

Hey, you can definitely connect back to your laptop from your app. Your laptop gets an IP address on your 6PN (“IPv6 private networking”) subnet, which you can use to connect to it from your app.

1 Like

Thanks :smile: How do I find that :sweat_smile:

I see an /120 in for “Addresses” in Wireguard, which I assume is the address range for the network. I tried that IP address as well as the addresses listed under flyctl wireguard list, but no luck.

I was trying from inside Elixir, by the way, with HTTPoison.get("http://[ipv6address]:4000/overview") and getting {:error, %HTTPoison.Error{reason: :econnrefused, id: nil}}. It could be that I’m testing incorrectly :thinking:

That’s the correct IP, is your service listening on it?

Ah, right, thank you! Needed to change my Phoenix.Endpoint config from http: [ip: {127, 0, 0, 1}, port: 4000], to http: [ip: {0, 0, 0, 0, 0, 0, 0, 0}, port: 4000], to listen on ipv6 :tada: Thanks!

Hmm, ok… so I can confirm that I can connect with HTTPoison to my local web server, but when I try to connect via UDP to my local graphite instance it doesn’t work. I’m using TelemetryMetricsStatsd and giving it the correct host (I finally found out you can’t seem to give it a string, so I’m giving it a tuple of the ipv6 address integers), but it’s giving a eafnosupport error.

Should I be able to connect via UDP? The note in the middle of this post implies there might be some sort of problem with UDP and WireGuard…

Ok, I figured it out. telemetry_metrics_statsd is using OTP’s gen_udp under the covers and you need to pass the :inet6 option to it. Anybody following along can check out this issue: Is IPv6 supported? · Issue #78 · beam-telemetry/telemetry_metrics_statsd · GitHub

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.