Home Sock It To Me With Socat

Sock It To Me With Socat

We’ve all been there. You want to isolate an issue with a server running on a port but want something quick and easy to verify if it is a host firewall problem or something else. Perhaps you are dealing with someone on the other end of the network that says it is a firewall problem. How you prove otherwise?

Luckily, there is socat. While there are other network Swiss army knives out there such as Ncat and Netcat, you might find socat worth a try. Socat is available for most Linux and BSD distributions and there are binaries available for Windows.

Sock It To Me

In this example, we have a service running on a high port (6000) on a machine “tom” and we want to prove that the firewall rule is indeed allowing traffic from the outside world from another machine “jerry”.

In this very simple example, we are logged into tom and start by confirming that socat is installed on tom. Here we simply install the socat package via yum on tom. Next, we’ll make sure that the firewall rules on tom are correct. Finally, we issue the socat one liner to listen on the port we want to test for the firewall allowing incoming traffic on port 6000 and we save our results on tom to /tmp.

Now that we have a service listening on tom it’s time to login to jerry and telnet to the tom on the specified port. We’ll simply type in “Hello world” and then escape from our telnet session.

At this point we can review the file on tom:/tmp to see if our testing was fruitful. Success! Now, time to tell the other end that the problem isn’t with the firewall on your end!

There a huge number of socat one liners out there and the socat documentation is detailed. You can imagine the possibilities if in this example both tom and jerry both have access to socat.

Again, this is a very simple example but the power of socat is how quickly and easily you can verify and solve problems. Of course, socat use cases don’t end there and you can quickly find socat being an indispensable tool for getting things done.

If you already know and love socat, what are some of your favorite one liners?

About ReadWrite’s Editorial Process

The ReadWrite Editorial policy involves closely monitoring the tech industry for major developments, new product launches, AI breakthroughs, video game releases and other newsworthy events. Editors assign relevant stories to staff writers or freelance contributors with expertise in each particular topic area. Before publication, articles go through a rigorous round of editing for accuracy, clarity, and to ensure adherence to ReadWrite's style guidelines.

Get the biggest tech headlines of the day delivered to your inbox

    By signing up, you agree to our Terms and Privacy Policy. Unsubscribe anytime.

    Tech News

    Explore the latest in tech with our Tech News. We cut through the noise for concise, relevant updates, keeping you informed about the rapidly evolving tech landscape with curated content that separates signal from noise.

    In-Depth Tech Stories

    Explore tech impact in In-Depth Stories. Narrative data journalism offers comprehensive analyses, revealing stories behind data. Understand industry trends for a deeper perspective on tech's intricate relationships with society.

    Expert Reviews

    Empower decisions with Expert Reviews, merging industry expertise and insightful analysis. Delve into tech intricacies, get the best deals, and stay ahead with our trustworthy guide to navigating the ever-changing tech market.