TCP protocol and different ports

The default protocol that OpenVPN uses is UDP, as it is generally more suitable for VPN connections. However, if the TCP protocol is required, then the preceding example needs to be modified only slightly:

On the listening end, start the OpenVPN server instance:

[root@server] # openvpn \
    --ifconfig 10.200.0.1 10.200.0.2 \
    --dev tun \
    --proto tcp-server

On the client side, the code is as follows:

[root@client] # openvpn \
    --ifconfig 10.200.0.2 10.200.0.1 \
     --dev tun \
    --proto tcp-client \
    --remote openvpnserver.example.com

OpenVPN will now connect over TCP port 1194. It is also possible to override the port number using the --port parameter, for example, --port 5000.

The TAP mode

If non-TCP/IP traffic needs ...

Get Mastering OpenVPN now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.