IPv6, NAT64: Rails cannot connect to IPv4 through working NAT64 | experience report with bugfix #1516
tillcarlos
started this conversation in
General
Replies: 1 comment
-
|
Thanks for this! It's not reporting a Kamal issue though, so I'll convert it to a discussion instead. |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Hey Devops Friends
A friend urged me to document my last two days of pain. This is our way to running our own infrastructure on ipv6. I am not the main admin here, but debugged this issue. I think it'd be good for people who are stuck at the same place.
Feel free to close / move this if it doesn't belong here.
Situation:
I run a SaaS with one Hetzner server + sqlite3 + ipv4. It runs great. I met a German guy who told me that IPv6 would be a good thing. So we switched it over to IPv6 and ran into a weird issue which needs some context.
This is our setup:
I also have an admin in my company who set this all up.
How we set up ipv6
We have a
.kamal/hooks/docker-setupthat goes into each server and does this:It was running nicely until we tried to send an email via sendgrid. They don't have ipv6 (apparently email providers dislike ipv6).
ENETUNREACH- Network is unreachable.That's when we created a NAT64 server - separate Hetzner box. I didn't set it up, but it worked well. We added the NAT64 to the /etc/resolv.conf of the host.
The rails container still have this DNS set. You are not supposed to change it (like run with --dns flag), and with a custom network you cannot even change it. Fine, because it forwards to the host anyway:
Where is the error?
We tried to DNS-resolve sendgrid and both time (host + container) we GET THE SAME RESPONSE.
Obvious, because the DNS just forwards to the host machine:
By getting help from my German IPv6-buddy, we found the main difference:
This is a curl to sendgrid from the host mathine:
And this is on the rails container:
Culprit:
The container is TRYING IPV4 FIRST! Why the heck is that?
This blog post finally helped me: https://chameth.com/ipv6-docker-routing/
Apparently the IPv4 is preferred, because we are talking to a IPv4 DNS (the one inside docker at 127.0.11)
We can set the preferences in a file we didn't know existed. Here in the Dockerfile:
That did the trick.
If you find anything here confusing, please send me a message and I'll improve this text.
Beta Was this translation helpful? Give feedback.
All reactions