Skip to content

Instantly share code, notes, and snippets.

@gnh1201
Created August 19, 2023 10:37
Show Gist options
  • Save gnh1201/6ce151d30266fb59dd31effac3746d6e to your computer and use it in GitHub Desktop.
Save gnh1201/6ce151d30266fb59dd31effac3746d6e to your computer and use it in GitHub Desktop.
IPFS configuration with NAT

IPFS configuration with NAT

IPFS (here, referring to go-ipfs or kubo) already supports NAT environments, but there is a lack of documentation explaining this, leading to difficulties in configuration for many users.

Below is an configuration example for supporting NAT environments in IPFS.

{
	"Addresses": {
		"API": "/ip4/0.0.0.0/tcp/5001",
		"Announce": [
			"/ip4/[YOUR_PUBLIC_IP]/tcp/4001",
			"/ip4/[YOUR_PUBLIC_IP]/udp/4001/quic",
			"/ip4/[YOUR_PUBLIC_IP]/udp/4001/quic-v1",
			"/ip4/[YOUR_PUBLIC_IP]/udp/4001/quic-v1/webtransport"
		],
		"AppendAnnounce": [],
		"Gateway": "/ip4/0.0.0.0/tcp/8080",
		"NoAnnounce": [],
		"Swarm": [
			"/ip4/0.0.0.0/tcp/4001",
			"/ip6/::/tcp/4001",
			"/ip4/0.0.0.0/udp/4001/quic",
			"/ip4/0.0.0.0/udp/4001/quic-v1",
			"/ip4/0.0.0.0/udp/4001/quic-v1/webtransport",
			"/ip6/::/udp/4001/quic",
			"/ip6/::/udp/4001/quic-v1",
			"/ip6/::/udp/4001/quic-v1/webtransport"
		]
	}
}

Afterwards, you can simply port forward 4001/tcp and 4001/udp on your router or firewall.

Thank you.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment