I am trying to play with socat to simulate a DNS request on localhost. Here is what I did setup DNS server on localhost port 15353 and once request received on 15353, it will forword it to google's DNS server 8.8.8.8:53
socat -v -v TCP-LISTEN:15353,reuseaddr,fork UDP:8.8.8.8:53
Send DNS request on same localhost using dig, specify request port to 15353
dig +tcp example.com @localhost -p 15353
Below are the response I got
On socat server terminal
socat -v -v TCP-LISTEN:15353,reuseaddr,fork UDP:8.8.8.8:53
> 2023/01/24 12:46:13.030249 length=54 from=0 to=53
.4... ........\aexample.com.......).......\f.
.\b........> 2023/01/24 12:46:23.029623 length=54 from=0 to=53
.4.i. ........\aexample.com.......).......\f.
.\b........> 2023/01/24 12:46:49.002657 length=54 from=0 to=53
.4.k. ........\aexample.com.......).......\f.
.\b...Q...0> 2023/01/24 12:46:59.001639 length=54 from=0 to=53
.4... ........\aexample.com.......).......\f.
.\b...Q...0> 2023/01/24 12:47:09.001787 length=54 from=0 to=53
.4E.. ........\aexample.com.......).......\f.
On dig client terminal
dig +tcp example.com @localhost -p 15353
; <<>> DiG 9.16.1-Ubuntu <<>> +tcp example.com @localhost -p 15353
;; global options: +cmd
;; connection timed out; no servers could be reached
Anything wrong on my command ?