The cart is empty

In today's digital era, ensuring secure and encrypted access to corporate resources over the internet is crucial for protecting sensitive data and maintaining enterprise integrity. Virtual Private Networks (VPNs) are a key technology to achieve this goal. One popular and effective implementation of VPN is the OpenConnect server, which provides compatibility with the Cisco AnyConnect VPN client. This article focuses on configuring and managing the OpenConnect VPN server on the CentOS operating system.

Prerequisites

Before initiating the configuration, ensure that your system meets the following prerequisites:

  • Clean installation of CentOS 7 or 8.
  • Static IP address assigned to the server.
  • Access to the server with superuser (root) privileges.

Installation of Dependencies

The first step is to install the necessary packages. The OpenConnect server requires several dependencies, including OpenSSL for encryption. Install them using the following command:

sudo yum install epel-release -y
sudo yum update -y
sudo yum install ocserv httpd-tools openssl -y

Configuration of OpenConnect VPN Server

After installing the dependencies, the OpenConnect server needs to be configured. The configuration file is typically located at /etc/ocserv/ocserv.conf. For basic setup, open this file in an editor and make the following changes:

  • Setting up the IP address range for clients.
  • Configuring certificates for communication encryption.
  • Setting connection limits.

Example configuration of IP address range:

ipv4-network = 192.168.1.0
ipv4-netmask = 255.255.255.0

Creation and Configuration of SSL Certificates

Secure VPN connections require SSL certificates. To create your own certificate and key, use OpenSSL:

cd /etc/ocserv/
sudo openssl req -new -x509 -days 3650 -nodes -out server-cert.pem -keyout server-key.pem

During the certificate creation process, you will be asked for various information such as company name and email address. These details are part of the certificate.

Configuration of Firewall and Routing

To access the VPN server from an external network, configure the firewall and enable IP forwarding. Example firewall configuration in CentOS:

sudo firewall-cmd --zone=public --add-port=443/tcp --permanent
sudo firewall-cmd --reload

To enable IP forwarding, edit the file /etc/sysctl.conf and add:

net.ipv4.ip_forward = 1

Apply the changes using sudo sysctl -p.

Starting and Testing OpenConnect VPN Server

After completing the configuration, you can start the OpenConnect server with the command:

sudo systemctl start ocserv

To ensure that the OpenConnect server starts automatically on system boot, use:

sudo systemctl enable ocserv

To test the functionality of the VPN, connect using the Cisco AnyConnect client or a compatible client such as the OpenConnect client on another computer. The input details will be the server address (IP or domain name) and login credentials (username and password) that you have set.

User Management and Access Rights

User management is done using the ocpasswd tool, which is part of the OpenConnect server package. To add a new user, run:

sudo ocpasswd -c /etc/ocserv/ocpasswd username

After running this command, you will be prompted to enter a password for the new user. To remove a user, use the same tool with the -d switch.

Security and Optimization

To secure the OpenConnect VPN server, it's crucial to regularly update the operating system and all software. Additionally, use strong passwords for user access and regularly renew SSL certificates. For performance optimization, adjust the settings of the OpenConnect server, such as the number of concurrently connected users or encryption algorithms, depending on the server's hardware capabilities and security requirements.

Monitoring and Logging

For effective management and troubleshooting, it's important to monitor the status of the VPN server and review logs. The OpenConnect server logs events to the syslog, allowing easy tracking of accesses, errors, and security incidents. For more detailed information about server activity, you can adjust the logging configuration in the ocserv.conf file.

 

Setting up the OpenConnect VPN server on CentOS offers a flexible and secure way to provide remote access to network resources. Thanks to compatibility with Cisco AnyConnect clients, this solution is suitable for various enterprise environments. Paying attention to configuration details, security, and server management is important to ensure a secure and reliable VPN connection for all users.