{ "id": "https://ryan.freumh.org/eon.html", "title": "Eon", "link": "https://ryan.freumh.org/eon.html", "updated": "2025-04-21T00:00:00", "published": "2025-04-21T00:00:00", "summary": "
\n \n Published 21 Apr 2025.\n \n \n
\n \n
Tags: research, projects, self-hosting.
\n \n \n\n

Eon\nis an Effects-based OCaml Nameserver using MirageOS’s functionally pure Domain Name\nSystem (DNS) library\nwith direct-style\nIO (as opposed to monadic\nIO) using OCaml 5’s\neffect handlers\n[1] created as the basis to implement\nsome of ideas from the Spatial Name\nSystem.

\n

DNS Tunnelling

\n

DNS is well-known to be used for data\nexfiltration and tunneling,\nsince DNS is one of the few protocols that’s almost always allowed\nthrough a firewall (at least through a recursive resolver) since it’s so\nfundamental to the operation of the Internet. I’ve implemented a\ntransport layer over DNS in\nEon, a simple netcat\nexample shows how this can be used to transport data using DNS queries.\nMany thanks to Paul-Elliot for\nhelping clean up the transport interface and making it more\nidiomatically functional. At the moment there’s no multiplexing – a\nserver can only handle one communication at a time, but that could\naddresses by adding a demultiplexing field (a ‘port’).

\n

The well-defined interfaces that\nOCaml gives us allows this to be combined in interesting ways, such as a\nshell\nover DNS (SoD), or an IP\ntunnel. Note that you wouldn’t want to use this in production\nwithout some form of encryption (maybe ocaml-tls?) and\nauthentication (e.g. public/private keys, or capabilities). A standalone\nexample of a capability interface to a shell can be found at capability-shell.

\n

There’s some interesting performance\ncharacteristics of this tunneling in a variable asymmetry of latency\nbetween the sender and receiver, since we’re retrofitting bidirectional\npacket switching onto a request response protocol. That is, for the DNS\nserver to send data to a client it has to have a query to respond to. We\ncan’t wait to respond to a query until we have data, since recursive\nresolvers aggressively timeout and return a SERVFAIL in the case of a delayed reply. So we\nhave the client periodically poll the server with queries containing no\ndata, so the latency of the server to client link is bounded by the\nperiod of this polling.

\n

This is interesting as it allows us\nto bootstrap communication with a nameserver using nothing but\nDNS.

\n

Capability Interface

\n

DNS is an old protocol, and\nhas some baked-in limitations due to protocol\nossification (such as a maximum domain name length of 255 bytes).\nThe ‘back-end’ of the protocol, interactions between services under your\ncontrol, is easier to evolve. The AXFR zone transfers defined with the\nDomain Name System [2] are often replaced with some form of\ndatabase replication in nameserver implementations. Dynamic updates\n[3] using secret key transaction\nsignatures [4] are often eschewed in favour of\ncustom APIs1. While using these protocols allows\nan variety of nameserver implementations to interoperate, in practice\nthey are often replaced with custom solutions.

\n

We’ve experimented with a programmable\ninterface to the nameserver with Cap’n Proto capability-based\nRPCs. This creates capabilities for dynamically updating a domain, or\nreceiving a zonefile and dynamic updates as a secondary nameserver.\nPlease feel free to try deploying it for your own domain, and get in touch if you’d like to set up a reciprocal\nsecondarying relationship.

\n

Names Have Power

\n

Having a programmable interface\ninto the domain name system is powerful, because domain names are\npowerful. Domain names are the root of identity for the Internet\nprotocol suite. Federated communication networks derive user’s identify\nfrom domain names including Matrix, Mastodon, Bluesky’s AT Protocol\n[5], and good old E-Mail.

\n

The DNS is also used to prove\nowership of domains. The security of the modern internet is built on the\nTransport Layer Security (TLS) protocol [6], which uses X509 certificates signed\nby certificate authorities. The Internet Security Research Group\n(ISRG)’s Let’s Encrypt certificate authority (CA) provides the majority\nof the Internet’s certificates, over 500 million in 2025. Traditionally\nprovisioning a certificate was costly and manual process, but the\nAutomatic Certificate Management Environment (ACME) protocol [7] used by Let’s Encrypt allows for an\nautomated provisioning of certificates by proving ownership of a domain\nby displaying a token with one of a number of challenges; HTTP,\nTLS-ALPN, and DNS.

\n

Only the DNS challenge is possible\nif the address the domain name points to is not publicly accessible,\nwhich is often the case for remote and resource constrained devices\nbehind NATs or firewalls. However, it requires a complex\ndance of managing DNS UPDATE keys and specifying the subdomain and\nzone which it can modify. With our capability interface to the nameserver\nwe can expose fine-grained access control to provision a certificate for\na subdomain.

\n

Wake-on-DNS

\n

Motivated by a desire to curb the power\nuse of self-hosted services which are often idle for large periods of\ntime, such as storage servers, we implemented hibernia\nnameserver than can wake a machine up on a name resolution with Eon and\na OCaml Wake-on-LAN implementation.\nWe published this idea as ‘Carbon-aware Name\nResolution’ in LOCO2024.

\n

What next?

\n

I’m looking at extending this interface\nto support additional functionality for networked services such as\nstorage, identity, and more. Eilean is an\nattempt to parameterise a federated service deployment by a domain name\nleveraging the NixOS deployment system to do so, but it lacks a runtime\ncomponent.

\n
\n
\n
[1]
K. Sivaramakrishnan, S. Dolan, L. White, T.\nKelly, S. Jaffer, and A. Madhavapeddy, “Retrofitting effect\nhandlers onto OCaml,” in Proceedings of the 42nd\nACM SIGPLAN International Conference on Programming\nLanguage Design and Implementation, Jun. 2021,\npp. 206–221, doi: 10.1145/3453483.3454039\n[Online]. Available: https://dl.acm.org/doi/10.1145/3453483.3454039.\n[Accessed: Mar. 04, 2022]
\n
\n
\n
[2]
“Domain names - implementation and\nspecification,” Internet Engineering Task Force, Request for\nComments RFC 1035, Nov. 1987 [Online]. Available: https://datatracker.ietf.org/doc/rfc1035.\n[Accessed: May 15, 2022]
\n
\n
\n
[3]
P. A. Vixie, S. Thomson, Y. Rekhter, and J.\nBound, “Dynamic Updates in the Domain Name\nSystem (DNS UPDATE),” Internet Engineering\nTask Force, Request for Comments RFC 2136, Apr. 1997 [Online].\nAvailable: https://datatracker.ietf.org/doc/rfc2136.\n[Accessed: Jun. 30, 2023]
\n
\n
\n
[4]
D. E. Eastlake 3rd, Ó. Guðmundsson, P. A.\nVixie, and B. Wellington, “Secret Key Transaction\nAuthentication for DNS (TSIG),”\nInternet Engineering Task Force, Request for Comments RFC 2845, May 2000\n[Online]. Available: https://datatracker.ietf.org/doc/rfc2845.\n[Accessed: Oct. 22, 2023]
\n
\n
\n
[5]
M. Kleppmann et al., “Bluesky\nand the AT Protocol: Usable Decentralized Social\nMedia,” in Proceedings of the ACM Conext-2024\nWorkshop on the Decentralization of the\nInternet, Dec. 2024, pp. 1–7, doi: 10.1145/3694809.3700740\n[Online]. Available: http://arxiv.org/abs/2402.03239.\n[Accessed: Mar. 25, 2025]
\n
\n
\n
[6]
C. Allen and T. Dierks, “The TLS\nProtocol Version 1.0,” Internet Engineering Task Force,\nRequest for Comments RFC 2246, Jan. 1999 [Online]. Available: https://datatracker.ietf.org/doc/rfc2246.\n[Accessed: Mar. 25, 2025]
\n
\n
\n
[7]
R. Barnes, J. Hoffman-Andrews, D. McCarney, and\nJ. Kasten, “Automatic Certificate Management\nEnvironment (ACME),” Internet Engineering\nTask Force, Request for Comments RFC 8555, Mar. 2019 [Online].\nAvailable: https://datatracker.ietf.org/doc/rfc8555.\n[Accessed: Jun. 26, 2023]
\n
\n
\n\n\n\n\n
    \n
  1. Note that prior\nto TSIG introduced with DNSSEC, DNS UPDATEs and zone transfers were\ntypically enforced with IP-based access control.↩︎

  2. \n
", "content": "
\n \n Published 21 Apr 2025.\n \n \n
\n \n
Tags: research, projects, self-hosting.
\n \n \n\n

Eon\nis an Effects-based OCaml Nameserver using MirageOS’s functionally pure Domain Name\nSystem (DNS) library\nwith direct-style\nIO (as opposed to monadic\nIO) using OCaml 5’s\neffect handlers\n[1] created as the basis to implement\nsome of ideas from the Spatial Name\nSystem.

\n

DNS Tunnelling

\n

DNS is well-known to be used for data\nexfiltration and tunneling,\nsince DNS is one of the few protocols that’s almost always allowed\nthrough a firewall (at least through a recursive resolver) since it’s so\nfundamental to the operation of the Internet. I’ve implemented a\ntransport layer over DNS in\nEon, a simple netcat\nexample shows how this can be used to transport data using DNS queries.\nMany thanks to Paul-Elliot for\nhelping clean up the transport interface and making it more\nidiomatically functional. At the moment there’s no multiplexing – a\nserver can only handle one communication at a time, but that could\naddresses by adding a demultiplexing field (a ‘port’).

\n

The well-defined interfaces that\nOCaml gives us allows this to be combined in interesting ways, such as a\nshell\nover DNS (SoD), or an IP\ntunnel. Note that you wouldn’t want to use this in production\nwithout some form of encryption (maybe ocaml-tls?) and\nauthentication (e.g. public/private keys, or capabilities). A standalone\nexample of a capability interface to a shell can be found at capability-shell.

\n

There’s some interesting performance\ncharacteristics of this tunneling in a variable asymmetry of latency\nbetween the sender and receiver, since we’re retrofitting bidirectional\npacket switching onto a request response protocol. That is, for the DNS\nserver to send data to a client it has to have a query to respond to. We\ncan’t wait to respond to a query until we have data, since recursive\nresolvers aggressively timeout and return a SERVFAIL in the case of a delayed reply. So we\nhave the client periodically poll the server with queries containing no\ndata, so the latency of the server to client link is bounded by the\nperiod of this polling.

\n

This is interesting as it allows us\nto bootstrap communication with a nameserver using nothing but\nDNS.

\n

Capability Interface

\n

DNS is an old protocol, and\nhas some baked-in limitations due to protocol\nossification (such as a maximum domain name length of 255 bytes).\nThe ‘back-end’ of the protocol, interactions between services under your\ncontrol, is easier to evolve. The AXFR zone transfers defined with the\nDomain Name System [2] are often replaced with some form of\ndatabase replication in nameserver implementations. Dynamic updates\n[3] using secret key transaction\nsignatures [4] are often eschewed in favour of\ncustom APIs1. While using these protocols allows\nan variety of nameserver implementations to interoperate, in practice\nthey are often replaced with custom solutions.

\n

We’ve experimented with a programmable\ninterface to the nameserver with Cap’n Proto capability-based\nRPCs. This creates capabilities for dynamically updating a domain, or\nreceiving a zonefile and dynamic updates as a secondary nameserver.\nPlease feel free to try deploying it for your own domain, and get in touch if you’d like to set up a reciprocal\nsecondarying relationship.

\n

Names Have Power

\n

Having a programmable interface\ninto the domain name system is powerful, because domain names are\npowerful. Domain names are the root of identity for the Internet\nprotocol suite. Federated communication networks derive user’s identify\nfrom domain names including Matrix, Mastodon, Bluesky’s AT Protocol\n[5], and good old E-Mail.

\n

The DNS is also used to prove\nowership of domains. The security of the modern internet is built on the\nTransport Layer Security (TLS) protocol [6], which uses X509 certificates signed\nby certificate authorities. The Internet Security Research Group\n(ISRG)’s Let’s Encrypt certificate authority (CA) provides the majority\nof the Internet’s certificates, over 500 million in 2025. Traditionally\nprovisioning a certificate was costly and manual process, but the\nAutomatic Certificate Management Environment (ACME) protocol [7] used by Let’s Encrypt allows for an\nautomated provisioning of certificates by proving ownership of a domain\nby displaying a token with one of a number of challenges; HTTP,\nTLS-ALPN, and DNS.

\n

Only the DNS challenge is possible\nif the address the domain name points to is not publicly accessible,\nwhich is often the case for remote and resource constrained devices\nbehind NATs or firewalls. However, it requires a complex\ndance of managing DNS UPDATE keys and specifying the subdomain and\nzone which it can modify. With our capability interface to the nameserver\nwe can expose fine-grained access control to provision a certificate for\na subdomain.

\n

Wake-on-DNS

\n

Motivated by a desire to curb the power\nuse of self-hosted services which are often idle for large periods of\ntime, such as storage servers, we implemented hibernia\nnameserver than can wake a machine up on a name resolution with Eon and\na OCaml Wake-on-LAN implementation.\nWe published this idea as ‘Carbon-aware Name\nResolution’ in LOCO2024.

\n

What next?

\n

I’m looking at extending this interface\nto support additional functionality for networked services such as\nstorage, identity, and more. Eilean is an\nattempt to parameterise a federated service deployment by a domain name\nleveraging the NixOS deployment system to do so, but it lacks a runtime\ncomponent.

\n
\n
\n
[1]
K. Sivaramakrishnan, S. Dolan, L. White, T.\nKelly, S. Jaffer, and A. Madhavapeddy, “Retrofitting effect\nhandlers onto OCaml,” in Proceedings of the 42nd\nACM SIGPLAN International Conference on Programming\nLanguage Design and Implementation, Jun. 2021,\npp. 206–221, doi: 10.1145/3453483.3454039\n[Online]. Available: https://dl.acm.org/doi/10.1145/3453483.3454039.\n[Accessed: Mar. 04, 2022]
\n
\n
\n
[2]
“Domain names - implementation and\nspecification,” Internet Engineering Task Force, Request for\nComments RFC 1035, Nov. 1987 [Online]. Available: https://datatracker.ietf.org/doc/rfc1035.\n[Accessed: May 15, 2022]
\n
\n
\n
[3]
P. A. Vixie, S. Thomson, Y. Rekhter, and J.\nBound, “Dynamic Updates in the Domain Name\nSystem (DNS UPDATE),” Internet Engineering\nTask Force, Request for Comments RFC 2136, Apr. 1997 [Online].\nAvailable: https://datatracker.ietf.org/doc/rfc2136.\n[Accessed: Jun. 30, 2023]
\n
\n
\n
[4]
D. E. Eastlake 3rd, Ó. Guðmundsson, P. A.\nVixie, and B. Wellington, “Secret Key Transaction\nAuthentication for DNS (TSIG),”\nInternet Engineering Task Force, Request for Comments RFC 2845, May 2000\n[Online]. Available: https://datatracker.ietf.org/doc/rfc2845.\n[Accessed: Oct. 22, 2023]
\n
\n
\n
[5]
M. Kleppmann et al., “Bluesky\nand the AT Protocol: Usable Decentralized Social\nMedia,” in Proceedings of the ACM Conext-2024\nWorkshop on the Decentralization of the\nInternet, Dec. 2024, pp. 1–7, doi: 10.1145/3694809.3700740\n[Online]. Available: http://arxiv.org/abs/2402.03239.\n[Accessed: Mar. 25, 2025]
\n
\n
\n
[6]
C. Allen and T. Dierks, “The TLS\nProtocol Version 1.0,” Internet Engineering Task Force,\nRequest for Comments RFC 2246, Jan. 1999 [Online]. Available: https://datatracker.ietf.org/doc/rfc2246.\n[Accessed: Mar. 25, 2025]
\n
\n
\n
[7]
R. Barnes, J. Hoffman-Andrews, D. McCarney, and\nJ. Kasten, “Automatic Certificate Management\nEnvironment (ACME),” Internet Engineering\nTask Force, Request for Comments RFC 8555, Mar. 2019 [Online].\nAvailable: https://datatracker.ietf.org/doc/rfc8555.\n[Accessed: Jun. 26, 2023]
\n
\n
\n\n\n\n\n
    \n
  1. Note that prior\nto TSIG introduced with DNSSEC, DNS UPDATEs and zone transfers were\ntypically enforced with IP-based access control.↩︎

  2. \n
", "content_type": "html", "categories": [], "source": "https://ryan.freumh.org/atom.xml" }