Introduction
In this article, we will discuss how to connect to an Azure virtual machine using OpenVPN on a CentOS machine, without directly reaching another computer via the OpenVPN private address. We will cover the key concepts, subtitles, and provide a detailed context of the topic.
Prerequisites
- A CentOS machine with OpenVPN installed.
- An Azure virtual machine with a public IP address, in this case, 10.5.0.4.
- An OpenVPN machine with a private IP address, in this case, 10.6.0.4.
- Peering between the CentOS OpenVPN network and the Azure virtual machine.
Overview
The objective is to connect to the Azure virtual machine using OpenVPN on the CentOS machine, without directly reaching another computer via the OpenVPN private address. This can be achieved by configuring the OpenVPN client on the CentOS machine to connect to the Azure virtual machine using its public IP address.
Configuring the OpenVPN Client
To configure the OpenVPN client on the CentOS machine, we need to create a new OpenVPN configuration file. This file will contain the necessary settings to connect to the Azure virtual machine using its public IP address.
Creating the OpenVPN Configuration File
Create a new OpenVPN configuration file using a text editor of your choice. For example, you can use the nano text editor to create a new file called azure.ovpn.
sudo nano /etc/openvpn/azure.ovpn
Adding the Configuration Settings
Add the following configuration settings to the azure.ovpn file.
client
dev tun
proto udp
remote 10.5.0.4 1194
resolv-retry infinite
nobind
persist-key
persist-tun
ca ca.crt
cert client.crt
key client.key
tls-auth ta.key 1
cipher AES-256-CBC
auth SHA256
verb 3
Replace 10.5.0.4 with the public IP address of the Azure virtual machine. The other settings are standard OpenVPN configuration settings.
Connecting to the Azure Virtual Machine
To connect to the Azure virtual machine using the OpenVPN client on the CentOS machine, use the following command.
sudo openvpn --config /etc/openvpn/azure.ovpn
This will start the OpenVPN client and connect to the Azure virtual machine using its public IP address.
In this article, we have discussed how to connect to an Azure virtual machine using OpenVPN on a CentOS machine, without directly reaching another computer via the OpenVPN private address. We have covered the key concepts, subtitles, and provided a detailed context of the topic. We have also provided the steps to configure the OpenVPN client on the CentOS machine to connect to the Azure virtual machine using its public IP address.