LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Networking (https://www.linuxquestions.org/questions/linux-networking-3/)
-   -   Tun/Tap driver - IPv4 in IPv6 (https://www.linuxquestions.org/questions/linux-networking-3/tun-tap-driver-ipv4-in-ipv6-802349/)

the_ionic 04-16-2010 03:54 AM

Tun/Tap driver - IPv4 in IPv6
 
My problem is the following:
I want to use tun driver for implementing an IPv4-in-IPv6 tunneling mechanism. I know that IP4-in-IP6 tunnel are available in Linux but I have specific needs which lead me to use tun driver.
I have a 2 machines, a client and a server, each one having an IPv4 address. My goal is to encapsulate IPv4 packets from client to server in IPv6 tunnel. For that, I use an userspace program conjointly with tun driver. This program create one tunnel for encaspulating(tun46) and one tunnel for decapsulating (tun64) on both client and server. Encapsulation and decapsulation functions are written by myself.
So by using tun driver, I succeed to intercept IPv4 packets (in that case a ping from client to server) from client in userspace (in fact a default route indicate that all IPv4 packet should go to tun46), to encapsulate it thanks to C code that I wrote, and to send it to the server by the tunnel.
The server receives the encapsulated packet but the problem begins. If I put the destination IPv6 address of the encapsulated packet on the interface which receives the packet on server side, the server replies immediately with ICMPv6 parameter problem because it doesn't know how to handle the IPv4-in-IPv6 packet. If I dont put any IPv6 address, the packet is correctly routed to tun64, and decapsulated without any problem but the decapsulated packet (so the IPv4 ping) is delivered through the tunnel tun64 and never routed through the server interface which has the IPv4 destination address. I try to change route but it never works.
Do you have any ideas?

Regards

TimothyEBaldwin 04-17-2010 03:13 AM

You seem to be expecting that when a computer receives a packet addressed to itself it sends it elsewhere.

the_ionic 04-17-2010 09:45 AM

Quote:

Originally Posted by TimothyEBaldwin (Post 3938282)
You seem to be expecting that when a computer receives a packet addressed to itself it sends it elsewhere.

Not really but I understand what you mean. What I need is an encapsulation/decapsulation IPv4-in-IPv6 solution but with specific needs. After browsing a while on the Internet, I'm sure that tun/tap driver allows me to do that.
Maybe I misunderstand tun/tap and tunnels in general but what I'm trying to do is simply to establish tunnel between 2 hosts.
So it's normal that when the ICMPv4 packet encaspulated in IPv6 from the client to the server goes through the server decap interface (tun64), I expect that tun64 decapsulates IPv6 header (and it works ;)), and also that tun64 delivers the packet to the server's real interface in IPv4. It's the normal role of a tunnel and that what I'm trying to do, not to deliver a packet addressed to a host to another.

TimothyEBaldwin 04-17-2010 07:48 PM

Quote:

Originally Posted by the_ionic (Post 3938537)
and also that tun64 delivers the packet to the server's real interface in IPv4. It's the normal role of a tunnel

You said the packet was addressed to the server, which is doing the de-encapsulation, in which case it would be completely broken to send the packet to another interface as it should be locally processed.


All times are GMT -5. The time now is 05:04 PM.