0

We have five interfaces in the server.

I would like to route traffic from IP 10.8.0.150 behind tun0 to 10.130.219.68 behind interface em2.

I have enabled port forwarding and done IP tables rules but the traffic reaches the server but goes back to tun0, because .

How can I achieve this, to route traffic from a 10.8.0.150 behind tun0 to 10.130.219.68 behind interface em2 without interfering with other VPS communicating in the VPN (tun0)?

em2       Link encap:Ethernet  HWaddr 94:18:82:33:3a:85
          inet addr:172.17.247.242  Bcast:172.17.247.255  Mask:255.255.255.240
          inet6 addr: fe80::9618:82ff:fe33:3a85/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:1564 errors:0 dropped:0 overruns:0 frame:0
          TX packets:336 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:140656 (140.6 KB)  TX bytes:56927 (56.9 KB)
          Interrupt:19

lo        Link encap:Local Loopback
          inet addr:127.0.0.1  Mask:255.0.0.0
          inet6 addr: ::1/128 Scope:Host
          UP LOOPBACK RUNNING  MTU:65536  Metric:1
          RX packets:63491 errors:0 dropped:0 overruns:0 frame:0
          TX packets:63491 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1
          RX bytes:5828461 (5.8 MB)  TX bytes:5828461 (5.8 MB)

tun0      Link encap:UNSPEC  HWaddr 00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00
          inet addr:10.8.0.98  P-t-P:10.8.0.97  Mask:255.255.255.255
          UP POINTOPOINT RUNNING NOARP MULTICAST  MTU:1500  Metric:1
          RX packets:78487 errors:0 dropped:0 overruns:0 frame:0
          TX packets:89611 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:100
          RX bytes:7480633 (7.4 MB)  TX bytes:24983338 (24.9 MB)

ROUTES in host server :

default         10.2.0.1        0.0.0.0         UG    0      0        0 br1
10.0.0.0        10.8.0.97       255.255.255.0   UG    0      0        0 tun0
10.0.1.0        10.8.0.97       255.255.255.0   UG    0      0        0 tun0
10.2.0.0        *               255.255.255.0   U     0      0        0 br1
10.8.0.0        10.8.0.97       255.255.255.0   UG    0      0        0 tun0
10.8.0.97       *               255.255.255.255 UH    0      0        0 tun0
10.130.219.68   172.17.247.241  255.255.255.255 UGH   0      0        0 em2
128.0.0.0       10.8.0.97       128.0.0.0       UG    0      0        0 tun0
link-local      *               255.255.0.0     U     1000   0        0 em2
172.17.247.240  *               255.255.255.240 U     0      0        0 em2

Iptables in host:

-A FORWARD -i em2 -j ACCEPT
-A FORWARD -i tun0 -j ACCEPT
-A FORWARD -i em1 -j ACCEPT
-A FORWARD -i tun0 -o em2 -j ACCEPT
-A FORWARD -i em2 -o tun0 -j ACCEPT
-A FORWARD -i tun0 -o em2 -m state --state RELATED,ESTABLISHED -j ACCEPT

Routes in 10.8.0.150:

10.0.0.0        10.8.0.149      255.255.255.0   UG    0      0        0 tun0
10.0.1.0        10.8.0.149      255.255.255.0   UG    0      0        0 tun0
10.2.0.0        10.8.0.149      255.255.255.0   UG    0      0        0 tun0
10.8.0.0        10.8.0.149      255.255.255.0   UG    0      0        0 tun0
10.8.0.149      *               255.255.255.255 UH    0      0        0 tun0
10.18.0.0       *               255.255.0.0     U     0      0        0 eth0
10.130.219.60   *               255.255.255.255 UH    0      0        0 tun0
10.130.219.68   10.8.0.149      255.255.255.255 UGH   0      0        0 tun0

Traceroute from 10.8.0.150:

traceroute to 10.130.219.68 (10.130.219.68), 30 hops max, 60 byte packets
 1  10.8.0.1 (10.8.0.1)  179.067 ms  179.062 ms  179.073 ms
 2  10.0.0.1 (10.0.0.1)  179.083 ms  179.093 ms  179.104 ms

Your Answer

By clicking "Post Your Answer", you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.