website/content/blog/socatforward.md

23 lines
703 B
Markdown
Raw Normal View History

2021-06-19 00:03:57 +00:00
---
2023-02-19 02:37:22 +00:00
date: 2021-06-18 23:38:43
2021-06-19 00:03:57 +00:00
draft: false
2023-01-05 19:04:45 +00:00
medium_enabled: true
2023-02-19 02:37:22 +00:00
medium_post_id: 790558856bee
tags:
- Networking
title: Forward Packets with Socat
2021-06-19 00:03:57 +00:00
---
I've written about relaying TCP traffic using [SSH port forwarding](/blog/sshlocalportforwarding/). Though sometimes you don't require the authenticity and encryption of SSH or want to use another protocol such as UDP. That's where `socat` comes in.
2021-06-19 00:03:57 +00:00
The following will listen to TCP traffic on port 8001 and redirect it to TCP localhost:8000
```bash
socat tcp-listen:8001,reuseaddr,fork tcp:localhost:8000
```
This will listen UDP on port 4009 and forward it to UDP localhost:4010
```bash
socat udp-listen:4009,reuseaddr,fork udp:localhost:4010
```