DZone
Thanks for visiting DZone today,
Edit Profile
  • Manage Email Subscriptions
  • How to Post to DZone
  • Article Submission Guidelines
Sign Out View Profile
  • Post an Article
  • Manage My Drafts
Over 2 million developers have joined DZone.
Log In / Join
Refcards Trend Reports
Events Video Library
Refcards
Trend Reports

Events

View Events Video Library

Zones

Culture and Methodologies Agile Career Development Methodologies Team Management
Data Engineering AI/ML Big Data Data Databases IoT
Software Design and Architecture Cloud Architecture Containers Integration Microservices Performance Security
Coding Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks
Culture and Methodologies
Agile Career Development Methodologies Team Management
Data Engineering
AI/ML Big Data Data Databases IoT
Software Design and Architecture
Cloud Architecture Containers Integration Microservices Performance Security
Coding
Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance
Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks

Last call! Secure your stack and shape the future! Help dev teams across the globe navigate their software supply chain security challenges.

Modernize your data layer. Learn how to design cloud-native database architectures to meet the evolving demands of AI and GenAI workloads.

Releasing software shouldn't be stressful or risky. Learn how to leverage progressive delivery techniques to ensure safer deployments.

Avoid machine learning mistakes and boost model performance! Discover key ML patterns, anti-patterns, data strategies, and more.

Related

  • Analyze Your ALB/NLB Logs With ClickHouse
  • Virtual Network Functions in VPC and Integration With Event Notifications in IBM Cloud
  • Load-Balancing Minecraft Servers with Kong Gateway
  • MuleSoft Operational and API Management Capabilities

Trending

  • How AI Agents Are Transforming Enterprise Automation Architecture
  • 5 Subtle Indicators Your Development Environment Is Under Siege
  • Build Your First AI Model in Python: A Beginner's Guide (1 of 3)
  • Teradata Performance and Skew Prevention Tips
  1. DZone
  2. Software Design and Architecture
  3. Cloud Architecture
  4. Hacking the VPC: ELB as a Bastion

Hacking the VPC: ELB as a Bastion

Keeping your cloud machine instances secure is of paramount importance, but it's often hard to troubleshoot and expensive. An Elastic Load Balancer can help with that.

By 
Keith Gregory user avatar
Keith Gregory
·
Dec. 26, 16 · Tutorial
Likes (3)
Comment
Save
Tweet
Share
17.2K Views

Join the DZone community and get the full member experience.

Join For Free

a common deployment structure for amazon virtual private clouds (vpcs) is to separate your servers into public and private subnets. for example, you put your webservers into the public subnet, and database servers in the private subnet. or for more security you put all of your servers in the private subnet, with an elastic load balancer (elb) in the public subnet as the only point-of-contact with the open internet.

the problem with this second architecture is that you have no way to get to those servers for troubleshooting: the definition of a private subnet is that it does not expose servers to the internet.

the standard solution involves a “bastion” host: a separate ec2 instance that runs on the public subnet and exposes a limited number of ports to the outside world. for a linux-centric distribution, it might expose port 22 (ssh), usually restricted to a limited number of source ip addresses. in order to access a host on the private network, you first connect to the bastion host and then from there connect to the private host (although there's a neat trick with netcat that lets you connect via the bastion without an explicit login).

the problem with a bastion host — or, for windows users, an rd gateway — is that it costs money. not much, to be sure: ssh forwarding doesn't require much in the way of resources, so a t2.nano instance is sufficient. but still …

it turns out that you've already got a bastion host in your public subnet: the elb. you might think of your elb as just front-end for your webservers: it accepts requests and forwards them to one of a fleet of servers. if you get fancy, maybe you enable session stickiness or do https termination at the load balancer. but what you may not realize is that an elb can forward any tcp port.

so, let's say that you're running some windows servers in the private subnet. to expose them to the internet, go into your elb config and forward traffic from port 3389:

of course, you don't really want to expose those servers to the internet, you want to expose them to your office network. that's controlled by the security group that's attached to the elb; add an inbound rule that just allows access from your home/office network (yeah, i'm not showing my real ip here):

lastly, if you use an explicit security group to control traffic from the elb to the servers, you'll also need to open the port on it. personally, i like the idea of a “default” security group that allows all components of an application within the vpc to talk with each other.

you should now be able to fire up your favorite rdesktop client and connect to a server.

> xfreerdp --plugin cliprdr -u administrator 52.15.40.131
loading plugin cliprdr
connected to 52.15.40.131:3389
password: 
...


the big drawback, of course, is that you have to control over which server you connect to. but for many troubleshooting tasks, that doesn't matter: any server in the load balancer's list will show the same behavior. and in development, where you often have only one server, this technique lets you avoid creating special configuration that won't run in production.

actually, the definition of a public subnet is that it routes non-vpc traffic to an internet gateway, which is a precondition for exposing servers to the internet. however, this isn't a sufficient condition: even if you have an internet gateway you can prevent access to a host by not giving it a public ip. but such pedantic distinctions are not really relevant to the point of this post; for practical purposes, a private subnet doesn't allow any access from the internet to its hosts, while a public subnet might.

i should clarify: the classic load balancer can forward any port; an application load balancer just handles http and https, but has highly configurable routing. see the docs for more details.

Virtual private cloud Host (Unix) Load balancing (computing) Internet (web browser)

Published at DZone with permission of Keith Gregory, DZone MVB. See the original article here.

Opinions expressed by DZone contributors are their own.

Related

  • Analyze Your ALB/NLB Logs With ClickHouse
  • Virtual Network Functions in VPC and Integration With Event Notifications in IBM Cloud
  • Load-Balancing Minecraft Servers with Kong Gateway
  • MuleSoft Operational and API Management Capabilities

Partner Resources

×

Comments

The likes didn't load as expected. Please refresh the page and try again.

ABOUT US

  • About DZone
  • Support and feedback
  • Community research
  • Sitemap

ADVERTISE

  • Advertise with DZone

CONTRIBUTE ON DZONE

  • Article Submission Guidelines
  • Become a Contributor
  • Core Program
  • Visit the Writers' Zone

LEGAL

  • Terms of Service
  • Privacy Policy

CONTACT US

  • 3343 Perimeter Hill Drive
  • Suite 100
  • Nashville, TN 37211
  • support@dzone.com

Let's be friends: