-
Notifications
You must be signed in to change notification settings - Fork 379
Tailscale Integration with Management Network #2928
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR introduces comprehensive Tailscale VPN integration to containerlab, enabling secure remote access to lab management networks. The integration includes automatic deployment of Tailscale containers as infrastructure, optional DNS services with CoreDNS and MagicDNS support, and advanced features like 1:1 NAT with DNS doctoring for IP translation.
Key Changes
- Tailscale VPN Integration: Automatic deployment and lifecycle management of Tailscale containers with route advertisement, configurable addressing, ACL tags, and NAT support
- DNS Services: CoreDNS integration with automatic node record generation, split DNS support via Tailscale MagicDNS, and intelligent DNS proxy for NAT scenarios
- Infrastructure Management: New infrastructure container concept with dedicated lifecycle methods and labeling system to distinguish from user nodes
Reviewed Changes
Copilot reviewed 16 out of 16 changed files in this pull request and generated 12 comments.
Show a summary per file
| File | Description |
|---|---|
types/types.go |
Defines TailscaleConfig and TailscaleDNSConfig structs with comprehensive configuration options |
utils/ip.go |
Adds LastHostIPInSubnet helper function to calculate container IP addresses |
runtime/docker/tailscale.go |
Core implementation (~1000 lines) handling Tailscale deployment, DNS setup, and container management |
runtime/docker/scripts/nat-setup.sh |
Embedded shell script for iptables NETMAP rules to enable 1:1 NAT |
runtime/docker/scripts/dns-proxy.py |
Python DNS proxy with intelligent IP rewriting based on client source address |
runtime/docker/scripts/coredns-install.sh |
CoreDNS installation script with optional Python dependency |
runtime/docker/scripts/Corefile.tmpl |
CoreDNS configuration template for lab domain resolution |
runtime/docker/scripts/README.md |
Comprehensive documentation for embedded scripts architecture |
core/clab.go |
Infrastructure lifecycle methods (Deploy/Destroy/UpdateDNS) |
core/deploy.go |
Integration point for infrastructure deployment after network creation |
core/destroy.go |
Integration point for infrastructure cleanup before network deletion |
core/config.go |
Infrastructure container exclusion from uniqueness checks |
constants/labels.go |
New IsInfrastructure label constant |
docs/manual/tailscale.md |
Extensive documentation (795 lines) covering configuration, use cases, and troubleshooting |
docs/manual/network.md |
Brief introduction to Tailscale feature with reference to full documentation |
mkdocs.yml |
Navigation menu entry for Tailscale documentation |
Co-authored-by: Copilot <[email protected]>
|
Thanks @hellt |
|
@tvarohohlavy looks cool, I will try this one out :) |
Tailscale VPN Integration with MagicDNS Support
Overview
This PR adds native Tailscale VPN integration to containerlab, enabling secure remote access to lab management networks from anywhere. The integration includes optional DNS server support with intelligent DNS doctoring for seamless name resolution via Tailscale's MagicDNS feature.
Features
🔐 Tailscale VPN Integration
clab-is-infrastructurelabel for extensibility🌐 DNS Services
<node-name>.<lab-name>.clab🛠️ Advanced Features
Configuration
Basic Setup
With MagicDNS
Advanced Configuration with NAT and DNS Doctoring
Architecture
DNS Integration
UpdateInfrastructureDNS()called after all nodes deployedDNS Architecture with Doctoring
How it works:
Files Changed
Core Implementation
types/types.go- AddedTailscaleConfigandTailscaleDNSConfigstructsconstants/labels.go- AddedIsInfrastructurelabel constantclab/clab.go- AddedDeployInfrastructure(),DestroyInfrastructure(),UpdateInfrastructureDNS()clab/deploy.go- Integrated infrastructure deployment and DNS updatescore/destroy.go- Integrated infrastructure cleanupclab/config.go- Generic infrastructure container detectionutils/ip.go- AddedLastHostIPInSubnet()helperScript Files (NEW)
runtime/docker/scripts/nat-setup.sh- NAT configuration with iptables NETMAPruntime/docker/scripts/dns-proxy.py- Python DNS proxy with intelligent doctoringruntime/docker/scripts/coredns-install.sh- Optimized CoreDNS installationruntime/docker/scripts/README.md- Comprehensive script documentationDocumentation
docs/manual/network.md- Brief Tailscale introduction with referencedocs/manual/tailscale.md- Comprehensive guide (NEW)mkdocs.yml- Added Tailscale VPN navigation entryUsage Examples
Remote Lab Access
With MagicDNS
Testing
Tested with:
Known Limitations
in-addr.arpazones. This requires further investigation.Documentation
Comprehensive documentation includes:
Migration Path
N/A - New feature with opt-in configuration. Fully backward compatible.
Future Enhancements
Potential follow-ups:
Related Issues: #2396 #1394