Loading the code workspace…
Write a C program that builds a DNS query packet, sends it via UDP to 8.8.8.8 (Google Public DNS), and parses the response.
Requirements:
This is exactly what glibc's res_query() and getaddrinfo() do internally against a resolver like 8.8.8.8 or 1.1.1.1, encoding names into DNS's length-prefixed label format before parsing the answer section. Dan Kaminsky's 2008 cache-poisoning attack exploited weak randomization in the very transaction ID field you set here, which is why modern resolvers randomize both the ID and the source port.
Sample case for Run. Submit grades this sample plus all hidden tests.