Giter Site home page Giter Site logo

portfwd's Introduction

portfwd

A simple and efficient TCP/UDP port forwarder

AboutFeaturesBuildConfigurationRunLicense

About

portfwd is a simple tool designed to forward TCP or UDP traffic to different ports.

Features

  • ✅ A single statically compiled binary for each OS/architecture
  • ✅ Support TCP traffic
  • ✅ Support UDP traffic
  • ✅ Can forward multiple ports to multiple locations simultaneously
  • ✅ An easily configurable tool
  • ✅ Can operate effortlessly as a daemon

Build

First check that you have Golang installed on your machine.
Then, run:

make 

Quite simply!

Configuration

Here is an example of a configuration (YAML):

forward:
  # Forward TCP traffic from one port to a single other
  - protocol: tcp
    from: 127.0.0.1:5100
    to: [10.2.0.1:5101]
  # Forward of TCP traffic from one port to several others
  - protocol: tcp
    from: 127.0.0.1:5200
    to: [127.0.0.1:5201, 10.2.0.1:5202]
  # Forward UDP traffic from one port to a single other
  - protocol: udp
    from: 127.0.0.1:5300
    to: [10.2.0.1:5301]
  # Forward of UDP traffic from one port to several others
  - protocol: udp
    from: 127.0.0.1:5400
    to: [127.0.0.1:5401, 10.2.0.1:5402]

Run

Direct use

To be able to use portfwd directly, you must set the environment variable PORTFWD_CONFIG_FILE_PATH as the path to the configuration file.
For example :

export PORTFWD_CONFIG_FILE_PATH=./config.yaml

Then you can run the program:

./portfwd

As a systemd service

It is possible to easily use portfwd as a daemon with the provided systemd service.
The systemd service provided can be adapted to your needs.

Steps to install portfwd as a systemd service:

  • Create a group:
groupadd portfwd
  • Create an user:
useradd -r -s /sbin/nologin -g portfwd portfwd
  • Copy the portfwd binary to /usr/bin/
cp portfwd /usr/bin/
  • Create a portfwd folder in /etc/ for the configuration file
mkdir /etc/portfwd
  • Copy the config.yaml configuration file to /etc/portfwd/
cp config.yaml /etc/portfwd/
  • Copy the portfwd.service systemd service file to /etc/systemd/system/
cp portfwd.service /etc/systemd/system/
  • Start the systemd service
systemctl start portfwd

License

This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/.

portfwd's People

Contributors

gaetanlhf 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.