大网数据广告活动
服务器运维问答

AWS route table point default to network interface in a different subnet

· 52CE 我爱测

I'm trying to setup an EC2 instance as NAT gateway of sorts that other instances in a private network will be routed to. I have a following setup: VPC 10.0.0.0/16 2 subnets A: 10.0.1.0/24 B: 10.0.2.0/24 2 EC2 instances NAT instan…

问题原文

原帖链接 · Michal Artazov · CC BY-SA 4.0

I'm trying to setup an EC2 instance as NAT gateway of sorts that other instances in a private network will be routed to.

I have a following setup:

VPC

  • 10.0.0.0/16

2 subnets

  • A: 10.0.1.0/24
  • B: 10.0.2.0/24

2 EC2 instances

  • NAT instance with 2 network interfaces eth0, eth1, both in subnet A
  • Another instance in subnet B

In the NAT instance, eth0 is meant for public network and eth1 for private and they have firewalls set accordingly.

I tried to create route table for subnet B that routes the default to eth1 of NAT, i.e.:

0.0.0.0/0         <id of eth1 on NAT>

Then I tried to run tshark -i eth1 (Wireshark in command line) on NAT to see if any traffic is getting there and I ran ping google.com on the other instance. With no success. I also tried curl google.com just in case pings are blocked somewhere, but also nothing happened.

Looks like there is something wrong with the way AWS is routing the traffic so it never reaches the network interface even though the route table is set that way.

I'd appreciate if someone can help me with this. Thank you.

DISCLAIMER: I know that AWS has a built-in NAT gateway option and it's not suitable for my case.

已采纳解答

原帖链接 · Pedro Perez · CC BY-SA 4.0

As neither the source nor the destination of the packets are an IP address that belongs to your NAT gateway of sorts, you need to disable the srcdst check on the Network Interfaces you'd like to handle traffic (I'd say both in the NAT gateway):

https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/using-eni.html#change_source_dest_check

Otherwise the platform drops the traffic as an "antispoofing" protection so to speak.

If you want to do this in Azure, the equivalent is the IP Forwarding flag.

摘自公开归档,保留原文语言,版式经整理,外部媒体与邮箱地址已移除。

资料来源与适用范围

资料来源
Server Fault
适用范围
以原帖系统、软件版本与发布日期为准(2019-03-06)
内容语言
中文;命令、路径和错误标识保留技术原文
本地收录日期
2026-11-15
授权说明
CC BY-SA 4.0

正文与所需资源由本站本地存储。查看来源及更新记录 ↗

请按适用版本和实际日志确认原因;本站没有对每一种系统或设备逐项执行文中的操作。