3

Network

  WAN
 __|___
|Router|
 ‾‾|‾‾‾                                           ______
192.168.0.1----(192.168.0.0/24)----192.168.0.102-|Server|-192.168.3.1---(192.168.3.0/24)
                                                  ‾‾‾‾‾‾

Server

So I'm trying to set this up (A):

     192.168.0.102
 __________|____________
|          |            |
|         eth0--tun0    |
|          |      |     |
|   apache-|      |     |
|   ssh----|      |     |
|                 |     |
|_________________|_____|
                  |
             192.168.3.1

But, this is what I'm getting (B) :

     192.168.0.102
 __________|____________
|          |            |
|         eth0--tun0    |
|                 |     |
|   apache--------|     |
|   ssh-----------|     |
|                 |     |
|_________________|_____|
                  |
             192.168.3.1

 $ifconfig:
 eth0     Link encap:Ethernet  HWaddr 00:xx:xx:xx:xx:xx
          inet addr:192.168.0.102  Bcast:192.168.0.255  Mask:255.255.255.0

 tun0     Link encap:UNSPEC  HWaddr 00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00
          inet addr:10.114.0.4  P-t-P:10.114.0.4  Mask:255.255.0.0

 $route -n:
 Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
 0.0.0.0         10.114.0.1      128.0.0.0       UG    0      0        0 tun0
 0.0.0.0         192.168.0.1     0.0.0.0         UG    0      0        0 eth0
 10.114.0.0      0.0.0.0         255.255.0.0     U     0      0        0 tun0
 <VPN IP>        192.168.0.1     255.255.255.255 UGH   0      0        0 eth0
 128.0.0.0       10.114.0.1      128.0.0.0       UG    0      0        0 tun0
 192.168.0.0     0.0.0.0         255.255.255.0   U     1      0        0 eth0

Question

As soon as I start the openvpn service, I get the setup described in case B. Any trafic to/from the server uses the tun0 interface (and thus gets VPNd).

So, how do I make all trafic default to the eth0 interface, except trafic explicitly routed to tun0?

I tried setting the metric on tun0 to 100, using ifmetric after the openvpn service is started and set up. Trafic still defaults to tun0 however.

Is there maybe a conf value I can put in the .conf run by openvpn?

iptables is confed to route trafic from 192.168.3.1 to tun0.

2

It appears as if the server has:
push "redirect-gateway tun0" or some similar config that is causing the all traffic to go through the tun0 connection. You should be able to remove that rule and just push the subnets you need routed explicitly.

The following routing rule is the problem:
0.0.0.0 10.114.0.1 128.0.0.0 UG 0 0 0 tun0

| improve this answer | |
  • So I tried manually removing this rule, using "sudo route del default gw 10.114.0.1 netmask 128.0.0.0" & doing a network-service restart. And it disappears from the list. But trafic is still redirected. – Darajan Dec 8 '15 at 8:34
  • 1
    I am not sure how you are starting the VPN, but doing a network service restart will likely undo any route changes you have made. As I stated in the answer if you want to "fix" this (ie not have to do extra stuff) changes should be made on the server side. – Eddie Dunn Dec 8 '15 at 13:39

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.