Skip to content

Repository files navigation

vtether

eBPF/XDP-based TCP port forwarder with full NAT (DNAT + SNAT).

Install

Download a binary from Releases, or build from source:

rustup default nightly
rustup component add rust-src
cargo +nightly install bpf-linker
cargo build --release

Quick Start

# Install systemd service and default config
vtether setup
# Edit config
vim /etc/vtether/config.yaml
# Start / stop
systemctl start vtether
systemctl stop vtether

Configuration

interface: eth0# snat_ip: "192.168.1.100" # optional, auto-detected from interface# conntrack_size: 131072 # max conntrack entries# snat_min_port: 32768 # SNAT source port range# snat_max_port: 60999routes:
- port: 443to: "10.0.0.1:443"
- port: 8080to: "10.0.0.3:8080"
FieldDescription
interfaceNetwork interface to attach XDP program to
snat_ipSource IP for SNAT (optional, auto-detected from interface)
conntrack_sizeMax conntrack entries (default: 131072)
snat_min_portMinimum SNAT source port (default: 32768)
snat_max_portMaximum SNAT source port (default: 60999)
portListen port on the interface
toBackend address and port to forward traffic to

Usage

# Start forwarding (requires root)
vtether proxy up --config vtether.yaml
# Stop forwarding
vtether proxy destroy
# Show active routes and metrics
vtether inspect
# Show version
vtether version

Requirements

  • Linux with XDP-capable NIC driver and bpffs mounted at /sys/fs/bpf
  • Root privileges

Acknowledgements

Much of the design and implementation is inspired by Cilium. Great thanks to the Cilium team.

About

eBPF/XDP-based TCP port forwarder with full NAT (DNAT + SNAT).

Resources

Stars

0 stars

Watchers

1 watching

Forks

Releases

Packages

Contributors

Languages