Setup openvpn in an Ubuntu act as both client and server to connect to another server

Need help configuring your VPN? Just post here and you'll get that help.

Moderators: TinCanTech, TinCanTech, TinCanTech, TinCanTech, TinCanTech, TinCanTech

Forum rules
Please use the [oconf] BB tag for openvpn Configurations. See viewtopic.php?f=30&t=21589 for an example.
Post Reply
logelwatelz
OpenVpn Newbie
Posts: 2
Joined: Sat Jun 17, 2023 6:49 pm

Setup openvpn in an Ubuntu act as both client and server to connect to another server

Post by logelwatelz » Sat Jun 17, 2023 6:54 pm

Hello,

This is what I want to do:
connect to server 1.1.1.1 via ssh, then in 1.1.1.1 run `openvpn --config file /path/file.ovpn` to connect to 2.2.2.2 but only incoming traffic from port 1194 should go to tun0 device.
When I run this command, in fact the default routing changes and I cannot access to 1.1.1.1 anymore (I should kill that PID via console).

I want to establish connection but shouldn't change default routing. I mean OpenVPN's connection should be open but only any traffic comes from port 1194 should go through tun0 device, and other traffic like port 80 and 587 should go through eth0.

I googled but couldn't find proper way or any ways.

The image below is something I just drew to try to show my mean better:

Image

I want to know how to configure it so that it can act both as a client and server, and has a persistent connection from 1.1.1.1 to 2.2.2.2 as a client, and I with my mobile connect to 1.1.1.1. as client to OpenVPN Server 1.1.1.1.

I'm not much experienced in this field but I'm curious to know whether it is possible and if yes, how?

Thanks in advance

never-stop-learning
OpenVPN User
Posts: 43
Joined: Sat Oct 02, 2021 3:57 pm

Re: Setup openvpn in an Ubuntu act as both client and server to connect to another server

Post by never-stop-learning » Sun Jun 18, 2023 11:22 am

Hey man, what is your main goal in why connecting your Server 1.1.1.1 to Server 2.2.2.2?
Is it to access by a client device like mobile to access the server 2.2.2.2 traversing the traffic from 1.1.1.1?

logelwatelz
OpenVpn Newbie
Posts: 2
Joined: Sat Jun 17, 2023 6:49 pm

Re: Setup openvpn in an Ubuntu act as both client and server to connect to another server

Post by logelwatelz » Sun Jun 18, 2023 3:25 pm

never-stop-learning wrote:
Sun Jun 18, 2023 11:22 am
Hey man, what is your main goal in why connecting your Server 1.1.1.1 to Server 2.2.2.2?
Is it to access by a client device like mobile to access the server 2.2.2.2 traversing the traffic from 1.1.1.1?
The goal is just to learn change the routing traffic (if I'm saying the correct phrases) and learn how can I do that. There's no any technical issue.
I just want to know and do that, I think it should be fun to learn.

Yes, I want to access by device like mobile to access 2.2.2.2 traversing from 1.1.1.1.

Post Reply