LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Networking
User Name
Password
Linux - Networking This forum is for any issue related to networks or networking.
Routing, network cards, OSI, etc. Anything is fair game.

Notices


Reply
  Search this Thread
Old 05-07-2019, 01:57 PM   #1
horizn
Member
 
Registered: Jan 2015
Location: UK and Poland
Distribution: Slackware + Debian + Ubuntu
Posts: 170

Rep: Reputation: Disabled
OpenVPN server and client on the same machine (RPi)


Hi,
I have RPi running OpenVPN server and client, both in routing. While server is running fine when client is down, it stops working when the client is up. RPi itself has still access to the internet via the client VPN.

Internet
^
|
ISP Router 192.168.1.0/24
^
|
eth0 RPi (192.168.1.17)
- tun0 OpenVPN server(192.168.2.0/24)
\ tun1 OpenVPN client(10.1.0.0/24)

I tried to add:
ip rule add from 192.168.1.17 lookup 10
ip route add default via 192.168.1.1 table 10
but with no luck. Any idea how to fix that?

Last edited by horizn; 05-07-2019 at 01:58 PM.
 
Old 05-08-2019, 06:40 PM   #2
ferrari
LQ Guru
 
Registered: Sep 2003
Location: Auckland, NZ
Distribution: openSUSE Leap
Posts: 5,807

Rep: Reputation: 1140Reputation: 1140Reputation: 1140Reputation: 1140Reputation: 1140Reputation: 1140Reputation: 1140Reputation: 1140Reputation: 1140
First thoughts are speculative as you haven't shared enough detail. When the OpenVPN client becomes active, I assume that the remote VPN server may push a 'redirect-gateway' directive to your local OpenVPN client ie this would change the R.Pis default gateway. Now all internet traffic will be via the VPN. That would break any connections to your R.Pi OpenVPN server. Some policy-based routing will be needed to ensure properly route traffic that should go via the VPN tunnel and traffic that should not.
 
Old 05-09-2019, 10:54 AM   #3
horizn
Member
 
Registered: Jan 2015
Location: UK and Poland
Distribution: Slackware + Debian + Ubuntu
Posts: 170

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by ferrari View Post
First thoughts are speculative as you haven't shared enough detail. When the OpenVPN client becomes active, I assume that the remote VPN server may push a 'redirect-gateway' directive to your local OpenVPN client ie this would change the R.Pis default gateway. Now all internet traffic will be via the VPN. That would break any connections to your R.Pi OpenVPN server. Some policy-based routing will be needed to ensure properly route traffic that should go via the VPN tunnel and traffic that should not.
Yes, that correct assumptions, except I can still connect to the server and reach first hop.
 
Old 05-10-2019, 09:59 AM   #4
horizn
Member
 
Registered: Jan 2015
Location: UK and Poland
Distribution: Slackware + Debian + Ubuntu
Posts: 170

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by horizn View Post
Yes, that correct assumptions, except I can still connect to the server and reach first hop.
If I add any rule and then set routing then I can't connect to the VPN server.
 
Old 05-11-2019, 01:35 AM   #5
ferrari
LQ Guru
 
Registered: Sep 2003
Location: Auckland, NZ
Distribution: openSUSE Leap
Posts: 5,807

Rep: Reputation: 1140Reputation: 1140Reputation: 1140Reputation: 1140Reputation: 1140Reputation: 1140Reputation: 1140Reputation: 1140Reputation: 1140
See if this helps...
https://forums.openvpn.net/viewtopic.php?t=21535
 
Old 05-11-2019, 12:06 PM   #6
horizn
Member
 
Registered: Jan 2015
Location: UK and Poland
Distribution: Slackware + Debian + Ubuntu
Posts: 170

Original Poster
Rep: Reputation: Disabled
I've seen that before I posted here. It doesn't work for me.
 
Old 05-12-2019, 04:56 PM   #7
ferrari
LQ Guru
 
Registered: Sep 2003
Location: Auckland, NZ
Distribution: openSUSE Leap
Posts: 5,807

Rep: Reputation: 1140Reputation: 1140Reputation: 1140Reputation: 1140Reputation: 1140Reputation: 1140Reputation: 1140Reputation: 1140Reputation: 1140
You worte that you tried...
Quote:
I tried to add:
Code:
ip rule add from 192.168.1.17 lookup 10
ip route add default via 192.168.1.1 table 10
Perhaps that should that have been...
Code:
ip rule add from 192.168.1.17 table 10
ip route add default via 192.168.1.1 table 10
 
Old 05-13-2019, 05:03 AM   #8
horizn
Member
 
Registered: Jan 2015
Location: UK and Poland
Distribution: Slackware + Debian + Ubuntu
Posts: 170

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by ferrari View Post
You worte that you tried...


Perhaps that should that have been...
Code:
ip rule add from 192.168.1.17 table 10
ip route add default via 192.168.1.1 table 10
Sorry, I didn't make myself clear enough. I have tried many options including the ones on the openvpn community forum. However I have another idea I'll test this evening.
 
Old 05-13-2019, 05:55 AM   #9
ferrari
LQ Guru
 
Registered: Sep 2003
Location: Auckland, NZ
Distribution: openSUSE Leap
Posts: 5,807

Rep: Reputation: 1140Reputation: 1140Reputation: 1140Reputation: 1140Reputation: 1140Reputation: 1140Reputation: 1140Reputation: 1140Reputation: 1140
Great. Let us know how you get on.
 
Old 05-13-2019, 04:33 PM   #10
horizn
Member
 
Registered: Jan 2015
Location: UK and Poland
Distribution: Slackware + Debian + Ubuntu
Posts: 170

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by ferrari View Post
Great. Let us know how you get on. :)
OK, it doesn't work whatever I try.

Code:
ip rule add from 192.168.1.0/24 or 192.168.2.1 or 192.168.1.17 or 192.168.2.0/24 table 10
ip route add default via 192.168.1.1 or 192.168.2.1 or 192.168.1.17 table 10
Code:
cat /etc/iproute2/rt_tables
#
# reserved values
#
255     local
254     main
253     default
0       unspec
#
# local
#
#1      inr.ruhep
10      vpn
 
Old 05-13-2019, 05:03 PM   #11
ferrari
LQ Guru
 
Registered: Sep 2003
Location: Auckland, NZ
Distribution: openSUSE Leap
Posts: 5,807

Rep: Reputation: 1140Reputation: 1140Reputation: 1140Reputation: 1140Reputation: 1140Reputation: 1140Reputation: 1140Reputation: 1140Reputation: 1140
It's hard to diagnose from a distance, and I don't have the time to drill deeper with this. You could cast your net wider by posting your issue on the openVPN Forum perhaps.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
LXer: Mini-PC taps RPi Compute Module and supports RPi 2 LXer Syndicated Linux News 0 02-22-2015 03:03 PM
Directing OpenVPN client's traffic through the OpenVPN server mohtasham1983 Linux - Networking 1 01-17-2012 06:44 PM
OpenVPN client has not default gateway when connect to OpenVPN server sailershen Linux - Security 3 03-04-2010 02:20 AM
configuring openvpn in same network (i.e client and server both are in same netwrk) eshi14 Linux - Networking 4 10-31-2009 12:46 AM
prevent users to run the same script at the same time, on the same machine pvpnguyen Programming 2 09-05-2007 08:52 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Networking

All times are GMT -5. The time now is 05:58 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration