socat: Pfiffiges Tool zum Mappen von IPv6 auf IPv4 Adressen

Wer gerade vor dem Problem steht alle Dienste auf seinen Linux Maschinen IPv4/IPv6 Dualstack fähig zu machen, der ist froh wenn er so ein Tool wie socat findet.

Es sind zwar die meisten Linux Dienste bereits Dualstack fähig aber es gibt vereinzelt noch Dienste wo keine regelmäßige bis keine Pflege der Software stattfindet.

socat ist quasi ein IPv6 -> IPv4 Relay. Das Paket ist im Packet Repository von Debian / Ubuntu verfügbar.

Beschreibung von socat aus der README des Pakets:

socat is a relay for bidirectional data transfer between two independent data
channels. Each of these data channels may be a file, pipe, device (serial line
etc. or a pseudo terminal), a socket (UNIX, IP4, IP6 - raw, UDP, TCP), an
SSL socket, proxy CONNECT connection, a file descriptor (stdin etc.), the GNU
line editor (readline), a program, or a combination of two of these.
These modes include generation of "listening" sockets, named pipes, and pseudo
terminals.

socat can be used, e.g., as TCP port forwarder (one-shot or daemon), as an
external socksifier, for attacking weak firewalls, as a shell interface to UNIX
sockets, IP6 relay, for redirecting TCP oriented programs to a serial line, to
logically connect serial lines on different computers, or to establish a
relatively secure environment (su and chroot) for running client or server
shell scripts with network connections.

Many options are available to refine socats behaviour:
terminal parameters, open() options, file permissions, file and process owners,
basic socket options like bind address, advanced socket options like IP source
routing, linger, TTL, TOS (type of service), or TCP performance tuning.

More capabilities, like daemon mode with forking, client address check,
"tail -f" mode, some stream data processing (line terminator conversion),
choosing sockets, pipes, or ptys for interprocess communication, debug and
trace options, logging to syslog, stderr or file, and last but not least
precise error messages make it a versatile tool for many different purposes.

In fact, many of these features already exist in specialized tools; but until
now, there does not seem to exists another tool that provides such a generic,
flexible, simple and almost comprehensive (UNIX) byte stream connector.

Das Tool kann noch wesentlich mehr, Infos findet man auf der Webseite des Programmierers http://www.dest-unreach.org/socat/.

Ich habe das für meinen alten SKS Keyserver verwendet, der noch kein IPv6 beherrscht. Ich lasse das ganze in einzelnen Screens laufen.

screen -dmS socat1 socat TCP6-LISTEN:11370,ipv6only=1,reuseaddr,fork TCP4:1.2.3.4:11370
screen -dmS socat2 socat TCP6-LISTEN:11371,ipv6only=1,reuseaddr,fork TCP4:1.2.3.4:11371
screen -dmS socat3 socat TCP6-LISTEN:80,ipv6only=1,reuseaddr,fork TCP4:1.2.3.4:11371

Damit das ganze auch noch einen Neustart überlebt kann man es noch in die /etc/rc.local vor dem „exit 0“ einfügen.

Schreibe einen Kommentar

Diese Website verwendet Akismet, um Spam zu reduzieren. Erfahre mehr darüber, wie deine Kommentardaten verarbeitet werden.