You are not logged in.

#1 2021-01-22 12:03:09

eearcher
Member
Registered: 2021-01-08
Posts: 21

Setting up OpenVPN, Routing error

So what I want to achieve is a VPN Tunnel from my laptop running arch to my home network, where a Raspberry Pi is configured as an OpenVPN server. I want to use this so I can access my servers at home.
What my network looks like:

              -------------------           ------------------
Internet ----| Router 172.*.*.*  |---------| OpenVPN Server   |
             | 192.168.1.1       |         | 192.168.1.116    |
             | 255.255.255.0     |         |                  |
             --------------------           ------------------
                       |
                       |
                       |
                       |
             --------------------
             | Server           |
             | 192.168.1.200    |
             --------------------

On my router I activated a dynDNS service so I can reach my router from the internet. I also added a port forwarding rule, TCP/UDP Port 1194 is forwarded to 192.168.1.116.

Thanks so the Arch Wiki, I managed to create all necessary certificates and keys. I think the only problem that remains is routing the internet traffic. When using the GUI in gnome settings (uses NetworkManager vpn plugin), I can successfully connect to my VPN (journalctl: "VPN connection (IP Config get) complete", there is a little key icon in the top bar). No error messages either when running OpenVPN from the terminal, all authentication seems to be fine.

However, I can't access anything on my home network.

server config:

ca /etc/openvpn/server/ca.crt
cert /etc/openvpn/server/vpn-server.crt
key /etc/openvpn/server/vpn-server.key
port '1194'
verb 4
dh none
ecdh-curve secp521r1
dev tun
proto udp
server 192.168.1.0 255.255.255.0
persist-tun
persist-key
tls-server
tls-crypt /etc/openvpn/server/ta.key
tls-version-min 1.2
cipher AES-256-CBC

push "redirect-gateway def1"


user pi
group sudo

net.ipv4.ip_forward is also set to 1.

iptables on server:

iptables -t filter -F
iptables -t nat -F
iptables -A FORWARD -m state --state RELATED,ESTABLISHED -j ACCEPT
iptables -A FORWARD -i tun0 -j ACCEPT
iptables -A FORWARD -j REJECT
iptables -t nat -A POSTROUTING -s '192.168.1.0/24' -j MASQUERADE
iptables-save > /etc/iptables/rules.v4

client 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
proto udp

# The hostname/IP and port of the server.
# You can have multiple remote entries
# to load balance between the servers.

remote *** DynDNS NAME OF MY ROUTER HERE *** 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 /etc/openvpn/client/ca.crt
cert /etc/openvpn/client/thinkpad_client.crt
key /etc/openvpn/client/thinkpad.key

# Verify server certificate by checking that the
# certificate 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
tls-crypt /etc/openvpn/client/ta.key

# Select a cryptographic cipher.
# If the cipher option is used on the server
# then you must also specify it here.
# Note that v2.4 client/server will automatically
# negotiate AES-256-GCM in TLS mode.
# See also the data-ciphers option in the manpage
cipher AES-256-CBC
data-ciphers AES-256-CBC

# 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

What am I doing wrong? What do I need to do so that I can ping my servers?
Any help is appreciated.

Kind regards

Offline

#2 2021-02-24 23:37:22

yiuko
Member
Registered: 2021-02-24
Posts: 1

Re: Setting up OpenVPN, Routing error

did you check in ipv4 tab "use this connection only for resources of its network"?

Offline

Board footer

Powered by FluxBB