Openvpn: internet traffic out of the tunnel

Scripts with setup, destroy, and modify routing tables and firewall rulesets for client connections.

Moderators: TinCanTech, TinCanTech, TinCanTech, TinCanTech, TinCanTech, TinCanTech

Post Reply
etnal
OpenVpn Newbie
Posts: 1
Joined: Mon Oct 14, 2013 12:04 pm

Openvpn: internet traffic out of the tunnel

Post by etnal » Mon Oct 14, 2013 12:47 pm

Hi all,

this is my problem:

I'm always out of my company, so I use openvpn to access my email (through Outlook using IMAP protocol) and to use the intranet apps on the company webportal.
Probably the server (I can't access it) uses the redirect-gateway command, so, when the vpn is on I can't surf on internet.

I tried to modify the config file in this way:

- I added the route-nopull command
- I added the routes pushed by the server (I copied them from the log file) using the syntax "route xxx.xxx.xxx.xxx yyy.yyy.yyy.yyy zzz.zzz.zzz.zzz" where xxx.xxx.xxx.xxx is the IP, yyy.yyy.yyy.yyy is the subnet mask and zzz.zzz.zzz.zzz is the VPN gateway.
In this way it didn't work (it worked internet because of the route-nopull command, but it didn't work the company email/intranet.

Afterwards I made this modification:

- I left the route-nopull command in the config file
- I added the routes in a windows batch file, using for each route the syntax "C:\WINDOWS\system32\route.exe ADD xxx.xxx.xxx.xxx MASK yyy.yyy.yyy.yyy zzz.zzz.zzz.zzz" where xxx.xxx.xxx.xxx is the IP, yyy.yyy.yyy.yyy is the subnet mask and zzz.zzz.zzz.zzz is the VPN gateway.

After this modification, first I connect to the VPN, then I launch the script, and now I can surf on internet, the mail works perfectly, but I can't access to the intranet webportal.

This is the routing table with this last configuration:
===========================================================================
Elenco interfacce
0x1 ........................... MS TCP Loopback interface
0x2 ...00 24 7e 75 eb ca ...... Driver del server di accesso alla rete LAN Bluetooth - Miniport dell'Utilità di pianificazione pacchetti
0x3 ...00 25 b3 5c 03 d3 ...... Broadcom NetLink (TM) Gigabit Ethernet - Miniport dell'Utilità di pianificazione pacchetti
0x4 ...00 22 fa ee 91 30 ...... Intel(R) Wireless WiFi Link 5100 - Miniport dell'Utilità di pianificazione pacchetti
0x5 ...00 ff 32 4f 5d dc ...... TAP-Windows Adapter V9 - Miniport dell'Utilità di pianificazione pacchetti
===========================================================================
===========================================================================
Route attive:
Indirizzo rete Mask Gateway Interfac. Metric
0.0.0.0 0.0.0.0 172.23.211.126 172.23.211.175 1
10.0.0.0 255.0.0.0 10.166.0.1 10.166.4.10 1
10.166.0.0 255.255.0.0 10.166.4.10 10.166.4.10 30
10.166.4.10 255.255.255.255 127.0.0.1 127.0.0.1 30
10.241.231.0 255.255.255.0 10.166.0.1 10.166.4.10 1
10.255.255.255 255.255.255.255 10.166.4.10 10.166.4.10 30
91.200.209.32 255.255.255.224 10.166.0.1 10.166.4.10 1
127.0.0.0 255.0.0.0 127.0.0.1 127.0.0.1 1
151.89.0.0 255.255.0.0 10.166.0.1 10.166.4.10 1
169.254.0.0 255.255.0.0 172.23.211.175 172.23.211.175 1
172.16.0.0 255.240.0.0 10.166.0.1 10.166.4.10 1
172.23.211.0 255.255.255.0 172.23.211.175 172.23.211.175 20
172.23.211.175 255.255.255.255 127.0.0.1 127.0.0.1 20
172.23.255.255 255.255.255.255 172.23.211.175 172.23.211.175 20
192.106.63.0 255.255.255.0 10.166.0.1 10.166.4.10 1
192.106.63.12 255.255.255.255 10.166.0.1 10.166.4.10 1
192.168.6.0 255.255.255.0 10.166.0.1 10.166.4.10 1
192.168.9.0 255.255.255.0 10.166.0.1 10.166.4.10 1
192.168.11.0 255.255.255.0 10.166.0.1 10.166.4.10 1
192.168.61.0 255.255.255.0 10.166.0.1 10.166.4.10 1
192.168.232.0 255.255.255.0 10.166.0.1 10.166.4.10 1
193.111.46.5 255.255.255.255 172.23.211.126 172.23.211.175 1
194.91.45.0 255.255.255.0 10.166.0.1 10.166.4.10 1
199.99.150.0 255.255.255.0 10.166.0.1 10.166.4.10 1
224.0.0.0 240.0.0.0 10.166.4.10 10.166.4.10 30
224.0.0.0 240.0.0.0 172.23.211.175 172.23.211.175 20
255.255.255.255 255.255.255.255 10.166.4.10 10.166.4.10 1
255.255.255.255 255.255.255.255 172.23.211.175 4 1
255.255.255.255 255.255.255.255 172.23.211.175 172.23.211.175 1
255.255.255.255 255.255.255.255 172.23.211.175 2 1
Gateway predefinito: 172.23.211.126
===========================================================================
Route permanenti:
Nessuno
and this is the config file:
##############################################
# Sample client-side OpenVPN 2.0 config file #
# for connecting to multi-client server. #
# #
# This configuration can be used by multiple #
# clients, however each client should have #
# its own cert and key files. #
# #
# On Windows, you might want to rename this #
# file so it has a .ovpn extension #
##############################################

# Specify that we are a client and that we
# will be pulling certain config file directives
# from the server.
client

# Use the same setting as you are using on
# the server.
# On most systems, the VPN will not function
# unless you partially or fully disable
# the firewall for the TUN/TAP interface.
dev tap
;dev tun

# Windows needs the TAP-Win32 adapter name
# from the Network Connections panel
# if you have more than one. On XP SP2,
# you may need to disable the firewall
# for the TAP adapter.
;dev-node MyTap

# Are we connecting to a TCP or
# UDP server? Use the same setting as
# on the server.
;proto tcp
proto udp

# The hostname/IP and port of the server.
# You can have multiple remote entries
# to load balance between the servers.
remote 193.111.46.5 1194
;remote my-server-2 1194

# Choose a random host from the remote
# list for load-balancing. Otherwise
# try hosts in the order specified.
;remote-random

# Keep trying indefinitely to resolve the
# host name of the OpenVPN server. Very useful
# on machines which are not permanently connected
# to the internet such as laptops.
resolv-retry infinite

# Most clients don't need to bind to
# a specific local port number.
nobind

# Downgrade privileges after initialization (non-Windows only)
;user nobody
;group nobody

# Try to preserve some state across restarts.
persist-key
persist-tun

# If you are connecting through an
# HTTP proxy to reach the actual OpenVPN
# server, put the proxy server/IP and
# port number here. See the man page
# if your proxy server requires
# authentication.
;http-proxy-retry # retry on connection failures
;http-proxy [proxy server] [proxy port #]

# Wireless networks often produce a lot
# of duplicate packets. Set this flag
# to silence duplicate packet warnings.
;mute-replay-warnings

# SSL/TLS parms.
# See the server config file for more
# description. It's best to use
# a separate .crt/.key file pair
# for each client. A single ca
# file can be used for all clients.
ca comp-ca.crt
cert etnal.crt
key etnal.key

# Verify server certificate by checking
# that the certicate has the nsCertType
# field set to "server". This is an
# important precaution to protect against
# a potential attack discussed here:
# http://openvpn.net/howto.html#mitm
#
# To use this feature, you will need to generate
# your server certificates with the nsCertType
# field set to "server". The build-key-server
# script in the easy-rsa folder will do this.
;ns-cert-type server

# If a tls-auth key is used on the server
# then every client must also have the key.
;tls-auth key 1

# Select a cryptographic cipher.
# If the cipher option is used on the server
# then you must also specify it here.
;cipher x


# Enable compression on the VPN link.
# Don't enable this unless it is also
# enabled in the server config file.
comp-lzo

# Set log file verbosity.
verb 3

# Silence repeating messages
mute 20

route-nopull
My goal is, of course, to surf in internet, access to email and intranet at the same time.

Any suggestion? Thanks in advance!

florit
OpenVpn Newbie
Posts: 8
Joined: Tue Dec 08, 2015 10:49 pm

Re: Openvpn: internet traffic out of the tunnel

Post by florit » Wed Dec 09, 2015 11:52 pm

Fixed ip Gateway and DNS Servers !!!

It's simple modify the tap Adapter IPv4 options

Post Reply