1

Hi I am connecting to my private server through an OpenVPN using a .ovpn configuration. However when I am connected to the VPN I need to access some servers in my Local Network with the ip range 10...* How can I selectivley not route the LAN traffic while routing all other traffic through openvpn I get the following log when connecting

Mon Oct 13 05:20:16 2014 /sbin/ip link set dev tun0 up mtu 1500
Mon Oct 13 05:20:16 2014 /sbin/ip addr add dev tun0 172.27.232.12/21 broadcast 172.27.239.255
Mon Oct 13 05:20:21 2014 ROUTE remote_host is NOT LOCAL
Mon Oct 13 05:20:21 2014 /sbin/ip route add 107.170.153.39/32 via 10.52.128.1
Mon Oct 13 05:20:21 2014 /sbin/ip route add 0.0.0.0/1 via 172.27.232.1
Mon Oct 13 05:20:21 2014 /sbin/ip route add 128.0.0.0/1 via 172.27.232.1
Mon Oct 13 05:20:21 2014 Initialization Sequence Completed
2
  • did you try to run a route command locally to send all 10.* traffic to your gateway yet?
    – Mike
    Oct 13, 2014 at 12:33
  • What is the command i am not much familliar with linux routing Oct 13, 2014 at 12:34

2 Answers 2

3

I don't think you can do this in a openvpn config. So you have to do it post connect but something like

 ip route add 10.0.1.0/24  dev eth0

That assumes your local lan is on 10.0.1.0/24 and your connection to that lan is eth0

4
  • actually all ips from 10.0.0.0 to 10.255.255.255 belongs to my LAN so if i use 10.0.0.0/2 is it correct ?? Oct 13, 2014 at 12:42
  • no it would be 10.0.0.0/8
    – Mike
    Oct 13, 2014 at 12:45
  • ip route add 10.0.0.0/8 dev eth0 worked ill edit your answer Oct 13, 2014 at 12:48
  • ip route add 10.0.0.0/8 via 10.52.128.1 dev eth0 worked finally Oct 13, 2014 at 14:06
1

EDIT: I realized I misread your question. Mike's answer works for you but I'm not sure it will be persistent across reboot.

In your openvpn configuration file you could do something like:

Server config

push "route 10.0.0.0 255.0.0.0"

OR you could add this in your client config

route 10.0.0.0 255.0.0.0
4
  • I am having a .ovpn config where should i add this ? Oct 13, 2014 at 12:50
  • If you control the openvpn server you would add it there, server.conf for example. Otherwise add "route 10.0.0.0 255.0.0.0" to your .ovpn without quotes.
    – Grimmjow
    Oct 13, 2014 at 12:53
  • Mikes answer gave an error i improvised it . if i am spcifying the gateway how can i use it in your command Oct 13, 2014 at 14:07
  • Well you can't really. You need to manually add a route from your computer to your local servers. If you control the openvpn server though, you could stop redirecting all traffic via VPN and only allow traffic to your server behind the VPN. The rest goes through your normal router and you would have access to your local servers.
    – Grimmjow
    Oct 13, 2014 at 21:41

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .