Page 1 of 1

Route all the traffic through OpenVPN server

Posted: Tue Jun 07, 2022 10:50 am
by wahabqurashi
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

Re: Route all the traffic through OpenVPN server

Posted: Tue Jun 07, 2022 12:13 pm
by TinCanTech
Which version of OpenVPN are you using ?

Re: Route all the traffic through OpenVPN server

Posted: Tue Jun 07, 2022 1:54 pm
by wahabqurashi
Package: openvpn
Architecture: amd64
Version: 2.4.7-1ubuntu2.20.04.4

Re: Route all the traffic through OpenVPN server

Posted: Tue Jun 07, 2022 3:54 pm
by openvpn_inc
Hi,

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

regards, rob0

Re: Route all the traffic through OpenVPN server

Posted: Tue Jun 07, 2022 4:06 pm
by TinCanTech
Is it sooo difficult to simply move the thread ?

Re: Route all the traffic through OpenVPN server

Posted: Tue Jun 07, 2022 4:55 pm
by TinCanTech
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..