关于 hybrid-cloud-networking
面向需要连接本地数据中心与 AWS、Azure 或 GCP 的团队,介绍 VPN 和专用连接方案,以及路由、安全、可用性、监控与成本考量。
主要功能
- 01VPN 与专用连接方案
- 02混合网络模式
- 03BGP 路由指南
- 04安全建议
- 05高可用性与监控
适用场景
- 01连接本地数据中心与云
- 02规划多云连接
- 03设计冗余混合连接
- 04排查 VPN 与 BGP 链路
安装
复制下面的命令,在终端中运行。
$
npx skills add https:/ / github.com/ ormus-solutions/ libreuiux-claude-code --skill hybrid-cloud-networking安装后在 Claude Code 中输入/hybrid-cloud-networking确认已加载。
详细介绍
混合云网络
使用 VPN、Direct Connect 和 ExpressRoute,在本地环境与云环境之间配置安全、高性能的连接。
目的
在本地数据中心与云服务提供商(AWS、Azure、GCP)之间建立安全、可靠的网络连接。
使用场景
- 将本地环境连接到云端
- 将数据中心扩展到云端
- 实施混合云主动-主动配置
- 满足合规要求
- 逐步迁移到云端
连接选项
AWS 连接
1. 站点到站点 VPN
- 通过互联网使用 IPSec VPN
- 每条隧道最高 1.25 Gbps
- 适用于中等带宽,成本效益高
- 延迟较高,依赖互联网
resource "aws_vpn_gateway" "main" {
vpc_id = aws_vpc.main.id
tags = {
Name = "main-vpn-gateway"
}
}
resource "aws_customer_gateway" "main" {
bgp_asn = 65000
ip_address = "203.0.113.1"
type = "ipsec.1"
}
resource "aws_vpn_connection" "main" {
vpn_gateway_id = aws_vpn_gateway.main.id
customer_gateway_id = aws_customer_gateway.main.id
type = "ipsec.1"
static_routes_only = false
}
2. AWS Direct Connect
- 专用网络连接
- 1 Gbps 至 100 Gbps
- 延迟较低,带宽稳定
- 成本较高,需要预留设置时间
**参考:**请参阅 references/direct-connect.md
Azure 连接
1. 站点到站点 VPN
resource "azurerm_virtual_network_gateway" "vpn" {
name = "vpn-gateway"
location = azurerm_resource_group.main.location
resource_group_name = azurerm_resource_group.main.name
type = "Vpn"
vpn_type = "RouteBased"
sku = "VpnGw1"
ip_configuration {
name = "vnetGatewayConfig"
public_ip_address_id = azurerm_public_ip.vpn.id
private_ip_address_allocation = "Dynamic"
subnet_id = azurerm_subnet.gateway.id
}
}
2. Azure ExpressRoute
- 通过连接提供商建立专用连接
- 最高 100 Gbps
- 延迟低,可靠性高
- 全球连接需支付额外费用
GCP 连接
1. Cloud VPN
- IPSec VPN(Classic 或 HA VPN)
- HA VPN:99.99% SLA
- 每条隧道最高 3 Gbps
2. Cloud Interconnect
- 专用连接(10 Gbps、100 Gbps)
- 合作伙伴连接(50 Mbps 至 50 Gbps)
- 延迟低于 VPN
混合网络模式
模式 1:中心辐射式
On-Premises Datacenter
↓
VPN/Direct Connect
↓
Transit Gateway (AWS) / vWAN (Azure)
↓
├─ Production VPC/VNet
├─ Staging VPC/VNet
└─ Development VPC/VNet
模式 2:多区域混合云
On-Premises
├─ Direct Connect → us-east-1
└─ Direct Connect → us-west-2
↓
Cross-Region Peering
模式 3:多云混合云
On-Premises Datacenter
├─ Direct Connect → AWS
├─ ExpressRoute → Azure
└─ Interconnect → GCP
路由配置
BGP 配置
On-Premises Router:
- AS Number: 65000
- Advertise: 10.0.0.0/8
Cloud Router:
- AS Number: 64512 (AWS), 65515 (Azure)
- Advertise: Cloud VPC/VNet CIDRs
路由传播
- 在路由表上启用路由传播
- 使用 BGP 进行动态路由
- 实施路由筛选
- 监控路由通告
安全最佳实践
- 使用专用连接(Direct Connect/ExpressRoute)
- 为 VPN 隧道启用加密
- 使用 VPC 端点以避免经由互联网路由
- 配置网络 ACL 和安全组
- 启用 VPC Flow Logs 进行监控
- 实施 DDoS 防护
- 使用 PrivateLink/Private Endpoints
- 使用 CloudWatch/Monitor 监控连接
- 实施冗余(双隧道)
- 定期进行安全审计
高可用性
双 VPN 隧道
resource "aws_vpn_connection" "primary" {
vpn_gateway_id = aws_vpn_gateway.main.id
customer_gateway_id = aws_customer_gateway.primary.id
type = "ipsec.1"
}
resource "aws_vpn_connection" "secondary" {
vpn_gateway_id = aws_vpn_gateway.main.id
customer_gateway_id = aws_customer_gateway.secondary.id
type = "ipsec.1"
}
主动-主动配置
- 从不同位置建立多条连接
- 使用 BGP 自动故障转移
- 使用等价多路径(ECMP)路由
- 监控所有连接的运行状况
监控与故障排除
关键指标
- 隧道状态(正常/中断)
- 入站/出站字节数
- 丢包率
- 延迟
- BGP 会话状态
故障排除
# AWS VPN
aws ec2 describe-vpn-connections
aws ec2 get-vpn-connection-telemetry
# Azure VPN
az network vpn-connection show
az network vpn-connection show-device-config-script
成本优化
- 根据流量选择合适的连接规格
- 为低带宽工作负载使用 VPN
- 通过更少的连接整合流量
- 尽量减少数据传输成本
- 为高带宽场景使用 Direct Connect
- 实施缓存以减少流量
参考文件
references/vpn-setup.md- VPN 配置指南references/direct-connect.md- Direct Connect 设置
相关技能
multi-cloud-architecture- 用于架构决策terraform-module-library- 用于 IaC 实施
评论
支持 Markdown