Route all the traffic through OpenVPN 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
wahabqurashi
OpenVpn Newbie
Posts: 3
Joined: Tue Jun 07, 2022 10:11 am

Route all the traffic through OpenVPN server

Post by wahabqurashi » Tue Jun 07, 2022 10:50 am

Hi there,

I have set up OpenVPN on a server. I am able to connect to OpenVPN as a client. I want to route all the client traffic from the OpenVPN server. I have read all the documentation and tried to follow it but still unsuccessful.

Here is my configuration details:

Server configs:

Code: Select all

push "redirect-gateway def1"

push "dhcp-option DNS 8.8.8.8"
push "dhcp-option DNS 208.67.222.222"
push "dhcp-option DNS 208.67.220.220"
Client configs:

Code: Select all

push "redirect-gateway def1"
On the OpenVPN server:

Add the following line in the /etc/sysctl.conf

Code: Select all

net.ipv4.ip_forward = 1
confirm it with "sudo sysctl -p" command.


Add the following in the firewall rules /etc/ufw/before.rules

Code: Select all

# START OPENVPN RULES
# NAT table rules
*nat
:POSTROUTING ACCEPT [0:0]
# Allow traffic from OpenVPN client to eth0 (change to the interface you discovered!)
-A POSTROUTING -s 10.8.0.0/8 -o eth0 -j MASQUERADE
COMMIT
# END OPENVPN RULES

Kindly guide me if I am missing anything. I have taken all the steps but it is not working. Thanks

TinCanTech
OpenVPN Protagonist
Posts: 11137
Joined: Fri Jun 03, 2016 1:17 pm

Re: Route all the traffic through OpenVPN server

Post by TinCanTech » Tue Jun 07, 2022 12:13 pm

Which version of OpenVPN are you using ?

wahabqurashi
OpenVpn Newbie
Posts: 3
Joined: Tue Jun 07, 2022 10:11 am

Re: Route all the traffic through OpenVPN server

Post by wahabqurashi » Tue Jun 07, 2022 1:54 pm

Package: openvpn
Architecture: amd64
Version: 2.4.7-1ubuntu2.20.04.4

User avatar
openvpn_inc
OpenVPN Inc.
Posts: 1333
Joined: Tue Feb 16, 2021 10:41 am

Re: Route all the traffic through OpenVPN server

Post by openvpn_inc » Tue Jun 07, 2022 3:54 pm

Hi,

This is not OpenVPN Access Server. I have moved the topic to an appropriate forum.

regards, rob0
Image OpenVPN Inc.
Answers provided by OpenVPN Inc. staff members here are provided on a voluntary best-effort basis, and no rights can be claimed on the basis of answers posted in this public forum. If you wish to get official support from OpenVPN Inc. please use the official support ticket system: https://openvpn.net/support

TinCanTech
OpenVPN Protagonist
Posts: 11137
Joined: Fri Jun 03, 2016 1:17 pm

Re: Route all the traffic through OpenVPN server

Post by TinCanTech » Tue Jun 07, 2022 4:06 pm

Is it sooo difficult to simply move the thread ?

TinCanTech
OpenVPN Protagonist
Posts: 11137
Joined: Fri Jun 03, 2016 1:17 pm

Re: Route all the traffic through OpenVPN server

Post by TinCanTech » Tue Jun 07, 2022 4:55 pm

wahabqurashi wrote:
Tue Jun 07, 2022 10:50 am
# Allow traffic from OpenVPN client to eth0 (change to the interface you discovered!)
-A POSTROUTING -s 10.8.0.0/8 -o eth0 -j MASQUERADE
See your OS for further details..

Post Reply