Thread: Help with forwarding packets from a Tun to an Eth interface
[********solved*********]
morning all,
have c-program creates tun (tun0) , writes it. part works fine, want packets forwarded on eth0 (different network), unfortunately not working.
if force ping src of tun0 exits via eth0 - happy routes correct.
additional information can provide me resolve appreciated - see below interfaces information.
tun setup these flags:
after program sets them set ip addresses. network resembles this:code:iff_up | iff_running | iff_noarp | iff_promisc
ip forwarding on via:code:machine1: tun0 | | eth0 | 192.168.1.1/28 | - | 10.1.1.1/16 |---| | machine2: | tun0 | | eth0 | | 192.168.2.1/28 | - | 10.1.2.1/16 |---|
ifconfig gives me this:code:sysctl -w net.ipv4.ip_forward=1
(it worth noting setting ip addresses manually, after program has set tun. using ifconfig tun0 192.168.1.1/28.code:tun0 link encap:unspec hwaddr 00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00 inet addr:192.168.1.1 p-t-p:192.168.1.1 mask:255.255.255.240 pointopoint running noarp promisc multicast mtu:1500 metric:1 rx packets:694 errors:0 dropped:0 overruns:0 frame:0 tx packets:0 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:500 rx bytes:80504 (80.5 kb) tx bytes:0 (0.0 b) eth0 link encap:ethernet hwaddr 52:54:00:9a:bc:9a inet addr:10.1.1.1 bcast:10.1.255.255 mask:255.255.0.0 inet6 addr: fe80::5054:ff:fe9a:bc9a/64 scope:link broadcast running multicast mtu:1500 metric:1 rx packets:18076 errors:0 dropped:65 overruns:0 frame:0 tx packets:537 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:1000 rx bytes:2017435 (2.0 mb) tx bytes:74778 (74.7 kb) lo link encap:local loopback inet addr:127.0.0.1 mask:255.0.0.0 inet6 addr: ::1/128 scope:host loopback running mtu:16436 metric:1 rx packets:46 errors:0 dropped:0 overruns:0 frame:0 tx packets:46 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:0 rx bytes:3450 (3.4 kb) tx bytes:3450 (3.4 kb)
, routing table:
i've been pulling hair out bit this, , have tried several solutions have found while researching on internet. including iptables forwarding having no luck this.code:default via 10.1.2.1 dev eth0 metric 100 10.1.0.0/16 dev eth0 proto kernel scope link src 10.1.1.1 192.168.0.0/16 dev eth0 scope link src 192.168.14.1 192.168.1.0/28 dev tun0 proto kernel scope link src 192.168.1.1
if tcpdump tun0 see:
but nothing of sorts while tcpdump on eth0code:11:43:00.847394 ip 192.168.1.1 > 192.168.2.1
appreciated.
many thanks,
chris.
follow up:
have come solution. appears tun route user space , other tun/taps.
have re-coded program read in on tun, read out complete sendto() raw socket (ipproto_raw iphdr_incl), drops packet stack , lets sort out!
has allowed me achieve want, , packets being routed out of machine correctly.
regards,
chris.
edit: not sure how set 'solved', mod honours - thank you.
Forum The Ubuntu Forum Community Ubuntu Official Flavours Support Networking & Wireless [ubuntu] Help with forwarding packets from a Tun to an Eth interface
Ubuntu
Comments
Post a Comment