Skip to main content
The 2024 Developer Survey results are live! See the results

Questions tagged [socat]

The program socat is a relay for bidirectional data transfer between two independent data channels.

Filter by
Sorted by
Tagged with
-1 votes
0 answers
33 views

Restart of socat process creates GB large log file

I have a usb port shared virtually through ser2net - socat, and I've configured socat based on what's described here. However, I noticed socat's tendency to fail, and so I have changed the socat.conf ...
Ajned's user avatar
  • 109
2 votes
1 answer
89 views

Proxy between UNIX socket with socat

I used socal to create a proxy server between 2 UNIX sockets: /var/a.sock , /var/b.sock client -> /var/a.sock -> MY_COMMAND -> /var/b.sock -> MY_COMMAND -> /var/a.sock ->client. The ...
Polo1990's user avatar
0 votes
2 answers
69 views

What does '-' as a file parameter mean? [duplicate]

I'm having trouble finding a name for the - character in the context of a piped bash command. What is the - character called? Can I replace it with something more readable for a script? Example ...
tarabyte's user avatar
  • 4,376
0 votes
1 answer
85 views

Where/How does socat insert packet boundaries?

I am using socat to forward incoming serial traffic to a local UDP port (on macOS): socat OPEN:/dev/cu.usbmodem13203 UDP:localhost:12345 I consider a serial device being a streaming interface while ...
Binabik's user avatar
  • 363
1 vote
1 answer
66 views

job control doesn't work when I create my own pty pair with socat

I am experimenting with understanding terminal emulators by looking at the different pieces of the puzzle. I am trying to start a pty pair and shell process with socat, and then connect to it with ...
Alex028502's user avatar
0 votes
1 answer
78 views

websocat command argument equivalent for this nginx custom configuration?

