Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>How did you set the IP address of the tun tap interface? Using <code>"ip addr add"</code> command? Have you checked/configured the tun tap to be up ie <code>"ip link set &lt;&lt;tun tap interface name&gt;&gt; up"</code>? Lastly are you sure your UDP socket sendto code runs after the previous said two conditions are satisfied ie it has the correct ip address and tun tap interface is up.</p> <p><strong>Update</strong></p> <p>I think you are getting the concept wrong or I didnt understand you very well. AFAIK you dont need to do these many things. The concept of the tun tap device is that whatever packets the tun tap interface receives its sent to the userspace program and whatever the userspace program writes to the tun tap device, its sent to the network. Having said this and reading that your requirement is to tunnel the UDP packets to the serial interface, what you should do is the following</p> <p>1) Set the default route to the tun tap IP address. In this way all the packets will be got by userspace program. <code>route add default gw 192.168.2.1 tun0</code></p> <p>So now in the userspace program you get the whole packet with the IP and UDP headers. Now this whole packet will be the message that you want to transfer via the serial interface. So when we send it via the serial interface using UDP or TCP(whichever you prefer), we are automatically again encapsulting the whole packet with one more UDP and IP header.</p> <p>2) You also need to add a host rule with the serial interface address. In this way the above said encapsulated packets for the serial interface are sent to the serial interface and they dont come back again to the TUN TAP device due to the default rule. <code>route add -host &lt;&lt;serial ip address&gt;&gt; dev &lt;&lt;serial device&gt;&gt;</code></p> <p>Give <code>route -n</code> and check if the routing is right. Make sure that you dont have other unwanted routes. If yes delete them.</p> <p><em>Note:</em> Also you can extract just the payload from the packet and using RAW sockets create a custom UDP header with the destination as the serial interface's IP address and write using the TUN TAP device. This packet will be seen as the kernel routing instance as belonging to the serial interface and will be forwarded to there because of the host rule. If you are going for this case you need to create a do a custom IP and UDP header and also CRC calculation.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload