VPC with NAT Gateway

Hello,

Sorry if this is a straight forward question but I’m pulling my hair out.

I have setup a private and public subnet. I’ve added a Windows 2012 Box to the public IP to mirror a terminal server which I can access via RDP perfectly fine. I then have a SAP DB running on an instance in a private subnet which I can also access via RDP through the “TS” Server and have confirmed internet access.

I understand I can only connect to the DB via “TS” instance as it is within the public subnet. However, I have to be able to allow certain ports from a specific source to the hit the DB both incoming and outgoing. I cannot add these sources into a VPN so I am a bit stuck.

What is the best way for this to be done? I’m stuck in the mind set of port forwarding but I can’t seem to work it out within the VPC.

Thanks!


Related discussions:

The easiest solution is to move the dB server into the public subnet and allow only rdp and the database port inbound ok the security group from your public ip. This is also the least secure option.

Secondly, you could place an external elb or nlb in the public subnet, use TCP toward the dB server port and have it send traffic that way. The security group of the load balancer should still be limited to your public IP only.

These options I would only consider if the dB engine can encrypt the connections.

Lastly (and most preferred), I’d do an SSH tunnel terminating in a public subnet and then forward traffic to the dB server from there.

You can also setup a small instance in the public subnet running only HAProxy and have it forward the connections to the DB in the private subnet. You can then lock down the HAProxy inbound to only a certain IP or range of IPs with security groups.

Not ideal but better than sticking it in a public subnet as is.

That’s kinda what I had in mind with the load balancer route. I’m not sure OPs overall end game here, but load balancers are at least part of free tier whereas he already has other instances running that would exceed his ec2 free tier quota.

Yep. I wasn’t thinking anything about the free tier when I saw SAP in the question. Nothing SAP wise is gonna be free but you’re right ELBs are great for this kinda thing.

Thanks for your responses. I’m out of the free tier so am paying for usage as I get my head around it.

Ultimately I’m running a small SAP Server and Windows 2012 with a DC and Terminal service on-prem with VMWare. Firewall rules are handled by a security appliance and RDP is only accessed via VPN so trying to emulate this as best as I can in AWS.

Do you already have a VPN from AWS back to on prem? That would be an easy solution as you could just access it privately.

If not, and you want to mimic that setup, you could deploy an OpenVPN instance or similar in AWS and connect up to that first. That would then direct your traffic to the rest of the VPC and mirror your existing on premise architecture.

Yeah I can spin that up easily enough. Sorry, I should have said that we are wanting to move the server completely off-prem. It’s just those external ports on the DB that require access for specific addresses which has thrown a spanner.

The “private/public” nature is just about if the instance gets an automatic public IP address. You can assign a public IP address, then a more specific route in the route table for the subnet for the incoming requests, then set a security group to permit those IP addresses inbound to the server.

That might not work as you expect if the private subnet doesn’t have an internet gateway assigned in it’s route table. Having a public IP won’t help if it’s not reachable.

“More specific route” is key here. It means modifying the route table to have the destination IP through the IGW.

I see what you mean, but it seems a bit to hacky. A private subnet shouldn’t really have IGWs attached at all. Maybe adding a second ENI attached to a public subnet would be better.

The additional interface presents other problems, mainly in handling two “default” routes, conflicting connections, and two different DHCP calls.

It can also lead to some odd networking behavior (like host unavailability due to replying out the wrong interface) if you’re not careful.

And that is also kind of hacky and complex. I’d rather keep hosts as simple/stupid as possible, and make the environment behave in ways that ensures consistency in behavior vs making a single instance a pet.

OP is talking windows server 2012.

Linux networking can do all kinds of things that are far harder in Windows server.

I completely missed that, my bad!