The AutoNATv2 service implements the AutoNAT v2 protocol to confirm whether addresses the node is listening on are dialable by remote peers.
It does not implement NAT hole punching.
import { createLibp2p } from 'libp2p'import { autoNATv2 } from '@libp2p/autonat-v2'const node = await createLibp2p({ // ...other options services: { autoNAT: autoNATv2() }})// observe per-address reachability changes as they are probednode.services.autoNAT.addEventListener('address:reachable', (evt) => { console.info(evt.detail.addr, 'is externally dialable')}) Copy
import { createLibp2p } from 'libp2p'import { autoNATv2 } from '@libp2p/autonat-v2'const node = await createLibp2p({ // ...other options services: { autoNAT: autoNATv2() }})// observe per-address reachability changes as they are probednode.services.autoNAT.addEventListener('address:reachable', (evt) => { console.info(evt.detail.addr, 'is externally dialable')})
The AutoNATv2 service implements the AutoNAT v2 protocol to confirm whether addresses the node is listening on are dialable by remote peers.
It does not implement NAT hole punching.
Example