<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Ryota Arai</title>
    <description>The latest articles on DEV Community by Ryota Arai (@ryotarai).</description>
    <link>https://dev.to/ryotarai</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F143225%2F8dce7482-5d6e-4e33-96a3-d3e516ddd0d0.jpeg</url>
      <title>DEV Community: Ryota Arai</title>
      <link>https://dev.to/ryotarai</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/ryotarai"/>
    <language>en</language>
    <item>
      <title>Mallet - a TCP tunnel like VPN</title>
      <dc:creator>Ryota Arai</dc:creator>
      <pubDate>Wed, 29 Jul 2020 14:40:11 +0000</pubDate>
      <link>https://dev.to/ryotarai/mallet-a-tcp-tunnel-like-vpn-1c8e</link>
      <guid>https://dev.to/ryotarai/mallet-a-tcp-tunnel-like-vpn-1c8e</guid>
      <description>&lt;p&gt;I've developed a TCP tunnel, called &lt;a href="https://github.com/ryotarai/mallet"&gt;"Mallet"&lt;/a&gt;, that works like VPN. It depends on &lt;a href="https://github.com/jpillora/chisel"&gt;jpillora/chisel&lt;/a&gt; for TCP tunneling.&lt;br&gt;
You just need to run a chisel server in a machine that you would like to get traffic through.&lt;/p&gt;

&lt;p&gt;Mallet configures iptables (Linux) or pf (macOS) to redirect traffic to the TCP tunnel.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--zn045QqB--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/uevyne8zfyem9jnxpfsy.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--zn045QqB--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/uevyne8zfyem9jnxpfsy.png" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;
&lt;h2&gt;
  
  
  Features
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;No admin privilege required in a server. You just need SSH as a normal user.

&lt;ul&gt;
&lt;li&gt;You still need sudo right in a client machine to redirect traffic.&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;Encrypted connection (thanks to chisel)&lt;/li&gt;
&lt;li&gt;Performant (thanks to chisel)&lt;/li&gt;
&lt;/ul&gt;
&lt;h2&gt;
  
  
  Installation
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://github.com/ryotarai/mallet#installation"&gt;https://github.com/ryotarai/mallet#installation&lt;/a&gt;&lt;/p&gt;
&lt;h2&gt;
  
  
  Usage
&lt;/h2&gt;

&lt;p&gt;Assume that you have a server &lt;code&gt;a.example.com&lt;/code&gt; and would like to get traffic to 10.0.0.0/8 through &lt;code&gt;a.example.com&lt;/code&gt;:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Laptop --&amp;gt; a.example.com --&amp;gt; 10.0.0.0/8
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;First, install chisel to a.example.com by following &lt;a href="https://github.com/jpillora/chisel#install"&gt;https://github.com/jpillora/chisel#install&lt;/a&gt; and run chisel server:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;a.example.com$ chisel server --port 8080
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;(Keep this chisel process running)&lt;/p&gt;

&lt;p&gt;Then, run Mallet and connect to the chisel server:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$ sudo mallet start --chisel-server http://a.example.com:8080 10.0.0.0/8
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;(Keep this mallet process running)&lt;/p&gt;

&lt;p&gt;Now, all TCP traffic to 10.0.0.0/8 is forwarded via a.example.com.&lt;/p&gt;

&lt;h2&gt;
  
  
  Usage with SSH
&lt;/h2&gt;

&lt;p&gt;In this example, we will run Mallet via SSH port forwarding.&lt;/p&gt;

&lt;p&gt;Assume that you have a server &lt;code&gt;a.example.com&lt;/code&gt; and would like to get traffic to 10.0.0.0/8 through &lt;code&gt;a.example.com&lt;/code&gt;:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Laptop --SSH--&amp;gt; a.example.com --&amp;gt; 10.0.0.0/8
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;First, install chisel to a.example.com by following &lt;a href="https://github.com/jpillora/chisel#install"&gt;https://github.com/jpillora/chisel#install&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Second, launch chisel server on a.example.com and forward a port to the server:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$ ssh -t -L 8080:127.0.0.1:8080 a.example.com chisel server --host 127.0.0.1 --port 8080
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;(Keep this ssh process running)&lt;/p&gt;

&lt;p&gt;Then, start Mallet:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$ sudo mallet start --chisel-server http://127.0.0.1:8080 10.0.0.0/8
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;(Keep this mallet process running)&lt;/p&gt;

