Yggdrasil Mesh Network Implementation for NeXuS Medusa Proxy¶
Overview¶
Yggdrasil mesh network support has been successfully implemented for NeXuS Medusa Proxy. This provides encrypted IPv6 mesh networking capability, allowing nodes to communicate securely across the distributed mesh network.
What is Yggdrasil?¶
Yggdrasil is an encrypted IPv6 mesh network that provides: - End-to-end encrypted communication - Automatic routing and peer discovery - NAT traversal capabilities - Scalable mesh topology - No central authority or coordination
Every Yggdrasil node participates in routing traffic for the mesh, strengthening the network - perfectly aligned with NeXuS philosophy: Together Everyone Achieves More.
Files Created¶
1. /home/user/git/medusa-proxy/proxy/yggdrasil.py (152 lines)¶
Yggdrasil Service Class - Implements the Yggdrasil daemon following the established Service pattern.
Key Features:
- Multi-instance support: Each Yggdrasil instance gets unique admin port (9001+)
- Peer configuration: Connect to mesh via environment variable YGGDRASIL_PEERS
- Health checking: Queries admin API to verify mesh connectivity and peer count
- IPv6 address display: Shows assigned mesh IPv6 address in status output
- Automatic peer discovery: Supports multicast beacons for local network peers
Configuration Options:
- peers: List of peer addresses to connect to (comma-separated)
- listen: Listen address for incoming connections (default: tcp://0.0.0.0:6000+id)
- admin_listen: Admin API endpoint (default: tcp://localhost:9001+id)
2. /home/user/git/medusa-proxy/templates/yggdrasil.conf¶
Yggdrasil Configuration Template - Jinja2 template for generating Yggdrasil daemon config.
Configuration Sections: - Listen addresses: Where to accept incoming peering connections - Peer list: Bootstrap peers to connect to the mesh - Admin API: JSON-RPC endpoint for health checks and monitoring - Interface settings: TUN adapter configuration with MTU 65535 - Session firewall: Disabled by default (mesh already encrypted) - Node info: Metadata identifying this as a NeXuS node - Multicast discovery: Automatic peer discovery on local networks
3. Updated /home/user/git/medusa-proxy/proxy/__init__.py¶
Added Yggdrasil class to module exports for easy importing.
Environment Variables¶
Configure Yggdrasil instances via environment variables:
# Number of Yggdrasil instances (default: 1)
YGGDRASILS=3
# Comma-separated list of peer addresses to connect to
YGGDRASIL_PEERS="tcp://1.2.3.4:5678,tls://[2001:db8::1]:9999,tcp://peer.example.com:6001"
Architecture¶
Service Pattern Compliance¶
The implementation follows the established Service base class pattern:
- Initialization: Creates required directories (
/var/lib/yggdrasil,/var/run/yggdrasil,/var/log/yggdrasil) - Configuration: Generates config from template in
/etc/yggdrasil/yggdrasil-{id}.conf - Process management: Starts daemon with unique config file
- Health checking: Queries admin API for mesh connectivity status
- Logging: Output to
/var/log/yggdrasil/yggdrasil-{id}.log
Multi-Instance Design¶
Each Yggdrasil instance operates independently:
Instance 0: Admin API on port 9001, Peering on port 6000
Instance 1: Admin API on port 9002, Peering on port 6001
Instance 2: Admin API on port 9003, Peering on port 6002
...
Health Checking¶
The working property performs comprehensive health checks:
- Process check: Verifies daemon is running (PID exists)
- Admin API query: Calls
getSelfto get IPv6 address - Peer status: Calls
getPeersto count active mesh connections - Graceful degradation: Returns true if process running even if API fails
Health Check Output:
Integration with Medusa Proxy¶
Import and Usage¶
from proxy import Yggdrasil
# Create Yggdrasil instance with default settings
ygg = Yggdrasil()
# Create with custom peers
ygg = Yggdrasil(peers=["tcp://peer1.example.com:6000", "tls://peer2.example.com:6001"])
# Check if mesh is working
if ygg.working:
print("Connected to Yggdrasil mesh!")
Orchestration (for start.py)¶
The implementation is ready for orchestration integration:
# Create multiple Yggdrasil instances based on YGGDRASILS env var
yggdrasil_count = int(os.environ.get("YGGDRASILS", "1"))
yggdrasils = []
for i in range(yggdrasil_count):
ygg = Yggdrasil()
yggdrasils.append(ygg)
# Health check all instances
for ygg in yggdrasils:
ygg.working # Logs connectivity status
NeXuS Philosophy Alignment¶
Together Everyone Achieves More¶
Yggdrasil embodies NeXuS core principles:
- Decentralization: No central authority, pure mesh topology
- Participation strengthens network: Every node routes for others
- Privacy by design: End-to-end encrypted IPv6 communication
- Censorship resistance: Multiple paths through the mesh
- Anonymous connectivity: No IP address exposure outside mesh
Mesh Participation¶
Unlike Tor (anonymous egress) or I2P (internal services), Yggdrasil is about mesh participation: - Your node helps route traffic for others - More nodes = stronger, faster, more resilient mesh - Automatic routing finds optimal paths - Self-healing network topology
Technical Details¶
Admin API (JSON-RPC)¶
Yggdrasil provides a JSON-RPC admin API for monitoring:
Available endpoints:
- getSelf: Get node's IPv6 address and public key
- getPeers: List active peering connections
- getSwitchPeers: Get routing table peers
- getDHT: View distributed hash table state
- getSessions: Active encrypted sessions
Example health check:
import requests
response = requests.post(
"http://localhost:9001",
json={"request": "getSelf"},
timeout=5
)
data = response.json()
ipv6_address = data["response"]["address"]
IPv6 Mesh Addressing¶
Yggdrasil assigns each node a cryptographically derived IPv6 address:
- Format: 200:xxxx:xxxx:xxxx:xxxx:xxxx:xxxx:xxxx
- Range: 200::/7 (reserved for Yggdrasil)
- Derived from node's public key
- Persistent across restarts
- Globally unique and verifiable
Multicast Peer Discovery¶
Yggdrasil can discover peers on local networks automatically: - Broadcasts beacon packets on LAN - Other nodes respond with their peering info - Automatic mesh formation in local environments - No manual peer configuration needed for LAN
Security Considerations¶
Encryption¶
- Transport encryption: All peering connections encrypted
- End-to-end encryption: IPv6 packets encrypted hop-to-hop through mesh
- Key exchange: Automatic public key cryptography
- Forward secrecy: Session keys rotated regularly
Privacy¶
- No IP exposure: Your real IP only visible to direct peers
- Traffic mixing: Packets routed through multiple nodes
- Metadata protection: Source/destination hidden from intermediate nodes
- NAT traversal: Can connect through restrictive networks
Trust Model¶
- Direct peers: You must trust your direct peering connections
- Mesh routing: No trust needed for routing nodes (encrypted tunnels)
- Peer verification: Public keys prevent man-in-the-middle attacks
- Bootstrap peers: Initial peers should be from trusted sources
Deployment Requirements¶
System Dependencies¶
Yggdrasil daemon must be installed:
# Alpine Linux
apk add yggdrasil
# Debian/Ubuntu
apt-get install yggdrasil
# From source
go install github.com/yggdrasil-network/yggdrasil-go/cmd/yggdrasil@latest
Network Requirements¶
- Inbound connections: Optional but recommended (helps mesh)
- Outbound connections: Required to connect to peers
- UDP/TCP: Supports both (TCP more reliable through NAT)
- TLS option: Available for additional transport security
- IPv6: Creates virtual IPv6 interface (no global IPv6 required)
Peer Discovery¶
Public Peers: Available at https://github.com/yggdrasil-network/public-peers
Example peer addresses:
Example Configurations¶
Minimal Configuration (Local Development)¶
Automatically discovers other Yggdrasil nodes on LAN.
Production Configuration (Public Peers)¶
# Multiple instances for redundancy
YGGDRASILS=3
# Connect to public bootstrap peers
YGGDRASIL_PEERS="tcp://54.37.137.221:11129,tcp://45.147.198.155:6010,tls://102.223.180.74:993"
High Availability Configuration¶
# Many instances, diverse peer set
YGGDRASILS=5
# Mix of geographic locations and protocols
YGGDRASIL_PEERS="tcp://us-peer.example.com:6000,tls://eu-peer.example.com:6001,tcp://asia-peer.example.com:6002"
Monitoring and Troubleshooting¶
Health Check Output¶
Successful connection:
Process running but API not ready:
Connection issues:
Log Files¶
Each instance logs to separate file:
Common Issues¶
No peers connecting: - Check firewall allows inbound on listen port (6000+) - Verify peer addresses are correct and reachable - Try different peers from public peer list
Admin API timeout: - Daemon may still be starting up - Check log file for errors - Verify admin port not blocked by firewall
IPv6 connectivity issues:
- Yggdrasil creates virtual IPv6 (doesn't need global IPv6)
- Check TUN interface created: ip addr show tun0
- Verify routing: ip -6 route show
Future Enhancements¶
Potential improvements for Yggdrasil integration:
- Dynamic peer management: Automatically add/remove peers
- Geographic distribution: Select peers from different regions
- Latency optimization: Prefer low-latency peers
- Bandwidth monitoring: Track mesh traffic statistics
- Mesh visualization: Map network topology
- Integration with routing: Use Yggdrasil for inter-node communication
References¶
- Official website: https://yggdrasil-network.github.io/
- GitHub: https://github.com/yggdrasil-network/yggdrasil-go
- Public peers: https://github.com/yggdrasil-network/public-peers
- Documentation: https://yggdrasil-network.github.io/configuration.html
- Admin API: https://yggdrasil-network.github.io/admin.html
Summary¶
Yggdrasil mesh network support is now fully implemented in NeXuS Medusa Proxy:
- ✅ Service class following established patterns
- ✅ Configuration template with sensible defaults
- ✅ Health checking via admin API
- ✅ Multi-instance support
- ✅ Environment variable configuration
- ✅ Exported in proxy module
Together Everyone Achieves More - Every Yggdrasil node strengthens the mesh! 🔗