Exploitationnatbypassingport-forwardingclient-serverudptcp

pwnat

pwnat is a tool that enables communication between clients and a server, both behind NATs, without requiring port forwarding or DMZ setup on routers. It allows direct connectivity where traditional methods fail.

Description

pwnat, pronounced 'poe-nat', is designed for NAT to NAT client-server communication. It allows any number of clients behind NATs to communicate with a server behind a separate NAT without the need for port forwarding or DMZ configuration on any routers. The server does not need prior knowledge of the clients attempting to connect, making it highly flexible for scenarios where direct access is blocked by NAT traversal issues.

Use cases include establishing connections in environments with strict firewall rules or symmetric NATs that typically prevent inbound connections. It's particularly useful for penetration testing, remote access, or any situation requiring peer-to-peer communication across NAT boundaries without third-party STUN/TURN servers.

The tool operates in client or server mode, leveraging UDP for proxying TCP connections, enabling seamless communication where standard TCP punching fails.

How It Works

pwnat uses UDP-based hole punching techniques to establish connectivity between endpoints behind NATs. The server listens on a UDP port, and clients connect via UDP to the server's public IP/port, creating NAT mappings. It proxies TCP connections over these UDP mappings, allowing TCP traffic to traverse NATs without port forwarding. The protocol handles prediction of NAT mapping behaviors, supporting various NAT types including symmetric NATs.

Installation

bash
sudo apt install pwnat

Flags

-sserver mode
-cclient mode (default)
-6use IPv6
-vshow debug output (up to 2)
-areuse address
-preuse port

Examples

Run in server mode on port 8080. Listening on UDP 0.0.0.0:8080
pwnat -s 8080
Run in client mode on local port 8000, connect to server IP 192.168.1.202 on port 8080, and use it to connect to google.com on port 80. Listening on TCP 0.0.0.0:8000
pwnat -c 8000 192.168.1.202 8080 google.com 80
Show usage help with all available flags
pwnat -h
Run in server mode with default proxy port 2222
pwnat -s
Client mode with default proxy port 2222 connecting to remote host and port
pwnat -c <local port> <proxy host> <remote host> <remote port>
Server mode specifying local IP and custom proxy port
pwnat -s [local ip] [proxy port]
Client mode specifying local IP and custom proxy port
pwnat -c [local ip] <local port> <proxy host> [proxy port] <remote host> <remote port>
Updated 2026-04-16kali.org ↗