Skip to main content

Uncomplicated Port Forwarder (UPF)

Project description

Uncomplicated Port Forwarder (UPF)

Uncomplicated Port Forwarder (UPF) is a simple command-line tool to manage port forwarding rules using iptables. It supports both TCP and UDP protocols, making it easy to set up port forwarding for specific ports or ranges of ports.

Installation

sudo pipx install upf

Run the script with sudo for administrative privileges (required to modify iptables).

Usage

Add a Single Port Forwarding Rule

Add a port forwarding rule from a host to a remote IP and port.

TCP (default)

sudo upf add <host-port> <remote-ip>:<remote-port>

Example:

sudo upf add 2200 192.168.0.2:22 # tcp by default

UDP

sudo upf add <host-port> <remote-ip>:<remote-port> --udp
sudo upf add <host-port>/<protocol> <remote-ip>:<remote-port>

Example:

sudo upf add 2200 192.168.0.2:22 --udp
sudo upf add 2200/udp 192.168.0.2:22
sudo upf add 2200/tcp 192.168.0.2:22

Add a Range of Port Forwarding Rules

Add a range of port forwarding rules for a subnet starting from a specified port.

TCP (default)

sudo upf add-range <starting-port>/<protocol> <gateway>/<subnet>:<start port> [--max <count>] [--start-at <number>]

Example:

sudo upf add-range 2200 192.180.12.1/24:80 [--max 10] [--start-at 20]
sudo upf add-range 2200 192.180.12.20/24:80

UDP

sudo  upf add-range 2200/udp 192.180.12.1/24:80 --max 10 --start-at 20

List All Managed Port Forwarding Rules

List all the port forwarding rules that have been added using UPF.

sudo upf list

Delete a Specific Port Forwarding Rule

Delete a specific port forwarding rule by host port.

TCP (default)

sudo upf delete <host-port>/<protocol>

Example:

sudo upf delete 2200 # tcp by default
sudo upf delete 2200/tcp

UDP

sudo upf delete <host-port> --udp

Example:

sudo upf delete 2200 --udp
sudo upf delete 2200/udp

Prune portforwarding

Clear all portforwarding added by upf

sudo upf prune

Sync

In case there is rules which are not part of upf, you can sync them.

sudo upf sync

Notes

  • Persistence: By default, changes made using iptables are not persistent after reboot. To make them persistent, you can save the rules using iptables-save and restore them with iptables-restore.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

upf-0.3.0.tar.gz (13.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

upf-0.3.0-py3-none-any.whl (17.0 kB view details)

Uploaded Python 3

File details

Details for the file upf-0.3.0.tar.gz.

File metadata

  • Download URL: upf-0.3.0.tar.gz
  • Upload date:
  • Size: 13.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.6.1 CPython/3.11.10 Darwin/24.1.0

File hashes

Hashes for upf-0.3.0.tar.gz
Algorithm Hash digest
SHA256 12921bb596c0084dff491db5d68b8d64bf18b6aec27dbe7534669d48309dc900
MD5 b8965895e74ecdfdfe0b830aa6ec50d1
BLAKE2b-256 bfb9d7ed65553958e4be34008fe05b7c4f79a03de07bc0b1a77d251d6387d805

See more details on using hashes here.

File details

Details for the file upf-0.3.0-py3-none-any.whl.

File metadata

  • Download URL: upf-0.3.0-py3-none-any.whl
  • Upload date:
  • Size: 17.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.6.1 CPython/3.11.10 Darwin/24.1.0

File hashes

Hashes for upf-0.3.0-py3-none-any.whl
Algorithm Hash digest
SHA256 b5b5e5ca8f817a56edb769c1a0f6858120f61d49c2435a2ac77a0db973cb19c3
MD5 934b08bfd5f7873295373d385ee5f90b
BLAKE2b-256 802c7f6394752de6786e99284b39e231bc8f7e887d1e06781ce9092bc77fa62e

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page