Create DNS query with Netcat or /dev/udp/ [closed]


I’m trying to send a valid DNS request with either nc or bash and /dev/udp/.

I created a valid DNS packet to use as a template:

tcpdump -XX port 53 

Then, in a new terminal made a request with curl:

curl https://duckduckgo.com/ 

This generates the following data in the tcpdump terminal.

    0x0000:  4500 003c b0b4 4000 4011 73c3 0a00 020f  E..<..@.@.s.....     0x0010:  0a2a 0001 bdd4 0035 0028 4f24 cfc9 0100  .*.....5.(O$  ....     0x0020:  0001 0000 0000 0000 0a64 7563 6b64 7563  .........duckduc     0x0030:  6b67 6f03 636f 6d00 0001 0001            kgo.com..... 

From this, I modified the request slightly to match this reference and saved it to a file /tmp/ddg.txt.

0000:  4500 003c b0b4 4000 4011 73c3 0a00 020f  E..<..@.@.s..... 0010:  0a2a 0001 bdd4 0035 0028 4f24 cfc9 0100  .*.....5.(O$  .... 0020:  0001 0000 0000 0000 0a64 7563 6b64 7563  .........duckduc 0030:  6b67 6f03 636f 6d00 0001 0001            kgo.com..... 

Then, tried generating a request, but I get the following error message:

xxd -r /tmp/ddg.txt | nc -q 1 -nu 10.42.0.1 53 xxd: sorry, cannot seek backwards. 

In Wireshark, the request appears malformed. What am I getting wrong here? It is possible to send a proper DNS query with this method?

enter image description here