# lan-network

> Best-effort discovery of the machine's default gateway and local network IP exclusively with UDP sockets.

Latest version **0.2.1** (published 2026-04-06) · MIT license · 0 weekly downloads

## Install

```sh
npm install lan-network
pnpm add lan-network
yarn add lan-network
bun add lan-network
```

Provides the command `lan-network`.

## Health

**Score 65/100 (B)** — status: active.

Positive: has types; esm support; no vulnerabilities; has provenance; high quality score.

Warnings: low downloads; pre 1.0.

## Facts

| | |
|---|---|
| Version | 0.2.1 |
| Published | 2026-04-06 |
| First published | 2025-02-21 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Dependencies | 0 |
| Unpacked size | 25.1 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Provenance | attested (GitHub Actions) |
| GitHub stars | 2 |
| Author | Phil Pluckthun |
| Maintainers | philpl |

## Links

- npm: https://www.npmjs.com/package/lan-network
- Repository: https://github.com/kitten/lan-network
- Homepage: https://github.com/kitten/lan-network#readme
- Issues: https://github.com/kitten/lan-network/issues
- npm.io page: https://npm.io/package/lan-network

## Recent versions

- 0.2.1 (latest) — 2026-04-06
- 0.2.1-canary-ee60e1415dc323843c07e3a0d0acda998ed2d9ae (canary) — 2026-04-06
- 0.2.1-canary-6891e4df9d8befaee243b6237d4741820d79bfa4 — 2026-04-06
- 0.2.0 — 2026-02-06
- 0.1.7 — 2025-05-22
- 0.1.7-canary-f5b38f9c48dfd16e7bc45aa611b9929bdd3f316a — 2025-05-22
- 0.1.6 — 2025-05-08
- 0.1.6-canary-6bf9bd3fa22667f4f84a7f3b5dc0dff433c3abab — 2025-05-08
- 0.1.5 — 2025-05-02
- 0.1.5-canary-ede331e7d746e36060fa7e8846549d035b41480d — 2025-05-02
- 0.1.4 — 2025-02-21
- 0.1.3 — 2025-02-21
- 0.1.3-canary-ab5c9378a15bb3a37bafc63289407ebf780f01d2 — 2025-02-21
- 0.1.2 — 2025-02-21
- 0.1.2-canary-e5785771c0d7af62c252ba9ca881737ee88a72a4 — 2025-02-21
- … 3 more at https://npm.io/package/lan-network/versions

## README

# lan-network

**Best-effort discovery of the machine's default gateway and local network IPv4 address exclusively with UDP sockets.**

This utility attempts to determine the interface and IPv4 address of a machine
on the local network. It'll attempt to determine the default gateway and
return the corresponding network interface assignment, both when the network
is online and offline.

The LAN Network it attempts to pick is the one that the machine uses to connect
to the internet. Determining it is useful to pick the machine's IP address that
is generally used to connect to it from other devices on the network.

`lanNetwork()` makes three separate attempts to guess the local network:

1. Create a socket to a publicly routed IP, and return the assignment matching the socket's local address
2. Broadcast DHCP discovery packets on all routable network assignments and listen for replies
3. Highest priority assignment

`lanNetworkSync()` does the same synchronously by spawning a child process
and blocking until a result is determined. Using this method is generally
not recommended.

---
_Source: https://npm.io/package/lan-network · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
