Default Gateway through remote VPN client

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
statisticavg
OpenVpn Newbie
Posts: 2
Joined: Sat Nov 07, 2020 8:54 am

Default Gateway through remote VPN client

Post by statisticavg » Sat Nov 07, 2020 9:01 am

I've got 1 server and 2 clients. I want to route all traffic from "client2" and any other clients through the VPN but not through the VPN server's default route itself but back through "client" one of the clients on the VPN. Whats the best way to achieve this? Below is my attempt using ifconfig-push and iroute on "client" but how can I configure the "redirect-gateway" directive to route all traffic through "client" instead of the server?

Server: 10.8.0.1
cn="client": 10.8.0.2
cn="client2": 10.8.0.3

server.conf

Server Config

client-config-dir ccd
client-to-client
server 10.8.0.0 255.255.255.0
push "route 10.8.0.2 255.255.255.0"
;push "route 192.168.20.0 255.255.255.0"
push "redirect-gateway def1"
push "dhcp-option DNS 1.1.1.1"


ccd/client
Server Config

ifconfig-push 10.8.0.2 255.255.255.255
iroute 10.8.0.2 255.255.255.255


ccd/client2
Server Config

route 10.8.0.2 255.255.255.0

castle15
OpenVpn Newbie
Posts: 1
Joined: Sun Nov 08, 2020 11:19 pm

Re: Default Gateway through remote VPN client

Post by castle15 » Fri Nov 13, 2020 5:24 pm

I think you should start here viewtopic.php?f=30&t=22603

I'm trying to do the same thing and I got most of it working. I don't think you need this route on ccd/client2 nor push "route ..." and change iroute on ccd/client to

Code: Select all

iroute 0.0.0.0 128.0.0.0
also you need to be able to deal with the traffic from client 2 either by NAT or routing. And if you want all traffic from server to go through client, I'm not really sure how to do it.

I followed this guy's guide adapting a couple of things. Maybe it can help you
P.S. he used all those iroutes instead of what I wrote here but that was a bug and I believe it was fixed so my code should work.
https://astojanov.github.io/blog/2013/0 ... outes.html

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

Re: Default Gateway through remote VPN client

Post by TinCanTech » Fri Nov 13, 2020 5:59 pm

You did not read that article very carefully ..

ValdikSS
OpenVpn Newbie
Posts: 7
Joined: Thu Sep 24, 2015 10:00 am

Re: Default Gateway through remote VPN client

Post by ValdikSS » Thu Apr 04, 2024 2:08 pm

The article says that

Code: Select all

iroute 0.0.0.0 128.0.0.0
does not work on OpenVPN, however I just tried

Code: Select all

iroute 0.0.0.0 0.0.0.0
on OpenVPN 2.6.9, and it just worked.

So, for L3 (TUN) mode, to route all the traffic via another client, all you need is:
server.conf

Code: Select all

client-to-client
client-config-dir ccd
ccd/client_name

Code: Select all

iroute 0.0.0.0 0.0.0.0

Post Reply