title: Routing traffic with TUN/TAP interface
body: <p>I am new to network programming and try to understand managing traffic via TUN/TAP interface. </p>
  
  <p>Since I have almost nonexistent system programming skills, and feel confident on Java; I use OpenVPN tun/tap driver and ready made Java binding for it. It works on TAP mode.</p>
  
  <p>As an example application I am trying to imitiate no encryption, no authentication client server VPN application.</p>
  
  <p>I can catch Ethernet Frame packets, but for the routing part, I failed miserably. (I can modify route/arp tables.)</p>
  
  <ol>
  <li><p>Do anybody know how OpenVPN send packets from client to server, and from server to target. Opening sockets from Java looks like an alternative; but I was hoping that modifying packets(change IPs and/or MAC addresses) and writing back to the virtual tap interface would be enough. Is it so?</p></li>
  <li><p>Can I inject packets to send other locations, or by default received packet moves towards application layer?</p></li>
  </ol>
  
  <p>-- Edit:</p>
  
  <p>Scneario</p>
  
  <pre><code>Client Tap0 _____ Server Tap0 ______ Target
         Eth0              Eth0
  </code></pre>
  
  <p>Target: Ping from client, move through tap interfaces, target see only server ip (anonymization)</p>
  
  <p>What I achived so far.</p>
  
  <ul>
  <li><p>Catch traffic at client tap0 interface. </p></li>
  <li><p>I coulnt forward traffic at server Tap so to fasten things I used Java socket programming between client-server.</p></li>
  </ul>
  
  <p>Now I read packets from socket at server, and try to OpenVPN Tap driver's write method to move forward but I am not sure where do I fail. I see packets with tcpdump at server tap0, but they do not pass to server eth0.</p>
  
  <p>My most important question is if I modify packet(ip, mac address) and call write method, is it possible that packet moves forward. (Or does it move to application layer whatever you change??)</p>
  
  <p>Any help would be appreciated.</p>