LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
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 10-19-2013, 09:44 AM   #1
normadize
LQ Newbie
 
Registered: Oct 2013
Posts: 1

Rep: Reputation: Disabled
route http and ssh traffic normally, everything else via vpn tunnel


I've read quite a bit and am close, I feel, and I'm pulling my hair out ... please help!

I have an OpenVPN cliend whose server sets local routes and also changes the default gw (I know I can prevent that with --route-nopull). I'd like to have all outgoing http and ssh traffic via the local gw, and everything else via the vpn.

- Local IP is 192.168.1.6/24, gw 192.168.1.1.
- OpenVPN local IP is 10.102.1.6/32, gw 192.168.1.5
- OpenVPN server is at {OPENVPN_SERVER_IP}

Here's the route table after openvpn connection:

Code:
# ip route show table main
0.0.0.0/1 via 10.102.1.5 dev tun0 
default via 192.168.1.1 dev eth0  proto static 
10.102.1.1 via 10.102.1.5 dev tun0 
10.102.1.5 dev tun0  proto kernel  scope link  src 10.102.1.6 
{OPENVPN_SERVER_IP} via 192.168.1.1 dev eth0 
128.0.0.0/1 via 10.102.1.5 dev tun0 
169.254.0.0/16 dev eth0  scope link  metric 1000 
192.168.1.0/24 dev eth0  proto kernel  scope link  src 192.168.1.6  metric 1
This makes all packets go via to the VPN tunnel except those destined for 192.168.1.0/24.

Doing `wget -qO- http://echoip.org` shows the vpn server's address, as expected, the packets have 10.102.1.6 as source address (the vpn local ip), and are routed via `tun0` ... as reported by `tcpdump -i tun0` (`tcpdump -i eth0` sees none of this traffic).

What I tried was:

- create a 2nd routing table holding the 192.168.1.6/24 routing info (copied from the `main` table above)
- add an `iptables -t mangle -I PREROUTING` rule to mark packets destined for port 80
- add an `ip rule` to match on the mangled packet and point it to the 2nd routing table
- add an ip rule for `to 192.168.1.6` and `from 192.168.1.6` to point to the 2nd routing table (though this is superfluous)
- changed the ipv4 filter validation to none in `net.ipv4.conf.tun0.rp_filter=0` and `net.ipv4.conf.eth0.rp_filter=0`

I also tried an `iptables mangle output` rule, `iptables nat prerouting` rule. It still fails and I'm not sure what I'm missing:

- `iptables mangle prerouting`: packet still goes via vpn
- `iptables mangle output`: packet times out

Is it not the case that to achieve what I want, then when doing `wget http://echoip.org` I should change the packet's source address to 192.168.1.6 before routing it off? But if I do that, the response from the http server would be routed back to 192.168.1.6 and `wget` would not see it as it is still bound to `tun0` (the vpn interface)?

Can a kind soul please help? What commands would you execute after the openvpn connects to achieve what I want?

Looking forward to hair regrowth ...
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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
Route Get_iPlayer through VPN Tunnel loveSpend Linux - Newbie 6 06-28-2013 10:36 AM
Hardware appliance that can route all traffic through ipsec tunnel zhjim Linux - Networking 6 07-23-2012 07:08 AM
How to use VPN tunnel for all traffic except SMTP (port 25) traffic? maven12 Linux - Networking 2 11-09-2010 06:00 AM
OpenVPN route issues, all traffic through VPN tunnel stuartornum Linux - Server 4 03-05-2007 03:07 AM

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

All times are GMT -5. The time now is 04:57 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