- Newest
- Most votes
- Most comments
Thanks for the screen shots. Sounds like your Ephemeral port is 587 from your EKS service. I would use something like VPC flow logs to find the source port from your EKS service.
As NACLs are stateless, as you are configuring you will need ports open for the return traffic. See if you can figure out the source port from your EKS Service. Usually rule 400 would cover it but somethings afoot here.
You can create 4 rules as follows set to ALLOW to limit access on the INBOUND ACL if the Ephemeral port (Source) port is 587
| Type | Protocol | Port Range | Source |
|---|---|---|---|
| Custom TCP | TCP (6) | 587 | 54.228.39.88/32 |
| Custom TCP | TCP (6) | 587 | 18.197.194.208/32 |
| Custom TCP | TCP (6) | 587 | 52.57.139.126/32 |
| Custom TCP | TCP (6) | 587 | 108.128.229.184/32 |
Gary
Hi! thanks for you reply. Just trying to understand clearly. I think I already have those Inbound rules - #600, #604, #608 and #612 - isn't it doing that?
-S
im not a fan of nacls.. let me update it. i am wrong
I wrote this first then changed direction. My new answer seems the logical reason for your issue.
I think, we already established that the return traffic has to come from port
587but the issue that I'm trying to get to bottom of is why I have to allow entier0.0.0.0/0for that, as I already have the inbound allowed from those 4 specific IPs on port 587.Am I missing something here?
okay, I think I figured out: For a strange reason, which I yet to understand, I need an Inbound rule, allowing traffic from EKS VPC CIDR on port 587.....
701 Custom TCP TCP (6) 587 10.xx.xx.0/22 Allow...... without anyother Ingress allow on port 587 from any of the piblic IP and that's the reason, it seems like it was working only from
0.0.0.0/0thanks @Gary Mclean for giving me the idea of cheking the VPC flow log. Now the next mystery to solve why it needs an allow from a private CIDR. -S
The issue you're experiencing with accessing the Sendgrid SMTP endpoint from your EKS service is likely related to how Network Access Control Lists (NACLs) handle return traffic for outbound connections.
When your service initiates an outbound connection to the Sendgrid SMTP endpoint on port 587, the return traffic from Sendgrid will use an ephemeral port (typically in the range of 1024-65535). This return traffic needs to be allowed by your NACL's inbound rules.
The reason why allowing traffic to 0.0.0.0/0 on port 587 works is that it's permitting all inbound traffic on that port, regardless of the source IP. However, this is not the ideal solution from a security standpoint.
To resolve this issue while maintaining better security practices, you should:
-
Keep your current egress rules allowing outbound traffic to the specific Sendgrid IP addresses on TCP port 587.
-
For the ingress rules, instead of specifying the Sendgrid IP addresses, you should allow inbound traffic from 0.0.0.0/0 (or your VPC CIDR if you want to be more restrictive) on the ephemeral port range (1024-65535). This will allow the return traffic from Sendgrid to reach your service.
-
Ensure that your security groups are also configured correctly to allow this traffic.
Remember that NACLs are stateless, meaning they don't automatically allow return traffic like security groups do. This is why you need to explicitly allow the inbound traffic on the ephemeral ports.
If you still experience issues after making these changes, you may need to investigate further, checking your VPC configuration, route tables, and ensuring that your NAT Gateway is properly set up to allow outbound internet access from your private subnets.
Sources
Troubleshoot connection to AWS service endpoints from Linux | AWS re:Post
Network ACLs for transit gateways in Amazon VPC Transit Gateways - Amazon VPC
@Gary Mclean, didn't figure out how exactly to share, but here is the screenshots:
Without the highlighted rule (#701) access to SMTP doesn't work.
-S
Relevant content
- asked 7 years ago

Can you share your NACL?