&lt;p&gt;Now, all TCP traffic to 10.0.0.0/8 is forwarded via a.example.com.&lt;/p&gt;

&lt;h2&gt;
  
  
  Comparison
&lt;/h2&gt;

&lt;p&gt;There is a similar project, &lt;a href="https://github.com/sshuttle/sshuttle"&gt;sshuttle&lt;/a&gt;. sshuttle supports IPv6 and UDP, that Mallet does not support, however Mallet is more performant than sshuttle.&lt;/p&gt;

&lt;p&gt;The following benchmark is measured by this method: &lt;a href="https://github.com/ryotarai/mallet#benchmark"&gt;https://github.com/ryotarai/mallet#benchmark&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  iperf benchmark
&lt;/h3&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;&lt;/th&gt;
&lt;th&gt;Throughput&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;(D) Direct&lt;/td&gt;
&lt;td&gt;4.98 Gbits/sec&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;(A) Mallet&lt;/td&gt;
&lt;td&gt;1.84 Gbits/sec&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;(B) Mallet over SSH&lt;/td&gt;
&lt;td&gt;1.04 Gbits/sec&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;(C) sshuttle&lt;/td&gt;
&lt;td&gt;0.279 Gbits/sec&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;h3&gt;
  
  
  HTTP benchmark (wrk and nginx)
&lt;/h3&gt;

&lt;p&gt;req/sec&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Concurrency (== Threads)&lt;/th&gt;
&lt;th&gt;1&lt;/th&gt;
&lt;th&gt;2&lt;/th&gt;
&lt;th&gt;4&lt;/th&gt;
&lt;th&gt;8&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;(D) Direct&lt;/td&gt;
&lt;td&gt;10174.78&lt;/td&gt;
&lt;td&gt;18137.10&lt;/td&gt;
&lt;td&gt;30328.02&lt;/td&gt;
&lt;td&gt;39130.81&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;(A) Mallet&lt;/td&gt;
&lt;td&gt;3560.81&lt;/td&gt;
&lt;td&gt;6772.88&lt;/td&gt;
&lt;td&gt;11054.35&lt;/td&gt;
&lt;td&gt;15576.85&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;(B) Mallet over SSH&lt;/td&gt;
&lt;td&gt;2465.27&lt;/td&gt;
&lt;td&gt;4434.10&lt;/td&gt;
&lt;td&gt;6881.70&lt;/td&gt;
&lt;td&gt;9767.50&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;(C) sshuttle&lt;/td&gt;
&lt;td&gt;2416.52&lt;/td&gt;
&lt;td&gt;4254.54&lt;/td&gt;
&lt;td&gt;5491.61&lt;/td&gt;
&lt;td&gt;469.49 (socket write error: 14)&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;avg latency&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Concurrency (== Threads)&lt;/th&gt;
&lt;th&gt;1&lt;/th&gt;
&lt;th&gt;2&lt;/th&gt;
&lt;th&gt;4&lt;/th&gt;
&lt;th&gt;8&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;(D) Direct&lt;/td&gt;
&lt;td&gt;95.85us&lt;/td&gt;
&lt;td&gt;107.50us&lt;/td&gt;
&lt;td&gt;128.92us&lt;/td&gt;
&lt;td&gt;211.63us&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;(A) Mallet&lt;/td&gt;
&lt;td&gt;279.71us&lt;/td&gt;
&lt;td&gt;295.74us&lt;/td&gt;
&lt;td&gt;368.46us&lt;/td&gt;
&lt;td&gt;526.68us&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;(B) Mallet over SSH&lt;/td&gt;
&lt;td&gt;406.29us&lt;/td&gt;
&lt;td&gt;452.08us&lt;/td&gt;
&lt;td&gt;586.36us&lt;/td&gt;
&lt;td&gt;823.74us&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;(C) sshuttle&lt;/td&gt;
&lt;td&gt;411.67us&lt;/td&gt;
&lt;td&gt;468.36us&lt;/td&gt;
&lt;td&gt;725.38us&lt;/td&gt;
&lt;td&gt;1.19ms&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

</description>
      <category>linux</category>
      <category>macos</category>
      <category>network</category>
      <category>vpn</category>
    </item>
  </channel>
</rss>
