简体   繁体   English

通过VPC将AWS VPN NAT转换为AWS IOT

[英]NAT AWS VPN to AWS IOT via VPC

I have a private M2M GSM network for my company devices. 我的公司设备有一个专用的M2M GSM网络。 I want to send traffic from my devices to AWS IOT but the M2M provider doesn't allow internet access from its sim cards, it only provide an IPSec connexion to aa private network. 我想将流量从设备发送到AWS IOT,但是M2M提供商不允许从其SIM卡访问互联网,它仅向私有网络提供IPSec连接。

I had now problem configuring the IPSec connexion to an AWS VPC and my sims can successfully ping all instance in my AWS VPC. 我现在在配置与AWS VPC的IPSec连接时遇到问题,我的模拟市民可以成功ping通我的AWS VPC中的所有实例。 However what I want is for my sims to access AWS IOT. 但是,我要让我的模拟市民访问AWS IOT。

What I did: 我做了什么:

  1. I configured my VPN with AWS third scenario . 我使用AWS第三种方案配置了VPN。 I have a public network with CIDR 192.168.0.0/24 and a private network with CIDR 192.168.1.0/24. 我有一个具有CIDR 192.168.0.0/24的公用网络和一个具有CIDR 192.168.1.0/24的专用网络。 My VPN has a static route CIDR 10.1.128.0/14 for my M2M network. 我的VPN对我的M2M网络有一条静态路由CIDR 10.1.128.0/14。
  2. Then I launched an EC2 Nat Instance inside my public network. 然后,我在公共网络内启动了一个EC2 Nat实例。
  3. I added a routing rule to my VPC main routing table to route trafic to 0.0.0.0/0 to my NAT instance. 我在VPC主路由表中添加了路由规则,以将流量0.0.0.0/0路由到NAT实例。
  4. I launched an EC2 instance in my VPC's private network and try to access internet from it, this work and I can see trafic going throung my nat instance. 我在VPC的专用网络中启动了一个EC2实例,并尝试通过它访问Internet,这项工作使我可以看到流量在我的nat实例中蔓延。 So I assume my nat and routing is well configured. 因此,我假设我的nat和路由配置正确。

However I still can't manage to access internet from my sim cards, traffic isn't even routed to my NAT instance. 但是我仍然无法通过SIM卡访问互联网,流量甚至都没有路由到我的NAT实例。 According to John Rotenstein's answer VPN traffic will not use my routing rule. 根据John Rotenstein的回答, VPN流量不会使用我的路由规则。

Does AWS VPN drop traffic which is not destinated to the VPC's or VPN's CIDR ? AWS VPN是否会丢弃并非发往VPC或VPN的CIDR的流量? Is there a security reason for that ? 有安全原因吗? If that's the case is there a way to customize routing rules for the VPN's traffic ? 如果是这样,是否有一种方法可以自定义VPN流量的路由规则? Or is the only solution to use a custom VPN within an EC2 instance ? 还是在EC2实例中使用自定义VPN的唯一解决方案?

Thank you for your help. 谢谢您的帮助。

I added a routing rule to my VPC main routing table to route trafic to 0.0.0.0/0 to my NAT instance. 我在VPC主路由表中添加了路由规则,以将流量0.0.0.0/0路由到NAT实例。

It is an understandable misconception that the "main" route table of a VPC impacts traffic coming in from a VPC hardware VPN. 可以理解的误解是,VPC的“主”路由表会影响来自VPC硬件VPN的流量。 It doesn't. 没有。 There is no route table that applies to such traffic, only the implicit target of the VPC subnets. 没有适用于此类流量的路由表,仅适用于VPC子网的隐式目标。 Only the assigned CIDR blocks can be reached from such a VPN. 从这样的VPN中只能访问分配的CIDR块。

Does AWS VPN drop traffic which is not destinated to the VPC's or VPN's CIDR? AWS VPN会丢弃不是发往VPC或VPN的CIDR的流量吗? Is there a security reason for that? 有安全原因吗?

Yes, that traffic is dropped. 是的,该流量被丢弃。

It probably not specifically for security reasons... it's just the way the service was designed to work. 可能不是出于安全原因而专门设计的……这只是服务设计为工作的方式。 Managed VPN connections are intended for access to instance-based services, and don't support traffic flows we might generally categorize as gateway, edge-to-edge, peering, or transit. 托管VPN连接旨在访问基于实例的服务,不支持我们通常可归类为网关,边缘到边缘,对等网络或中转的流量。

If you can configure your edge devices to use a web proxy, then a forward proxy server like squid could handle the connectivity for the devices, because the IP path between a device and a forward proxy is a connection involving only the device and proxy IPs. 如果可以将边缘设备配置为使用Web代理,则鱿鱼之类的前向代理服务器可以处理设备的连接,因为设备和前向代理之间的IP路径是仅涉及设备和代理IP的连接。

A simpler solution would be to use an instance-based firewall to terminate the VPN, instead of the built-in VPC VPN service, because then the firewall instance could allow the traffic to hairpin through itself, source-masquerading (NAT) the traffic behind its own EIP, and this would be something the VPC infrastructure easily supports. 一个更简单的解决方案是使用基于实例的防火墙来终止VPN,而不是内置的VPC VPN服务,因为这样防火墙实例可以允许流量通过自身发夹,将源流量伪装成(NAT)流量。它自己的EIP,这将是VPC基础结构轻松支持的功能。

An instance-based firewall is something you can build yourself, of course, but there are also several products in the AWS Marketplace that provide IPSec tunnel termination and NAT capability. 当然,您可以自行构建基于实例的防火墙,但是AWS Marketplace中也有几种产品可提供IPSec隧道终止和NAT功能。 Some have free trial periods where the only cost is the cost of the instance. 有些具有免费试用期,其中唯一的成本就是实例的成本。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM