Forwarding traffic from TUN device (C++ backend) to the default gateway

Solution 1:

Alternative solution would be using bridge.So you can bridge your tun0 with eth0 and there is no need for nat or setting ip on tun0 you just put IPs from the same subnet of eth0 and same gateway you are using right now on clients' tunnel interfaces.

Commands for setting a bridge up:

# brctl addbr br0
# brctl addif br0 eth0 tun0

www.tldp.org/HOWTO/BRIDGE-STP-HOWTO/set-up-the-bridge

To use brctl you have to install bridge-utils package.
If your distro is Ubuntu: aptitude install bridge-utils

Solution 2:

I recently ran into this problem (following the same article mention in the question) and after fiddling around a little, I found that the following command enable the local forwarding of the packets for the tun device.

echo 1 > /proc/sys/net/ipv4/conf/tun0/accept_local

I know its very late, I am just posting here so that anybody who faces the same issue can have some kind of help.