socat – Multipurpose Relay Tool

socat (SOcket CAT) is a powerful multipurpose relay tool for Linux that establishes two bidirectional...

Networking Tools Linux Open Source

socat (SOcket CAT) is a powerful multipurpose relay tool for Linux that establishes two bidirectional byte streams and transfers data between them. Often described as “netcat on steroids,” socat supports numerous protocols including TCP, UDP, UNIX sockets, SSL, PTY, and more, making it indispensable for network debugging, security testing, and system administration.

Key Features

  • Protocol Support – TCP, UDP, SCTP, UNIX sockets, SSL/TLS, PTY, pipes, files, and more
  • Bidirectional Data Transfer – Connect any two endpoints and relay data between them
  • SSL/TLS Support – Create encrypted tunnels and secure connections
  • Address Chaining – Chain multiple addresses for complex relay scenarios
  • Fork Mode – Handle multiple concurrent connections
  • Logging Options – Verbose output for debugging network issues

Installation

# Debian/Ubuntu
sudo apt install socat

# RHEL/CentOS/Fedora
sudo dnf install socat

# Arch Linux
sudo pacman -S socat

Common Usage Examples

# Create simple TCP listener
socat TCP-LISTEN:8080,fork -

# Port forwarding
socat TCP-LISTEN:8080,fork TCP:remote-host:80

# Create SSL tunnel
socat TCP-LISTEN:443,fork,reuseaddr OPENSSL:remote:443

# Connect two serial ports
socat /dev/ttyUSB0,raw,echo=0 /dev/ttyUSB1,raw,echo=0

# Create virtual serial port pair
socat -d -d pty,raw,echo=0 pty,raw,echo=0

Use Cases

socat excels in penetration testing, creating secure tunnels, serial port communication, debugging network applications, and building complex relay chains for traffic redirection.

Download socat

Was this article helpful?