# Network

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

---
icon: ph:globe-duotone
---

# Network

> Give the guest's TCP/IP stack a way out.

```js
import { createKernel, directBackend, wispBackend } from "unkernel";

await createKernel({ net: directBackend() }); // Node: host sockets
await createKernel({ net: wispBackend("wss://wisp.example/") }); // anywhere: your 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](https://github.com/MercuryWorkshop/wisp-protocol) proxy that you run or choose (one URL, or several to race). Browsers can't open raw TCP sockets, so this is the backend for the web. The proxy sees the host names and ports the guest connects to and plain-HTTP content; TLS from the guest is end to end. In Node, pass `headers` (e.g. `{ Origin: "https://your.site" }`) if your proxy checks the Origin.

Any object with `connect` and `lookup` methods can carry the guest's TCP and DNS, so you can write your own backend.

## Wisp limits

Wisp carries TCP streams and nothing else, and a guest program can tell:

- **No half-close.** When the guest shuts down its sending side (`shutdown(SHUT_WR)`, which `nc` does at the end of its input), the server is not told. A client that waits for the server to see end of file before it answers hangs, such as `echo hi | nc HOST PORT` against a server that reads to the end, or an HTTP/1.0 request with a body and no Content-Length.
- **No DNS.** Names resolve to placeholder addresses in 198.18.0.0/15, and the server resolves the name when the guest connects. Every name resolves (a bad one fails at connect time, as a reset), the address the guest sees is not the host's, and each name has one address.
- **No connect acknowledgement.** A connect succeeds at once; a refused or unreachable host shows up as a reset.

For real addresses, pass a resolver of your own, such as DNS over HTTPS. It takes a name and returns IPv4 addresses, or rejects with `{ code: "ENOTFOUND" }` for a name that does not exist:

```js
await createKernel({ net: wispBackend(servers, { lookup: (name) => resolveOverHttps(name) }) });
```

For half-close, use a backend of your own over a transport that has it.

::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()`](/sdk/vsock#reach-guest-servers), which go over vsock.
::
