In this article, we will walk you through the process of adding routes on an OpenVPN client to access off-site networks. This procedure is particularly useful when you need to route traffic from your client to an off-site network through the OpenVPN server.
To add routes on an OpenVPN client for off-site network access, you can use the
sudo route add command in the terminal. This allows you to manually direct traffic from your client to the off-site network through the OpenVPN server.
Before we delve into the specifics, it’s crucial to understand what OpenVPN is. OpenVPN is a robust and highly flexible VPN (Virtual Private Network) software that secures your network connections. It enables you to establish secure point-to-point or site-to-site connections, using the internet as a medium.
Why Add Routes on OpenVPN Client?
There are instances where you might need to access resources on a different network, which is not directly accessible from your current network. In such cases, you can manually add a route on your OpenVPN client to direct the traffic to the off-site network via the OpenVPN server.
How to Add Routes on OpenVPN Client
Here’s a step-by-step guide on how to add routes on an OpenVPN client:
Step 1: Open Terminal
First, you need to open a terminal on your client machine. If you’re using Ubuntu, you can do this by pressing
Ctrl + Alt + T.
Step 2: Add Route
Next, you’ll need to run the following command to add the route:
sudo route add -net 184.108.40.206/8 gw 10.242.2.5 dev tun0
In the above command:
sudogives you superuser privileges.
route addis the command to add a new route.
-net 220.127.116.11/8specifies the network you want to access. You should replace
18.104.22.168/8with the actual network address you want to access.
gw 10.242.2.5specifies the gateway through which the network can be accessed. Replace
10.242.2.5with the correct gateway IP.
dev tun0specifies the network interface that the command should use. In this case,
tun0is the network interface used by OpenVPN.
Step 3: Verify the Route
To ensure the route has been added successfully, run the following command:
This command lists all the routes that have been set up on your client. You should see the newly added route in the output.
Adding routes on an OpenVPN client for off-site network access can be a straightforward process if you understand the commands and their parameters. This process is highly useful in scenarios where you need to access resources on a different network. Remember to replace the network address and the gateway IP in the command with the actual values based on your network setup.
Please note that this solution assumes that you don’t have control over the OpenVPN server configuration and routes are not pushed from the server. If you have control over the server configuration, it’s recommended to add the routes on the server side and push them to the clients.
The purpose of adding routes on an OpenVPN client is to enable network traffic from the client to be directed to off-site networks via the OpenVPN server. This allows the client to access resources on networks that are not directly accessible from its current network.
To open a terminal on your client machine, you can use the shortcut
Ctrl + Alt + T if you are using Ubuntu. This will open a terminal window where you can enter commands.
To add a route on an OpenVPN client, you need to run the following command in the terminal:
sudo route add -net [network] gw [gateway] dev [interface]
[network] with the network address you want to access,
[gateway] with the correct gateway IP, and
[interface] with the network interface used by OpenVPN (usually
To verify if the route has been added successfully, you can run the command
route -n in the terminal. This command lists all the routes that have been set up on your client. If the route you added is displayed in the output, it means it has been added successfully.
Yes, it is necessary to replace the network address and gateway IP in the command with the actual values based on your network setup. The network address specifies the network you want to access, and the gateway IP specifies the gateway through which the network can be accessed.