1

I need to connect to my company's VPN in order to access internal websites and web applications, while I cannot access the regular internal when connecting to the VPN unless via a specific socks5 proxy. On a mac or PC, I can connect to openVPN and then use SwitchyOmega to connect to the socks5 proxy for websites that requires regular internet access, but on an Android or an iOS, I am not able to use openVPN and socks5 together.

I wish to know if I can (and how to) modify the client config file in order to specify a socks5 proxy behind openVPN tunnel to route through my traffic. Note, I have no privilege to change the server side config.

##############################################
# 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
;roto udp

# The hostname/IP and port of the server.
# You can have multiple remote entries
# to load balance between the servers.
remote fake.com 7777
;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 nogroup

# 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 ca.crt
;cert client.crt
;key client.key

# Verify server certificate by checking that the
# certicate has the correct key usage set.
# 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 keyUsage set to
#   digitalSignature, keyEncipherment
# and the extendedKeyUsage to
#   serverAuth
# EasyRSA can do this for you.
remote-cert-tls server

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

# Select a cryptographic cipher.
# If the cipher option is used on the server
# then you must also specify it here.
cipher AES-256-CBC
auth SHA256

# 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

# script-security 2
# up /etc/openvpn/update-resolv-conf
# down /etc/openvpn/update-resolv-conf
<ca>
-----BEGIN CERTIFICATE-----
xxx
-----END CERTIFICATE-----
</ca>

<tls-auth>
#
# 2048 bit OpenVPN static key
#
-----BEGIN OpenVPN Static key V1-----
xxx
-----END OpenVPN Static key V1-----
</tls-auth>

auth-user-pass
auth-nocache

Above is the mock version of .opvn file on my client side.

4
  • Unfortunately without seeing the client config, we cannot offer advice. Please provide the client config.
    – Daniel B
    Feb 17, 2022 at 9:30
  • @DanielB I am not sure why the specific client config should be provided (and should always not be provided due to it would involve security risk). Feb 17, 2022 at 10:16
  • Because OpenVPN has dozens of configuration options surrounding routing. Your goal here is not to specify a SOCKS proxy (not possible) but rather to set up split tunneling.
    – Daniel B
    Feb 17, 2022 at 10:32
  • @DanielB I updated my question. Feb 23, 2022 at 5:49

1 Answer 1

1

The config you present contains nothing about routing. This means routes will be pushed from the OpenVPN server. You need to take a look at the log file of a successful connection and check which routes are pushed. If you only get a redirect-gateway def1, you’ll have to figure out the routes yourself. Basically you take a look at the IP addresses you connect to (like 1.2.3.4) and create your own table of routing targets:

  1. 1.2.3.4/24
  2. 4.3.2.1/24

Then you modify the client config with the information you got:

route 1.2.3.4 255.255.255.0
route 4.3.2.1 255.255.255.0
route …
pull-filter ignore "route"

This will make your client ignore routes from the server while setting up the explicit rules you need to reach the targets you need.

One problem could arise: If any of your company networks is the same subnet as your home network, this will not work easily. The best option in this case is to change the local subnet.

If you connect only to very specific targets (with no conflicts there), you can circumvent the problem by not using a netmask. It will then default to 255.255.255.255.


If you don’t want to bother with all this and the company uses only internal IP ranges, you can also do this:

route 10.0.0.0 255.0.0.0
route 172.16.0.0 255.224.0.0
route 192.168.0.0 255.255.0.0
pull-filter ignore "route"

This will work because your home network (hopefully) has a longer prefix, making its route match due to higher specificity.


Keep in mind that you may want to set an internal DNS server somewhere, if the company has that.

You must log in to answer this question.

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