I have this nginx custom configuration: server { listen 8080; server_name subdomain.domain.my.id; location /vless-ws { # Consistent with the path of V2Ray configuration if ($...
isysrg's user avatar
  • 3
0 votes
0 answers
64 views

Emulate ttyS0 on Ubuntu 22 or link it to ttyUSB0

I have a JAVA code that checks if ttyS0 is present. I dont have a serial port, so Im getting: Exception in thread "main" java.lang.RuntimeException: Error opening "/dev/ttyS0" ...
Aleksander's user avatar
3 votes
1 answer
176 views

socat parameter order seems to matter

The man page of socat states that socat is a command line based utility that establishes two bidirectional byte streams and transfers data between them. Based on that, the order of your arguments ...
Pablo's user avatar
  • 234
0 votes
2 answers
62 views

Why the tunnel Xdmcp+ssh don't work?

I want to tunnel via ssh a Xdmcp protocol. To access sicure to a remote login. An easy solution can be openvpn, but I want to try socat+ssh first. The server is Solaris 10 The client is Slackware 15. ...
elbarna's user avatar
  • 12.8k
-1 votes
1 answer
63 views

What does the tee l2r or r2l argument mean?

I saw a socat example here, where they use tee l2r | socat - "TCP:remote:5555" | tee r2l what does the l2r or r2l mean?
René Link's user avatar
0 votes
0 answers
136 views

Is possible to "sniff" a socket? Socat doesn't work

This is the situation: I have two VM (virtual machines) via kvm-qemu connected via virtual-serial (a socket). I created the two vm's with this serial configuration: serial1 (slackware, uses port1 ...
elbarna's user avatar
  • 12.8k
0 votes
1 answer
175 views

how can I make socat simulate unplugging a serial device

I have this test program import sys for line in sys.stdin: print(line.strip()) print("DONE") if I get it to print out lines from a real device (an FTDI) python3 demo.py < /dev/...
Alex028502's user avatar
0 votes
0 answers
105 views

How to setup a DNS with a socat based vpn?

Since socat has the functionality of creating tunnel interfaces and route traffic over UDP, I believe a VPN can be created using this feature. Server side setup: sudo socat -d -d TUN:10.0.0.1/24,up ...
Weed Cookie's user avatar
0 votes
1 answer
101 views

Can I set up a serial terminal (RS-232) without a pty?

I have two computers that both have a RS-232 port on /dev/ttyS0 connect together with a null modem. I am trying to understand bit by bit how an external terminal worked in the old days, and how that ...
Alex028502's user avatar
0 votes
2 answers
640 views

socat et al.: run a command when incoming connection is received

Let's say one is listening on a tcp port for an incoming connection using socat like this: $ socat file:`tty`,echo=1 "TCP-L:8080" Is is possible to run a command (just once) when connection ...
codepoet's user avatar
  • 606
0 votes
1 answer
430 views

How to send UDP broadcast datagrams to port below 1025?

Scenario I'm trying to send a UDP datagram message with socat to a broadcast address. On the receiving end this is how I'm running socat (with root privileges): socat UDP-LISTEN:1011 - I'm trying to ...
polemon's user avatar
  • 11.6k
0 votes
2 answers
1k views

socat: How to do simple duplex communication with shell?

I would like to create a TCP connection to a remote server with socat, where a client sends an action for an image file ("convert", "open", etc.) the image (binary content) ...
mosaic's user avatar
  • 3
2 votes
2 answers
1k views

How to run multiple `socat` and forwarding both TCP and UDP traffic?

I want to forward Microsoft Remote Desktop on a Linux Server, assume that the remote Windows host is 192.168.1.100, I want to run: socat TCP4-LISTEN:3389,fork TCP4:192.168.1.100:3389 socat UDP4-LISTEN:...
ricky9w's user avatar
  • 21
0 votes
2 answers
369 views

Tunnel multiple HTTP connections over a bidirectional stream

I'm looking to forward an http server (on Linux) over a single non-network bidirectional stream (specifically, a QEMU virtio-serial stream, but that doesn't really matter). Basically what I want is: [...
Dustin Spicuzza's user avatar
0 votes
1 answer
87 views

TCP port visible from inside nor outside

I've used autossh (reverse) connecting to my server. The ssh side works like used to. But in an ARM64 system, my Ubuntu has less possibilities but this is another story (...). So what I see whit nmap ...
Erkman's user avatar
  • 3
1 vote
1 answer
807 views

how to remove the buffer when simulating a serial device with socat

I am creating a fake serial device like this: socat -d -d pty,raw,echo=0 pty,raw,echo=0 This creates devices with new numbers each time. Let's call them /dev/pty/6 and /dev/pty/7 To simulate a ...
Alex028502's user avatar
1 vote
0 answers
330 views

Trying to make a fake GPS device with socat

Background: I am trying to make a fake GPS device so that I can put the wrong time in the output, and then make sure that when I set up chrony and gpsd, I am getting the time from serial feed that I ...
Alex028502's user avatar
1 vote
1 answer
181 views

socat tunnel traffic drops after some time

I have two Linux machines, I want to create a tunnel between them using socat, this is my workaround: Machine1: socat -d -d UDP-LISTEN:4711,reuseaddr TUN:10.50.50.1/24,iff-up,iff-broadcast,iff-...
abexamir's user avatar
0 votes
1 answer
177 views

Start only a socat process when integrating with systemd

I want to run a "socat" command to replicate the information coming on port 162 to another machine and on the same port. I added a systemd to do this process: [Unit] Description=Socat SNMP ...
user548444's user avatar
0 votes
1 answer
1k views

Socat specify source port

How do I specify source port in socat? In netcat I can simply: nc -u -s 192.168.0.1 -p 8888 192.168.0.2 9999 I tried socat udp4:192.168.0.2:9999 STDIN:192.168.0.1:8888 It's failed STDIN: wrong ...
Muhammad Ikhwan Perwira's user avatar
1 vote
1 answer
2k views

Connect to host machine from WSL2

Problem Can't connect to Windows X Server (VcXsrv) from WSL2 due firewall rules (sometimes it works, but sometimes it doesnt; it's very strange). Changing the firewall rules is not possible. But any ...
Arber's user avatar
  • 133
0 votes
0 answers
471 views

Socat serial to tcp for authorized users

Hello everyone I hope you doing well I have a raspberry pi and I kind need a serial port server which can access from internet Now I use socat command like bellow on my raspberry and from putty on ...
Hamidreza's user avatar
1 vote
1 answer
350 views

How do I inject a header line into a pipe via a shell script?

I am working on a process to send data via a pipe from one server to another for processing. Although this is not the exact command, it might look something like this: tail -f logfile | grep "abc&...
Ben Holness's user avatar
0 votes
2 answers
2k views

Proxying localhost to HTTPS using socat returns Connection refused first time

I'm trying to fetch a page from https://termbin.com/9hc2k using bash redirections and socat, especially using special file /dev/tcp/localhost/8080 to open a network connection. # fetch.sh # fetch ...
Logan Lee's user avatar
  • 249
2 votes
2 answers
8k views

Intercept communications on physical serial port using socat

I'm no Linux expert so please go easy ;). Ok, the situation is that I have a single board computer running Debian Wheezy. I know its old/risky etc etc but its not actually "my" equipment and ...
RobF's user avatar
  • 21
0 votes
0 answers
487 views

socat streaming UDP is slower than TCP

I'm currently using subprocess.run(["socat", f"udp-listen:{_to},fork,reuseaddr,bind=127.0.0.1", f"""exec:'sudo ip netns exec {netns} socat STDIO "UDP-connect:...
DrownedSuccess's user avatar
0 votes
1 answer
390 views

socat does not honor sourceport option

I am trying to send a udp packet from a specific port: $ echo hello | socat - UDP-DATAGRAM:192.168.1.255:11111,broadcast,sourceport=22222 But a random port is used instead: # tcpdump -vvvv -ttttt -...
Evgeniy Berezovsky's user avatar
0 votes
0 answers
247 views

redirected stdin : how to get ALL lines of the incoming request instead of doing multiple "read"

THIS QUESTION IS BASH SCRIPT RELATED... the rest is to explain the context. context : experimentation : create a simple mini webserver with socat instead of apache. ** the test I'm doing is able to ...
John R's user avatar
  • 115
1 vote
0 answers
2k views

Local port forwarding on Ubuntu 20.04?

I have a service listening on port :3000. However, I would like to change that to port :8080. Unfortunately, the program that I'm running does not allow me to change the listen port. Is there any way ...
Blue Herring's user avatar
1 vote
1 answer
2k views

How do I write multiple socat statements in a systemd file for restart on failure?

CODE: /etc/systemd/system/socat.service [Unit] Description="socat systemd" [Service] Type=simple Restart=on-failure RestartSec=10 User=ubuntu ExecStart = /usr/bin/socat tcp-listen:1111,...
aste123's user avatar
  • 121
1 vote
1 answer
711 views

tell socat to stop on connection refuse with fork enabled

I'm using this instruction to forward a port to another, both on a local machine: socat -d -d TCP4-LISTEN:80,reuseaddr,fork TCP4:127.0.0.1:8000 I need to keep the port open unless the destination ...
Little Apocrypha's user avatar
0 votes
0 answers
114 views

Redirect specific traffic between two port on same device

I have two running SIP applications on a Debian buster server, one app use port 1000 (a softphone) and another one using port 2000 (VoIP server like FreePBX). both of them are on the same machine and ...
Mohammad Ali Nekouie's user avatar
0 votes
1 answer
2k views

SOCAT (only) reverse tunnel

I have a situation where we are trying to get data from one network to another - specifically access to a private maven repo on a different network. Network 1 contains a maven repo. And network is ...
Jeef's user avatar
  • 157
1 vote
2 answers
3k views

How to receive a file and save it with socat

**** This is for learning purpose. I just like to deep dive into sockets, tcp, packets, etc. For doing tests and learning, I began to "play" with socat CONTEXT (tests) : 1- Bind a port to a ...
Jintor's user avatar
  • 115
1 vote
1 answer
1k views

socat: EXEC does not relay correctly

I have a small program that first outputs a string to the user and then takes an input. I instead want the program to work by sending and receiving from a port. To try to realize this I ran the ...
Mr Krisey's user avatar
0 votes
0 answers
213 views

Contents of variable somehow lost with socat and wall

I'm not sure what is going on or which command causes the unexpected behavior, so I'll post everything I've done: I have created a script onreceive.sh containing: #!/bin/bash read INCOMING wall --...
AndreKR's user avatar
  • 1,110
0 votes
1 answer
650 views

Make "socat" constantly listen for the magic packet

I have a RPi 1b+ v1.2 with Raspberry Pi OS June 2021. I'm using socat to trigger a bash script that wakes another PC in the network up. I use this command: sudo socat UDP-LISTEN:10 EXEC:scripts/pi-wol....
magrega's user avatar
  • 13
0 votes
1 answer
419 views

listener message on port 23

I want to have a message to anyone that tries to telnet (port 23) to my server that they are connecting to the wrong port, then disconnects them. Basically something like socat would be ideal, but I ...
Alistair Ross's user avatar
1 vote
1 answer
624 views

How to use socat to implement a base64 decoding proxy?

The goal: bidirectional communication while decode in a unidirectional way the incoming data Theory: suppose to have a proxy/ server that listens on port 8080 which needs to handle multiple clients at ...
hyogy's user avatar
  • 13
0 votes
1 answer
3k views

send udp broadcast via bash

I try to send a udp broadcast with 2 (FF 01) bytes over bash, but in my network sniffer I notice it's 3 bytes. FF 01 0A where does the line break come from and how can i prevent it? echo -e '\xFF\x01' ...
live2's user avatar
  • 105
3 votes
1 answer
9k views

How to run socat as a systemd service to bridge two remote unix sockets?

In order to use Exim's dovecot authentication, I need to bridge two unix sockets in two different machines: the exim server and the dovecot one. To do so I'm using socat: eximserver# socat UNIX-LISTEN:...
Jesús Ángel's user avatar
1 vote
0 answers
1k views

What are the side effects of using socat to monitor the traffic of a serial port regarding the monitored serial port?

Disclaimer: Long and detailed problem description + I actually have no idea about socat, but ran into a very strange problem. Something similar to a tl;dr at the end. I am currently trying to connect ...
Jan4765's user avatar
  • 11
0 votes
0 answers
1k views

SSH local port forwarding or SSH + Socat

I would like to connect to a service running on port X on a host. The service cannot be reached on the host IP address and port. There are 2 options I know which can achieve this: Local port ...
likecs's user avatar
  • 113
0 votes
1 answer
130 views

How to get bash to reevaluate $(date) when part of a background job - if possible

OS FreeBSD-12.2 I have a virtual printer setup using socat. The socat command runs in the background. It spawns a system shell that processes the input stream and sends it to gpcl6 to create pdf ...
James B. Byrne's user avatar
1 vote
1 answer
320 views

PPP fails LCP negotiation with serial to wifi connection using Socat

I'm trying to setup a connection over a serial to wifi adapter. I'm using Socat to create a socket to bridge the connection to a PTY for pppd. Data appears to be be flowing both directions, but pppd ...
Biyau's user avatar
  • 11