Skip to content

Instantly share code, notes, and snippets.

@dmazzer
Last active May 2, 2024 14:32
Show Gist options
  • Star 15 You must be signed in to star a gist
  • Fork 4 You must be signed in to fork a gist
  • Save dmazzer/e8c2e97ae71928f8bfb3059c4331c4dc to your computer and use it in GitHub Desktop.
Save dmazzer/e8c2e97ae71928f8bfb3059c4331c4dc to your computer and use it in GitHub Desktop.
Forwarding IPv4 Ports to IPv6 Hosts
#!/bin/bash
# UDP:
socat UDP4-LISTEN:5683,fork,su=nobody UDP6:[aaaa::212:4b00:615:a1f7]:5683
# TCP:
socat TCP4-LISTEN:22,fork,su=nobody TCP6:[2a01:198:79d:1::8]:22
# UDP, IPv6
socat UDP6-LISTEN:5683,fork,su=nobody UDP6:[aaaa::212:4b00:615:a1f7]:5683
# Using in a script:
nohup socat TCP4-LISTEN:22,fork,su=nobody TCP6:[2a01:198:79d:1::8]:22 &
@flymia
Copy link

flymia commented Feb 12, 2020

Works perfectly! Thanks!

@Paroxz
Copy link

Paroxz commented Nov 16, 2021

Using socat -d -d UDP4-LISTEN:500,fork,su=nobody UDP6:[IPv6]:500 i get the errormessage:

accepting UDP connection from AF=2 IPv4:1011
2021/11/16 15:39:30 socat[56078] N forked off child process 56083
2021/11/16 15:39:30 socat[56078] N listening on UDP AF=2 0.0.0.0:500
2021/11/16 15:39:30 socat[56083] N opening connection to AF=10 [IPv6]:500
2021/11/16 15:39:30 socat[56083] N successfully connected from local address AF=10 [IPv6]:55694
2021/11/16 15:39:30 socat[56083] N starting data transfer loop with FDs [5,5] and [6,6]
2021/11/16 15:39:30 socat[56083] E read(6, 0x557465776bd0, 8192): Permission denied
2021/11/16 15:39:30 socat[56083] N exit(1)
2021/11/16 15:39:30 socat[56078] N childdied(): handling signal 17

Do you have an idea why this "Permission denied" is happening?

@py7hon
Copy link

py7hon commented Mar 30, 2022

Thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment