Tailscale Integration with Management Network#2928
Open
tvarohohlavy wants to merge 10 commits intosrl-labs:mainfrom
Open
Tailscale Integration with Management Network#2928tvarohohlavy wants to merge 10 commits intosrl-labs:mainfrom
tvarohohlavy wants to merge 10 commits intosrl-labs:mainfrom
Conversation
Contributor
There was a problem hiding this comment.
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 <175728472+Copilot@users.noreply.github.com>
Author
|
Thanks @hellt |
Member
|
@tvarohohlavy looks cool, I will try this one out :) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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