Skip to main content

Multi-Network

Running multiple Autonomys networks or configurations on the same machine requires careful port separation to avoid conflicts.

Network Architecture

Mainnet Setup:

Testnet Setup:

Required Ports

Basic Node + Farmer Setup

NetworkConsensusDSNFarmerRPC
Mainnet3033330433305339944
Testnet3133331433315339955

Domain Operator Setup (Additional Ports)

NetworkDomain P2PОператорDomain RPC
Mainnet30334403339945
Testnet31334413339956
Separate RPC Ports Required
  • Mainnet: 9944 (consensus), 9945 (domain)
  • Testnet: 9955 (consensus), 9956 (domain)

Never use the same RPC port for multiple networks running simultaneously.

Complete Setup Guide

Step 1: Router Port Forwarding

Configure these port forwarding rules for each network:

Mainnet Port Forwarding:

Service NameExternal PortInternal IPInternal PortProtocol
Mainnet-Consensus30333Your IP30333TCP
Mainnet-DSN30433Your IP30433TCP
Mainnet-Farmer30533Your IP30533TCP
Mainnet-Domain-P2P30334Your IP30334TCP
Mainnet-Domain-Operator40333Your IP40333TCP

Testnet Port Forwarding:

Service NameExternal PortInternal IPInternal PortProtocol
Testnet-Consensus31333Your IP31333TCP
Testnet-DSN31433Your IP31433TCP
Testnet-Farmer31533Your IP31533TCP
Testnet-Domain-P2P31334Your IP31334TCP
Testnet-Domain-Operator41333Your IP41333TCP
Domain Operator Ports

The domain operator ports (30334/31334 and 40333/41333) are only needed if you're running domain operators on both networks. Skip these if you're only running basic node + farmer setups.

Step 2: Firewall Configuration

# Enable firewall
sudo ufw enable

# Mainnet ports
sudo ufw allow 30333/tcp comment 'Mainnet Consensus'
sudo ufw allow 30433/tcp comment 'Mainnet DSN'
sudo ufw allow 30533/tcp comment 'Mainnet Farmer'

# Mainnet domain operator ports (if needed)
sudo ufw allow 30334/tcp comment 'Mainnet Domain P2P'
sudo ufw allow 40333/tcp comment 'Mainnet Domain Operator'

# Testnet ports
sudo ufw allow 31333/tcp comment 'Testnet Consensus'
sudo ufw allow 31433/tcp comment 'Testnet DSN'
sudo ufw allow 31533/tcp comment 'Testnet Farmer'

# Testnet domain operator ports (if needed)
sudo ufw allow 31334/tcp comment 'Testnet Domain P2P'
sudo ufw allow 41333/tcp comment 'Testnet Domain Operator'

# RPC ports - local only
sudo ufw allow from 127.0.0.1 to any port 9944 proto tcp comment 'Mainnet Consensus RPC'
sudo ufw allow from 127.0.0.1 to any port 9945 proto tcp comment 'Mainnet Domain RPC'
sudo ufw allow from 127.0.0.1 to any port 9955 proto tcp comment 'Testnet Consensus RPC'
sudo ufw allow from 127.0.0.1 to any port 9956 proto tcp comment 'Testnet Domain RPC'

# Verify configuration
sudo ufw status numbered

Multi-Network Configurations

Mainnet + Testnet Simultaneously

Running both networks on the same machine:

# Mainnet Configuration
./subspace-node run \
--chain mainnet \
--base-path /var/lib/autonomys/mainnet \
--listen-on /ip4/0.0.0.0/tcp/30333 \
--dsn-listen-on /ip4/0.0.0.0/tcp/30433 \
--rpc-listen-on 127.0.0.1:9944

# Testnet Configuration (separate terminal)
./subspace-node run \
--chain chronos \
--base-path /var/lib/autonomys/testnet \
--listen-on /ip4/0.0.0.0/tcp/31333 \
--dsn-listen-on /ip4/0.0.0.0/tcp/31433 \
--rpc-listen-on 127.0.0.1:9955

# Mainnet Farmer (separate terminal)
./subspace-farmer farm \
--node-rpc-url ws://127.0.0.1:9944 \
--listen-on /ip4/0.0.0.0/tcp/30533 \
path=/farms/mainnet,size=100GiB

# Testnet Farmer (separate terminal)
./subspace-farmer farm \
--node-rpc-url ws://127.0.0.1:9955 \
--listen-on /ip4/0.0.0.0/tcp/31533 \
path=/farms/testnet,size=50GiB

Verification

Check Port Usage

# Check all Autonomys ports are listening
sudo netstat -tuln | grep -E "30333|31333|30433|31433|30533|31533|30334|31334|40333|41333|9944|9945|9955|9956"

# Expected output shows both networks:
# tcp 0 0 0.0.0.0:30333 LISTEN # Mainnet Consensus
# tcp 0 0 0.0.0.0:31333 LISTEN # Testnet Consensus
# tcp 0 0 0.0.0.0:30433 LISTEN # Mainnet DSN
# tcp 0 0 0.0.0.0:31433 LISTEN # Testnet DSN
# tcp 0 0 0.0.0.0:30533 LISTEN # Mainnet Farmer
# tcp 0 0 0.0.0.0:31533 LISTEN # Testnet Farmer
# tcp 0 0 0.0.0.0:30334 LISTEN # Mainnet Domain P2P (if running)
# tcp 0 0 0.0.0.0:31334 LISTEN # Testnet Domain P2P (if running)
# tcp 0 0 0.0.0.0:40333 LISTEN # Mainnet Domain Operator (if running)
# tcp 0 0 0.0.0.0:41333 LISTEN # Testnet Domain Operator (if running)
# tcp 0 0 127.0.0.1:9944 LISTEN # Mainnet Consensus RPC
# tcp 0 0 127.0.0.1:9945 LISTEN # Mainnet Domain RPC (if running)
# tcp 0 0 127.0.0.1:9955 LISTEN # Testnet Consensus RPC
# tcp 0 0 127.0.0.1:9956 LISTEN # Testnet Domain RPC (if running)

Test Connectivity

# Test mainnet connectivity
nc -zv localhost 30333
curl -s http://127.0.0.1:9944

# Test testnet connectivity
nc -zv localhost 31333
curl -s http://127.0.0.1:9955

# External connectivity test
nc -zv YOUR_PUBLIC_IP 30333
nc -zv YOUR_PUBLIC_IP 31333

Common Issues

Port Conflicts

Error: "Address already in use"

Solution:

# Find what's using the port
sudo lsof -i :30333

# Kill conflicting process or use different ports
./subspace-node --listen-on /ip4/0.0.0.0/tcp/32333

Data Directory Separation

Critical: Always use separate data directories:

# Correct - separate directories
--base-path /var/lib/autonomys/mainnet
--base-path /var/lib/autonomys/testnet

# Wrong - same directory causes corruption
--base-path /var/lib/autonomys # DON'T DO THIS

Best Practices

DO:

  • Use separate base paths for each network
  • Document your port assignments
  • Monitor resource usage closely
  • Test each network independently first
  • Use systemd services for production

DON'T:

  • Share data directories between networks
  • Run more instances than your hardware can handle
  • Expose RPC ports to the internet
  • Use overlapping port ranges
  • Forget to update firewall rules