I have made a lot of DNS products and doing the same thing happening here is a few lines of code in most any language. This code, while entertaining, cannot handle very simple DNS packets because of its "compression encoding.
I've developed on consumer grade routers from big vendors - Asus, linksys, netgear etc, and they are all using identical quality scripts for a large majority of the router's data processing. These scripts may not be pristine, but they are sure not always just a toy.