Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
Help! Routing between openvpn server and local network
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Networking & Security
View previous topic :: View next topic  
Author Message
sglorz
n00b
n00b


Joined: 09 Jun 2011
Posts: 13

PostPosted: Wed Jun 15, 2011 12:47 pm    Post subject: Help! Routing between openvpn server and local network Reply with quote

Hello,

I have two connections on my server:
1/ first is eth0 with a local IP connected to my router and then my ISP.
2/ second is tun0 connected to a VPN server.

But, I want to have all the traffic redirected to my eth0 except for some ports (like ssh/22 or http/8080) that I want to be redirected to tun0.

Actually, when I start the openvpn client all traffic is redirected to tun0. So, it seems that I need to add a route instruction in my VPN client conf, but I don't know how.

So, could someone help me to configure that?

Thanks
Back to top
View user's profile Send private message
mikegpitt
Advocate
Advocate


Joined: 22 May 2004
Posts: 3224

PostPosted: Wed Jun 15, 2011 5:09 pm    Post subject: Reply with quote

I believe this link describes what you are looking for:
http://wiki.debian.org/HowTo/openvpn

Look at the section toward the bottom that describes configuring the VPN server as a pass through proxy.
Back to top
View user's profile Send private message
sglorz
n00b
n00b


Joined: 09 Jun 2011
Posts: 13

PostPosted: Wed Jun 15, 2011 6:10 pm    Post subject: Reply with quote

Thank you for your answer, but I don't think it will help me as I'm connecting to a VPN server that I don't manage.

I think I will look into net filter with iptables.
Back to top
View user's profile Send private message
mikegpitt
Advocate
Advocate


Joined: 22 May 2004
Posts: 3224

PostPosted: Wed Jun 15, 2011 6:25 pm    Post subject: Reply with quote

sglorz wrote:
Thank you for your answer, but I don't think it will help me as I'm connecting to a VPN server that I don't manage.
That might be a problem. If the VPN server isn't configured as a proxy, then you won't be able to use it in such a way. Sure, you can route all your eth0 traffic to the VPN server, but it won't know what to do with it.
Back to top
View user's profile Send private message
sglorz
n00b
n00b


Joined: 09 Jun 2011
Posts: 13

PostPosted: Wed Jun 15, 2011 6:36 pm    Post subject: Reply with quote

Ok I see.
But, I have two interfece: one is lan eth0 and this other is VPN tun0.
So, is it possible to tell my Gentoo to send all the local trafic to eth0 except for some port to tun0?
Back to top
View user's profile Send private message
mikegpitt
Advocate
Advocate


Joined: 22 May 2004
Posts: 3224

PostPosted: Wed Jun 15, 2011 7:05 pm    Post subject: Reply with quote

I believe the route commands at the bottom of the link I posted before do this. I haven't tested it myself, but it looks like it should work:
Code:
route del default eth0
route add default gw 10.9.8.1 dev tun0

It should also be possible with iptables. Again, I haven't tested this... but something like this should work:
Code:
echo "1" > /proc/sys/net/ipv4/ip_forward
iptables -t nat -A PREROUTING -p tcp -i eth0 -j DNAT
iptables -A FORWARD -i eth0 -o tun0 -p tcp -j ACCEPT
Back to top
View user's profile Send private message
sglorz
n00b
n00b


Joined: 09 Jun 2011
Posts: 13

PostPosted: Wed Jun 15, 2011 7:32 pm    Post subject: Reply with quote

Thank you, I shall look into this.
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Networking & Security All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum