title: socat: tunnel IP through TTY
body: <p>Is it possible to get an bidirectional IP-tunnel over ttyS0-like serial (modem) devices with the <strong>socat</strong> utility? I tried to use TUN option but still can't get the result.</p>
  
  <p>Any suggestions are welcome :)</p>
  
  <p><em>Update:</em></p>
  
  <p>PC1:</p>
  
  <pre><code>socat /dev/ttyUSB0,raw,echo=0,b57600,clocal TUN:192.168.1.1/24,up
  </code></pre>
  
  <p>PC2:</p>
  
  <pre><code>socat /dev/ttyUSB0,raw,echo=0,b57600,clocal TUN:192.168.1.2/24,up
  </code></pre>
  
  <p>After that, I have seen tun0 interfaces with proper addresses on both ends but I can't ping one from other. Instead of that, when I send data with <code>ping -c 1 192.168.1.1</code> remote <code>socat</code> process exits and it's tun0 device destroyed. Any suggestions?..</p>
  
  <p><em>Update2:</em></p>
  
  <p>There is a framing problem when we try to make TCP/IP tunnel over serial with only socat. Gerhard Rieger, the socat's developer, says me that:</p>
  
  <blockquote>
    <p>I am afraid that you are right. tun
    over datagram socket works, and - by
    luck - also over pipes. But over the
    serial line the packet boundaries may
    vanish and this is fatal when sending
    the data out on the tun interface.</p>
    
    <p>I cannot offer a socat based solution
    now, sorry. However, I will try to
    integrate some framing in a later
    version 2 release.</p>
  </blockquote>