Configuration: route specific traffic over Openvpn
Posted: Wed Sep 21, 2011 3:22 pm
Hi,
Openvpn rocks!
It works through proxy as well as on my iphone.
However I have 1 practical question (when connected from work to home OpenVPN):
=> I would like to route as well my LAN traffic (192.168.x.x) as Internet traffic through my
OpenVPN. It would be nice to be able to set exceptions also, f.e. not www.google.be.
How to achieve this? Should I setup a proxy on my NAS and how to route the traffic?
Any input on my config is also welcome!
Cheers,
J.
Server: Synology NAS with OpenVPN package, LAN = 192.168.x.x, VPN IP = 172.16.x.x
Client: Windows XP with OpenVPN portable
SETTINGS CLIENT:
----------------
dev tun
tls-client
remote mydyndnsaddress 8080
# If redirect-gateway is enabled, the client will redirect it's
# default network gateway through the VPN.
# It means the VPN connection will firstly connect to the VPN Server
# and then to the internet.
# (Please refer to the manual of OpenVPN for more information.)
#redirect-gateway
pull
proto tcp-client
script-security 2
ca ca.crt
comp-lzo
reneg-sec 0
auth-user-pass
SETTINGS SERVER:
-----------------
DS> vi openvpn.conf
push "route 192.168.1.0 255.255.255.0"
push "route 172.16.1.0 255.255.255.0"
dev tun
# management 127.0.0.1 1195 => changed this to ip of NAS
management mylocalipofnas 1195
server 172.16.1.0 255.255.255.0
dh /usr/local/synovpn/etc/openvpn/keys/dh1024.pem
ca /usr/local/synovpn/etc/openvpn/keys/ca.crt
cert /usr/local/synovpn/etc/openvpn/keys/server.crt
key /usr/local/synovpn/etc/openvpn/keys/server.key
max-clients 5
comp-lzo
persist-tun
persist-key
verb 3
#log-append /var/log/openvpn.log
keepalive 10 60
reneg-sec 0
plugin /usr/local/synovpn/lib/radiusplugin.so /usr/local/synovpn/etc/openvpn/rad
client-cert-not-required
username-as-common-name
duplicate-cn
proto tcp
~
auth-user-pass
ROUTE PRINT on PC WORK:
-----------------------
Active Routes:
Network Destination Netmask Gateway Interface Metric
0.0.0.0 0.0.0.0 10.101.161.254 10.101.161.129 1
10.101.160.0 255.255.254.0 10.101.161.129 10.101.161.129 20
10.101.161.129 255.255.255.255 127.0.0.1 127.0.0.1 20
10.255.255.255 255.255.255.255 10.101.161.129 10.101.161.129 20
127.0.0.0 255.0.0.0 127.0.0.1 127.0.0.1 1
172.16.1.0 255.255.255.0 172.16.1.5 172.16.1.6 1
172.16.1.1 255.255.255.255 172.16.1.5 172.16.1.6 1
172.16.1.4 255.255.255.252 172.16.1.6 172.16.1.6 30
172.16.1.6 255.255.255.255 127.0.0.1 127.0.0.1 30
172.16.255.255 255.255.255.255 172.16.1.6 172.16.1.6 30
192.168.1.0 255.255.255.0 172.16.1.5 172.16.1.6 1
224.0.0.0 240.0.0.0 10.101.161.129 10.101.161.129 20
224.0.0.0 240.0.0.0 172.16.1.6 172.16.1.6 30
255.255.255.255 255.255.255.255 10.101.161.129 10.101.161.129 1
255.255.255.255 255.255.255.255 10.101.161.129 2 1
255.255.255.255 255.255.255.255 172.16.1.6 172.16.1.6 1
Default Gateway: 10.101.161.254
===========================================================================
Persistent Routes:
None
Note that the openvpn adminpage is not implemented, don't know if I can put this/install this on the NAS?
Openvpn rocks!
It works through proxy as well as on my iphone.
However I have 1 practical question (when connected from work to home OpenVPN):
=> I would like to route as well my LAN traffic (192.168.x.x) as Internet traffic through my
OpenVPN. It would be nice to be able to set exceptions also, f.e. not www.google.be.
How to achieve this? Should I setup a proxy on my NAS and how to route the traffic?
Any input on my config is also welcome!
Cheers,
J.
Server: Synology NAS with OpenVPN package, LAN = 192.168.x.x, VPN IP = 172.16.x.x
Client: Windows XP with OpenVPN portable
SETTINGS CLIENT:
----------------
dev tun
tls-client
remote mydyndnsaddress 8080
# If redirect-gateway is enabled, the client will redirect it's
# default network gateway through the VPN.
# It means the VPN connection will firstly connect to the VPN Server
# and then to the internet.
# (Please refer to the manual of OpenVPN for more information.)
#redirect-gateway
pull
proto tcp-client
script-security 2
ca ca.crt
comp-lzo
reneg-sec 0
auth-user-pass
SETTINGS SERVER:
-----------------
DS> vi openvpn.conf
push "route 192.168.1.0 255.255.255.0"
push "route 172.16.1.0 255.255.255.0"
dev tun
# management 127.0.0.1 1195 => changed this to ip of NAS
management mylocalipofnas 1195
server 172.16.1.0 255.255.255.0
dh /usr/local/synovpn/etc/openvpn/keys/dh1024.pem
ca /usr/local/synovpn/etc/openvpn/keys/ca.crt
cert /usr/local/synovpn/etc/openvpn/keys/server.crt
key /usr/local/synovpn/etc/openvpn/keys/server.key
max-clients 5
comp-lzo
persist-tun
persist-key
verb 3
#log-append /var/log/openvpn.log
keepalive 10 60
reneg-sec 0
plugin /usr/local/synovpn/lib/radiusplugin.so /usr/local/synovpn/etc/openvpn/rad
client-cert-not-required
username-as-common-name
duplicate-cn
proto tcp
~
auth-user-pass
ROUTE PRINT on PC WORK:
-----------------------
Active Routes:
Network Destination Netmask Gateway Interface Metric
0.0.0.0 0.0.0.0 10.101.161.254 10.101.161.129 1
10.101.160.0 255.255.254.0 10.101.161.129 10.101.161.129 20
10.101.161.129 255.255.255.255 127.0.0.1 127.0.0.1 20
10.255.255.255 255.255.255.255 10.101.161.129 10.101.161.129 20
127.0.0.0 255.0.0.0 127.0.0.1 127.0.0.1 1
172.16.1.0 255.255.255.0 172.16.1.5 172.16.1.6 1
172.16.1.1 255.255.255.255 172.16.1.5 172.16.1.6 1
172.16.1.4 255.255.255.252 172.16.1.6 172.16.1.6 30
172.16.1.6 255.255.255.255 127.0.0.1 127.0.0.1 30
172.16.255.255 255.255.255.255 172.16.1.6 172.16.1.6 30
192.168.1.0 255.255.255.0 172.16.1.5 172.16.1.6 1
224.0.0.0 240.0.0.0 10.101.161.129 10.101.161.129 20
224.0.0.0 240.0.0.0 172.16.1.6 172.16.1.6 30
255.255.255.255 255.255.255.255 10.101.161.129 10.101.161.129 1
255.255.255.255 255.255.255.255 10.101.161.129 2 1
255.255.255.255 255.255.255.255 172.16.1.6 172.16.1.6 1
Default Gateway: 10.101.161.254
===========================================================================
Persistent Routes:
None
Note that the openvpn adminpage is not implemented, don't know if I can put this/install this on the NAS?