Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Cat-DNS: a DNS server that resolves everything to cats

Cat-DNS: a DNS server that resolves everything to cats

The internet needs more cats. DNS servers are the authority on all things internet. Therefore, the best DNS server is the one that resolves everything to cats. This talk is about DNS servers: how they work, how your browser talks to them, and how to write a DNS server that always gives you a cat in less than 200 lines of JavaScript.

Monica Dinculescu

March 11, 2014
Tweet

More Decks by Monica Dinculescu

Other Decks in Programming

Transcript

  1. MORE CATS
    THE INTERNET NEEDS

    View full-size slide

  2. I’M MONICA
    @NOTWALDORF

    View full-size slide

  3. DNS
    DOMEOWN NAME SYSTEM

    View full-size slide

  4. DNS
    WWW.GOOGLE.COM == 74.125.226.134

    View full-size slide

  5. CAT-DNS
    WWW.GOOGLE.COM == CATS? CATS!!

    View full-size slide

  6. HOW DO IT DO IT

    View full-size slide

  7. UDP
    USER DATAGRAM PROTOCOL

    View full-size slide

  8. UDP
    “THE HONEY BADGER OF THE INTERNET PROTOCOLS”

    View full-size slide

  9. WWW.IMAGES.GOOGLE.COM ?
    RECURSIVE NAME SERVER:
    YOU:
    HOLD ON. I’LL FIND OUT FOR YOU.

    View full-size slide

  10. WWW.IMAGES.GOOGLE.COM ?
    ROOT SERVER:
    RECURSIVE NAME SERVER:
    NOPE. TRY THE .COM SERVER.

    View full-size slide

  11. WWW.IMAGES.GOOGLE.COM ?
    .COM SERVER:
    NOPE. TRY THE GOOGLE SERVER.
    RECURSIVE NAME SERVER:

    View full-size slide

  12. WWW.IMAGES.GOOGLE.COM ?
    GOOGLE SERVER:
    I GOT IT! IT’S 74.125.226.135
    RECURSIVE NAME SERVER:

    View full-size slide

  13. DNS MESSAGES
    1987 RFCS ARE PAINFUL RFCS

    View full-size slide

  14. 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
    QR OPCODE AA TC RD RA RCODE

    View full-size slide

  15. LET’S TALK ABOUT TOOLS

    View full-size slide

  16. NSLOOKUP
    NSLOOKUP GOOGLE.COM

    View full-size slide

  17. WIRESHARK
    ———

    View full-size slide

  18. SURPRISE PENGUINS!

    View full-size slide

  19. ᕕ ( ᐛ ) ᕗ
    FINALLY, THE CODES!

    View full-size slide

  20. “I'LL OFTEN DROP DOWN TO NODE.JS IF I
    REALLY NEED TO BE CLOSE TO THE METAL”
    - SOME DUDE ON HACKER NEWS

    View full-size slide

  21. require(‘node-bitarray’)
    !
    require(‘buffer’).Buffer
    !
    require(‘dgram’)
    !
    require(‘ip’)

    View full-size slide

  22. var dnsServer = dgram.createSocket('udp4');
    dnsServer.bind(53,'localhost');
    !
    dnsServer.on('message', function (msg, rinfo) {
    !
    // Step 1. Parse message.
    // Step 2. Make answer, echoing the question
    // Step 3. ???
    // Step 4. CATS.
    !
    dnsServer.send(…);
    }
    !
    dnsServer.on("listening", function () {
    if (process.getuid && process.setuid)
    process.setuid(501); // Default user.
    }

    View full-size slide

  23. var dnsServer = dgram.createSocket('udp4');
    dnsServer.bind(53,'localhost');
    !
    dnsServer.on('message', function (msg, rinfo) {
    !
    // Step 1. Parse message.
    // Step 2. Make answer, echoing the question
    // Step 3. ???
    // Step 4. CATS.
    !
    dnsServer.send(…);
    }
    !
    dnsServer.on("listening", function () {
    if (process.getuid && process.setuid)
    process.setuid(501); // Default user.
    }

    View full-size slide

  24. var dnsServer = dgram.createSocket('udp4');
    dnsServer.bind(53,'localhost');
    !
    dnsServer.on('message', function (msg, rinfo) {
    !
    // Step 1. Parse message.
    // Step 2. Make answer, echoing the question
    // Step 3. ???
    // Step 4. CATS.
    !
    dnsServer.send(…);
    }
    !
    dnsServer.on("listening", function () {
    if (process.getuid && process.setuid)
    process.setuid(501); // Default user.
    }

    View full-size slide

  25. IMGUR
    OR: HOW WE ARE AUTHORITATIVE ABOUT CATS

    View full-size slide

  26. CAT-DNS, ENGAGE

    View full-size slide

  27. INSTA-REGRETS

    View full-size slide

  28. LESSONS LEARNED

    View full-size slide

  29. BAD DNS IS SLOW
    CHERISH 8.8.8.8

    View full-size slide

  30. OPEN SOURCE
    THE INTERNET IS A BEAUTIFUL PLACE

    View full-size slide

  31. CAT SERVICE
    THE INTERNET IS A BEAUTIFUL PLACE

    View full-size slide

  32. PULL REQUESTS
    THE INTERNET IS A BEAUTIFUL PLACE

    View full-size slide

  33. “CAT-DNS BEHAVES LIKE AN
    AUTHORITATIVE NAME SERVER, BUT DOES
    NOT SET THE AA BIT. SURELY CAT-DNS IS
    AUTHORITATIVE ABOUT CATS IN DNS.”
    ———

    View full-size slide

  34. =^. .^=
    @NOTWALDORF

    View full-size slide