As no-one on this forum (yes,
the OpenVPN forum itself) seems able, or capable of, supplying even just 3 small lines of code to get new users contributing and developing OpenVPN and helping, in turn, to keep the open source community alive and vibrant, I have decided to resolve this issue with the following (as much for my own benefit, and the benefit of others needing to know how to get this working, I might add, as a FY to those who will not help with something as simple as showing someone how to turn something on or how to make the initial connection).
So
this is the final (working) solution for anyone needing to connect two machines using network addresses only (no domain configurations and absolutely
no remote network or
example.com connections whatsoever), with both machines on the same subnet. This is also about the simplest possible connection for anyone looking to get started using OpenVPN.
Setup:
1x Windows personal computer (running Windows 7 Pro x64)
1x Fedora 27 Server Edition laptop
Both machines connected via a router on the same LAN and able to communicate with each other (port 1194 - unless configured to be something different ) with VLAN separation (which is essential for my setup, not only for security considerations, but also for the extra IP address as a result of this configuration). I have also configured the second address, 10.200.0.6, as a static address on the linux box because, otherwise, in VLAN configuration, it will not be locked to that address, which could cause connectivity issues.
- OpenVPN installed on both machines, with the repository version (
ie: not built from source on the machine, but downloaded via Yum) installed
- on the linux box
-
static.key file generated on the linux box using:
openvpn --genkey --secret static.key
- the above file on my linux box is located in:
/etc/openvpn/server or the OpenVPN
\config sub-directory on the Windows machine.
-
sample.ovpn [
v.i.] is stored in an ASCII text file (Notepad / Notepad++ as an editor,
not Microsoft Word!) as an
.ovpn file
- within the OpenVPN
\config sub-directory on the Windows machine and as a
.conf file in
/etc/openvpn/server on the linux box.
- OpenVPN GUI (Start Button - round object with Windows logo to the bottom left of the screen - All Programs - OpenVPN) is then initiated on the
- Windows machine, resulting in a small icon in the system tray to the bottom right of the screen (screen as viewed by the user). The
.ovpn
- config file should then be accessible and editable by right clicking on the icon in order to select it, likewise with the log file.
-
vpntest.conf is instantiated on the linux box with the code shown below (in my case), and as detailed above on the Windows machine.
openvpn vpntest.conf
All being well a tunnel will now be established between the two machines, and it will be possible to open an instance of CMD (command-line) on the Windows machine in order to
ping the linux box. The linux box will require further configuration in order to make OpenVPN run in the background before it will be possible to
ping the client, as it will otherwise remain in the foreground; effectively rendering the machine unusable for anything beyond those services already running in the background.
Observations:
OpenVPN on the Windows side uses a TAP adapter. This makes no difference to whether or not your config is using TAP or TUN, and should not prevent this simple configuration from working.
The two
ifconfig IP addresses are not configured on my router, and there is absolutely no need for me to reconfigure my router at all in order to allow their use. - They are part of the same 255.255.255.0 subnet as the other two 10.200.0 addresses (10.200.0.5 and 10.200.0.6), so OpenVPN is allowed to use them via the OpenVPN adapter and DHCP.
The names of the config files follow no mandatory naming conventions beyond common sense,
.ovpn file extension on the Windows machine, and a
.conf file extension on the linux box.
OpenVPN is
extremely pissy about what subnets it will work on, and will even refuse to work on subnets that are allowed under
show-valid-subnets. Using non-sequential addresses within a subnet is also highly likely to result in failed connection attempts.
Beware of
firewalld and SELinux. SELinux can be tamed until reboot with satanforce, sorry
setenforce permissive, and in its
/etc/selinux .conf file. I have a firewall and anti-spoof protection both running on the router with no problem, along with a software firewall on the Windows machine, a remote VPN connection, and occasional SSh connections to the linux machine; all of which co-exist quite happily together.
VLAN configuration can involve configuration via the default network adapter on Windows, following initial configuration on the router. Windows 7 does not like tagged VLAN, so an untagged VLAN0 may be a requirement. It is also likely that it will only be possible to add an untagged VLAN0 on the network adapter side following the initial creation of a tagged VLAN1. This is true of Intel adapters, and Windows will need to be connected to the untagged port on the router when configuring the devices on the router.
sample.ovpn:
dev tun
remote 10.200.0.6
ifconfig 10.200.0.1 10.200.0.2
secret static.key
cipher AES-256-CBC
persist-tun
persist-key
vpntest.conf
dev tun
remote 10.200.0.5
ifconfig 10.200.0.2 10.200.0.1
user nobody
group nobody
secret static.key
cipher AES-256-CBC
persist-tun
persist-key
sample.log
Tue Mar 06 00:34:27 2018 disabling NCP mode (--ncp-disable) because not in P2MP client or server mode
Tue Mar 06 00:34:27 2018 OpenVPN 2.4.4 x86_64-w64-mingw32 [SSL (OpenSSL)] [LZO] [LZ4] [PKCS11] [AEAD] built on Sep 26 2017
Tue Mar 06 00:34:27 2018 Windows version 6.1 (Windows 7) 64bit
Tue Mar 06 00:34:27 2018 library versions: OpenSSL 1.0.2l 25 May 2017, LZO 2.10
Enter Management Password:
Tue Mar 06 00:34:27 2018 open_tun
Tue Mar 06 00:34:27 2018 TAP-WIN32 device [Local Area Connection 6] opened: \\.\Global\{B1A13B50-22A1-48D4-980B-7105480DBA9B}.tap
Tue Mar 06 00:34:27 2018 Notified TAP-Windows driver to set a DHCP IP/netmask of 10.200.0.1/255.255.255.252 on interface {B1A13B50-22A1-48D4-980B-7105480DBA9B} [DHCP-serv: 10.200.0.2, lease-time: 31536000]
Tue Mar 06 00:34:27 2018 Successful ARP Flush on interface [15] {B1A13B50-22A1-48D4-980B-7105480DBA9B}
Tue Mar 06 00:34:27 2018 do_ifconfig, tt->did_ifconfig_ipv6_setup=0
Tue Mar 06 00:34:27 2018 TCP/UDP: Preserving recently used remote address: [AF_INET]10.200.0.6:1194
Tue Mar 06 00:34:27 2018 UDP link local (bound): [AF_INET][undef]:1194
Tue Mar 06 00:34:27 2018 UDP link remote: [AF_INET]10.200.0.6:1194
Tue Mar 06 00:34:36 2018 Peer Connection Initiated with [AF_INET]10.200.0.6:1194
Tue Mar 06 00:34:41 2018 WARNING: this configuration may cache passwords in memory -- use the auth-nocache option to prevent this
Tue Mar 06 00:34:41 2018 Initialization Sequence Completed