Theres a saying that “There’s more than one way to bake a cake” I often believe that this applies to Linux eco system as well. Interestingly I was in a situation where there was a requirement to connect two network interfaces to make a bunch of connections happen. I already had some options on my table, such as iptables, bridge-utils etc. But I decided not to use them for one reason that I wanted even simpler solution. And suddenly I came across a tool called stone.
Stone is a simple TCP/IP packet repeater according to its manual but it also does UDP/IP repeating. It also supports proxy, ssl encryption etc.It is available in Debian and Ubuntu repository.
Using stone I solved my problem but I found that the tool offers much more than that and there was no documentation other than the man pages so I thought of writing one. In order to show some bunch of example let me give a picture of my system settings
My system consist of two interfaces Eth0 and Wlan0. And Eth0 is having IP 192.168.1.2 and Wlan0 with IP 10.0.2.2.
Telnet Repeater using Stone:
Assume that you want to redirect telnet service that is running at IP 192.168.1.2 at port 23 to IP 10.0.2.2. at port 100023. A telnet server is running at IP 192.168.1.2/Eth0 at port 23. Now you dont want to run the telnet service for the IP 10.0.2.2/Wlan0 at the same port instead at port 10023.
$sudo apt-get install stone.
$ stone 192.168.1.2:telnet 10.0.2.2:10023
$telnet 10.0.2.2 10023 Trying 10.0.2.2 ... Connected to 10.0.2.2. Escape character is '^]'. Ubuntu 14.04 LTS lab login:
SSL Telnet using stone
Now Lets try to run a secure telnet to the outer side of the wireless interface.
Install SSL Telnet Client
sudo apt-get install telnet-ssl
sudo stone localhost:telnet 10023/ssl
$telnet-ssl localhost 10023
Multiple rules using stone
If you want to combine more than one redirection rule then use “–” as the seperator for adding multiple rules.
sudo stone 192.168.1.2:telnet 10.0.2.2:10023 -- 192.168.1.2:ssh 10.0.2.2:10022 -- 192.168.1.2:ftp 10.0.2.2:10021
Proxy service using Stone
Stone can also be used as a proxy server with and without authentication. This example
is without using authentication.
$sudo stone proxy 10.0.2.2:8080 $export http_proxy=10.0.2.2:8080 $wget www.google.com
Truly the stone tool is a swiss army knife. Refer to man page for more examples. If you find this article interesting kindly share it, if you have any feedback or correction please comment below.