You’re right. Stubby will proxy connections. I created a setup analogous to yours, with an lxc container on my router with hostname stubby-container (it was assigned the local ip fd00:8801:2909:6002::22 and global ip 2600:8801:2907:b02::22), installed stubby, and set it to listen on port 8053. The only change I made to the default config was to make it listen on all interfaces instead of just the loop back address:
listen_addresses:
# - 127.0.0.1
# - 0::1
- 0::0@8053
And on another host, I sent the request:
clifford@Ubuntu-Laptop:~$ nslookup -type=AAAA -port=8053 ipv6.danger-rocket.com fd00:8801:2909:6002::22
which returned:
Server: fd00:8801:2909:6002::22
Address: fd00:8801:2909:6002::22#8053
Non-authoritative answer:
Name: ipv6.danger-rocket.com
Address: 2600:1f14:229:a900:d027:2ea9:f122:e0eb
And I ran tcpdump on the bridge interface for the router’s lxc containers:
clifford@router:~$ sudo tcpdump -n -i br2 port 8053 or port 853
And tcpdump dutifully captured the unencrypted udp request from my laptop to stubby’s socket listening on port 8053:
11:59:13.796137 IP6 fd00:8801:2909:6001:f75d:252:4257:ea05.44808 > fd00:8801:2909:6002::22.8053: UDP, length 40
then stubby’s tls conversation with remote dns server’s listening interface on port 853:
11:59:13.950150 IP6 2600:8801:2907:b02::22.38232 > 2001:610:1:40ba:145:100:185:15.853: Flags [.], ack 1, win 225, options [nop,nop,TS val 89407790 ecr 777406519], length 0
11:59:13.950247 IP6 2600:8801:2907:b02::22.38232 > 2001:610:1:40ba:145:100:185:15.853: Flags [P.], seq 1:390, ack 1, win 225, options [nop,nop,TS val 89407790 ecr 777406519], length 389
11:59:14.106212 IP6 2001:610:1:40ba:145:100:185:15.853 > 2600:8801:2907:b02::22.38232: Flags [.], seq 1:1429, ack 390, win 232, options [nop,nop,TS val 777406557 ecr 89407790], length 1428
11:59:14.106233 IP6 2600:8801:2907:b02::22.38232 > 2001:610:1:40ba:145:100:185:15.853: Flags [.], ack 1429, win 248, options [nop,nop,TS val 89407829 ecr 777406557], length 0
11:59:14.107196 IP6 2001:610:1:40ba:145:100:185:15.853 > 2600:8801:2907:b02::22.38232: Flags [P.], seq 1429:2994, ack 390, win 232, options [nop,nop,TS val 777406557 ecr 89407790], length 1565
11:59:14.107214 IP6 2600:8801:2907:b02::22.38232 > 2001:610:1:40ba:145:100:185:15.853: Flags [.], ack 2994, win 272, options [nop,nop,TS val 89407830 ecr 777406557], length 0
11:59:14.107842 IP6 2600:8801:2907:b02::22.38232 > 2001:610:1:40ba:145:100:185:15.853: Flags [P.], seq 390:516, ack 2994, win 272, options [nop,nop,TS val 89407830 ecr 777406557], length 126
11:59:14.260542 IP6 2001:610:1:40ba:145:100:185:15.853 > 2600:8801:2907:b02::22.38232: Flags [P.], seq 2994:3252, ack 516, win 232, options [nop,nop,TS val 777406596 ecr 89407830], length 258
11:59:14.260676 IP6 2600:8801:2907:b02::22.38232 > 2001:610:1:40ba:145:100:185:15.853: Flags [P.], seq 516:675, ack 3252, win 295, options [nop,nop,TS val 89407868 ecr 777406596], length 159
11:59:14.426571 IP6 2001:610:1:40ba:145:100:185:15.853 > 2600:8801:2907:b02::22.38232: Flags [P.], seq 3252:3751, ack 675, win 240, options [nop,nop,TS val 777406638 ecr 89407868], length 499
and then stubby’s unencrypted udp response back to my laptop:
11:59:14.426702 IP6 fd00:8801:2909:6002::22.8053 > fd00:8801:2909:6001:f75d:252:4257:ea05.44808: UDP, length 490
I also ran tcpdump on the stubby-container:
clifford@stubby-container:/etc/stubby$ sudo tcpdump -n -i eth0 port 853 or port 8053
It captured the same traffic:
11:59:13.796141 IP6 fd00:8801:2909:6001:f75d:252:4257:ea05.44808 > fd00:8801:2909:6002::22.8053: UDP, length 40
11:59:13.796261 IP6 2600:8801:2907:b02::22.38232 > 2001:610:1:40ba:145:100:185:15.853: Flags [S], seq 1860576603, win 28800, options [mss 1440,sackOK,TS val 89407752 ecr 0,nop,wscale 7], length 0
11:59:13.950129 IP6 2001:610:1:40ba:145:100:185:15.853 > 2600:8801:2907:b02::22.38232: Flags [S.], seq 622492633, ack 1860576604, win 28560, options [mss 1440,sackOK,TS val 777406519 ecr 89407752,nop,wscale 7], length 0
11:59:13.950148 IP6 2600:8801:2907:b02::22.38232 > 2001:610:1:40ba:145:100:185:15.853: Flags [.], ack 1, win 225, options [nop,nop,TS val 89407790 ecr 777406519], length 0
11:59:13.950244 IP6 2600:8801:2907:b02::22.38232 > 2001:610:1:40ba:145:100:185:15.853: Flags [P.], seq 1:390, ack 1, win 225, options [nop,nop,TS val 89407790 ecr 777406519], length 389
11:59:14.106216 IP6 2001:610:1:40ba:145:100:185:15.853 > 2600:8801:2907:b02::22.38232: Flags [.], seq 1:1429, ack 390, win 232, options [nop,nop,TS val 777406557 ecr 89407790], length 1428
11:59:14.106232 IP6 2600:8801:2907:b02::22.38232 > 2001:610:1:40ba:145:100:185:15.853: Flags [.], ack 1429, win 248, options [nop,nop,TS val 89407829 ecr 777406557], length 0
11:59:14.107200 IP6 2001:610:1:40ba:145:100:185:15.853 > 2600:8801:2907:b02::22.38232: Flags [P.], seq 1429:2994, ack 390, win 232, options [nop,nop,TS val 777406557 ecr 89407790], length 1565
11:59:14.107213 IP6 2600:8801:2907:b02::22.38232 > 2001:610:1:40ba:145:100:185:15.853: Flags [.], ack 2994, win 272, options [nop,nop,TS val 89407830 ecr 777406557], length 0
11:59:14.107841 IP6 2600:8801:2907:b02::22.38232 > 2001:610:1:40ba:145:100:185:15.853: Flags [P.], seq 390:516, ack 2994, win 272, options [nop,nop,TS val 89407830 ecr 777406557], length 126
11:59:14.260545 IP6 2001:610:1:40ba:145:100:185:15.853 > 2600:8801:2907:b02::22.38232: Flags [P.], seq 2994:3252, ack 516, win 232, options [nop,nop,TS val 777406596 ecr 89407830], length 258
11:59:14.260674 IP6 2600:8801:2907:b02::22.38232 > 2001:610:1:40ba:145:100:185:15.853: Flags [P.], seq 516:675, ack 3252, win 295, options [nop,nop,TS val 89407868 ecr 777406596], length 159
11:59:14.426574 IP6 2001:610:1:40ba:145:100:185:15.853 > 2600:8801:2907:b02::22.38232: Flags [P.], seq 3252:3751, ack 675, win 240, options [nop,nop,TS val 777406638 ecr 89407868], length 499
11:59:14.426699 IP6 fd00:8801:2909:6002::22.8053 > fd00:8801:2909:6001:f75d:252:4257:ea05.44808: UDP, length 490
That is probably your best bet to find where your traffic being dropped. Run tcpdump on your container’s bridge interface and also on the container’s interface. Then run remote dns query. The output from tcpdump will show you exactly where traffic is being dropped and you can adjust your firewall rules accordingly.