# IPv6 address distance

`ipv6-address-distance` · version 1.0.0 · URLs & IP addresses · free, no key needed

Compute the signed integer distance between two IPv6 addresses (address_b minus address_a).

**Use when you need to: ipv6 address distance · ipv6 address difference · how many ipv6 addresses apart.**

## Supported

- ipv6 address distance
- ipv6 address difference
- how many ipv6 addresses apart

## Not supported

- IPv4

## Behavior

- address_a and address_b accept any RFC 4291 textual form (see ipv6-parse).
- difference is the canonical signed decimal integer string equal to address_b's 128-bit value minus address_a's, in range -340282366920938463463374607431768211455..340282366920938463463374607431768211455.

## Input

- `address_a` (string, required): max length 45
- `address_b` (string, required): max length 45

## Output

- `difference` (string, required): max length 40; pattern `^-?(0|[1-9][0-9]*)$`

## Limits

- max address length: 45

## Example

Request input:

```json
{
  "address_a": "2001:db8::1",
  "address_b": "2001:db8::b"
}
```

Response:

```json
{
  "result": {
    "difference": "10"
  }
}
```

## How to call it

### MCP

Connect `https://computefirst.net/mcp` ([setup](/docs#connect)), then call `execute` with:

```json
{
  "id": "ipv6-address-distance",
  "version": "1.0.0",
  "input": {
    "address_a": "2001:db8::1",
    "address_b": "2001:db8::b"
  }
}
```

### HTTP (no key)

```sh
curl -X POST https://computefirst.net/v1/tools/ipv6-address-distance/versions/1.0.0/execute \
  -H "Content-Type: application/json" \
  -d '{"address_a":"2001:db8::1","address_b":"2001:db8::b"}'
```

The machine-readable contract is at [/v1/tools/ipv6-address-distance/versions/1.0.0](/v1/tools/ipv6-address-distance/versions/1.0.0).

### CLI

```sh
node cli.mjs run ipv6-address-distance 1.0.0 --input input.json --base-url https://computefirst.net
```

Get the client at [/clients/cli/](/clients/cli/).

## Related tools

- [IPv4 address distance](/tools/ipv4-address-distance): Compute the signed integer distance between two IPv4 addresses (address_b minus address_a).
- [IPv6 address compare](/tools/ipv6-address-compare): Compare two IPv6 addresses by their numeric 128-bit value.
- [IPv4 address compare](/tools/ipv4-address-compare): Compare two canonical IPv4 addresses by their numeric uint32 value.
- [IPv6 address classify](/tools/ipv6-address-classify): Classify an IPv6 address against the static IANA IPv6 special-purpose address registry.
- [IPv6 address offset](/tools/ipv6-address-offset): Add a signed integer offset to an IPv6 address, throwing if the result leaves the IPv6 address space.
- [IPv6 in CIDR](/tools/ipv6-in-cidr): Test whether an IPv6 address lies in a CIDR prefix whose host bits are zero.
