This week we continue our series of examples for Mongoose Embedded Web Server with an example of a DNS server.In this case, it is a DNS server intended to be used to build a captive portal, i.e. where the user needs to log in before using public WiFi. Such a server responds to all queries with its own IP address and an HTTP server running alongside serves the portal page to the user.Building a DNS server with Mongoose is easy: mg_bind to a udp:// port, call mg_set_protocol_dns on the connection and handle incoming MG_DNS_MESSAGEevents.Our captive_dns_server example puts this all together:$ ./captive_dns_server Listening on 'udp://:5533' ev_handler Q type 1 name --- $ dig @localhost -p 5533 ; <<>> DiG 9.9.5-11ubuntu1.3-Ubuntu <<>> @localhost -p 5533 ; (1 server found) ;; global options: +cmd ;; Got answer: ;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 44936 ;; flags: qr rd ra ad; QUERY: 1, ANSWER: 1, AUTHORITHY: 0, ADDITIONAL: 0 ;; QUESTION SECTION: ; IN A ;; ANSWER SECTION: 10 IN A ;; Query time: 0 msec ;; SERVER: ;; WHEN: Mon Apr 18 19:56:51 IST 2016 ;; MSG SIZE rcvd: 56Follow the ExampleTo follow the example download Mongoose Embedded Webserver. It's open source under GPLv2, so free of charge for non-commercial use.