Network

Give the guest's TCP/IP stack a way out.

import { createKernel, directBackend, wispBackend, DEFAULT_WISP_SERVERS } from "unkernel";

await createKernel({ net: directBackend() }); // Node: host sockets
await createKernel({ net: wispBackend(DEFAULT_WISP_SERVERS) }); // anywhere: a Wisp proxy

Networking is off unless you pass net. The guest runs Linux's own TCP/IP stack, with DHCP and DNS; the backend carries its connections.

  • directBackend() (Node) opens real sockets on the host.
  • wispBackend(servers) goes through a Wisp proxy. Browsers can't open raw TCP sockets, so this is the backend for the web.

Any object with connect and lookup methods can carry the guest's TCP and DNS, so you can write your own backend.

Note

No IPv6, no UDP beyond DHCP and DNS, and no inbound connections. To reach a server in the guest, use vm.connect() and vm.fetch(), which go over vsock.