Git Product home page Git Product logo

tcp-port-forward's Introduction

TCP Port Forward

This extremely simple tool merely opens a port on the local machine and forwards the connection to another machine. It's based on portforward.c, and the DNS resolution happens at the time of the connection.

Usage

First, either compile by hand or simply run make:

make

This builds an executable called portforward. From here, you need to specify two settings and can specify a third.

portforward LISTEN_PORT FORWARD_NAME [FORWARD_PORT]
  • LISTEN_PORT: The port to listen to on the current machine.
  • FORWARD_NAME: DNS name of destination.
  • FORWARD_PORT: Destination port for the forwarded traffic. Optional, defaults to the same port as LISTEN_PORT.

Why resolve later?

That's a great question. Let's build a scenario to better explain why this could be a useful thing. I am sometimes working with applications in the cloud that do not handle scaling well. It is entirely possible that a cluster of MongoDB databases that were up yesterday are gone today, but in their place are a set of brand new ones.

These new ones were rolled on slowly and the replica set was preserved. We also have Consul up and running so our DNS name of "master.mongo.service.consul" always points to the master of the replica set. The IPs of the new machines do not match the old ones, but looking them up by name again will resolve to the correct IP addresses.

My ancient application was robust enough to reconnect in case Mongo disappeared for a bit, but it can't handle when IP addresses change. With this proxy in place on the same machine as the application, I can run this program

portforward 27017 master.mongo.service.consul

Now all that's left is to configure my application to use the mongo at "localhost:27017" and I'm set.

tcp-port-forward's People

Contributors

fidian avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.