karppinen@mastodon.online
karppinen@mastodon.online

I integrated an unbound instance as the DNS resolver of my homegrown CGNAT gateway yesterday. Hooked it up to the main (userland) routing process with a pair of veth devices so that all of the DNS-related networking went out the same path as the rest of the customer IP traffic and never touched the host network stack.

This worked great, except… only with some authoritative servers! The root servers worked fine, as did .com TLD, example.com resolved great… but things like google.com didn’t.

|
…
Embed
karppinen@mastodon.online
karppinen@mastodon.online

…this was a ”fun” day of debugging.

My thoughts immediately went to NAT bugs (the unbound process is behind NAT44/NAT66), MTU issues, routing problems at our network core, even rate limiting after my extended testing. But no, it was nothing like that.

Consistently, root servers worked, some other ones too, but most domain names would not resolve no matter what.

|
…
Embed
pcdog@chaos.social
pcdog@chaos.social

@karppinen MTU?

|
…
Embed
karppinen@mastodon.online
karppinen@mastodon.online

Turns out all of the outgoing unbound UDP packets had an invalid checksum.

When Linux sends packets out the veth, it doesn’t calculate proper checksums for them. They are, after all, useless on the local system and if the packets ever leave, the NIC hardware will fill them in.

But here I was, reading the packets directly in a userland process on the same system, not checking CHECKSUM_PARTIAL.

My NAT recalculates checksums incrementally, assuming they’re correct to begin with. Boom.

|
…
Embed
karppinen@mastodon.online
karppinen@mastodon.online

So what did we learn? That many authoritative DNS servers ignore UDP checksums!

|
…
Embed
In reply to
pajp
pajp

@karppinen I also learned that there’s such a a thing as incremental checksum recalculation!

|
…
Embed
karppinen@mastodon.online
karppinen@mastodon.online

@pajp yeah, The Elders had this all figured out!

|
…
Embed
karppinen@mastodon.online
karppinen@mastodon.online

@pcdog that's what I thought at first yeah!

|
…
Embed