LinuxQuestions.org
Review your favorite Linux distribution.
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
 
LinkBack Search this Thread
Old 04-06-2008, 03:43 AM   #1
Usogi
LQ Newbie
 
Registered: Feb 2006
Posts: 4

Rep: Reputation: 0
IPTables Reroute Outing Traffic Through VPN


ok, I have a bit of a project going on here.

I have a linux (ubuntu) router, it is setup and works great as a basic router. I'm wanting to setup a VPN back to my work and forward the following traffic through it:
Everything directed at the 10.0.0.0/16 network
All traffic from 192.168.200.125

I have gotten all the 10.0.0.0/16 traffic to work like I want with the following:

-----------------------------
route add -net 10.0.0.0 netmask 255.0.0.0 dev ppp0
iptables --table nat --append POSTROUTING --out-interface eth0 -j MASQUERADE
iptables --append FORWARD --in-interface eth1 -j ACCEPT

iptables --table nat --append POSTROUTING --out-interface ppp0 -j MASQUERADE
iptables -I INPUT -s 10.0.0.0/16 -i ppp0 -j ACCEPT
iptables --append FORWARD --in-interface eth1 -j ACCEPT

-----------------------------

eth0 is my WAN
eth1 is my LAN
ppp0 is my VPN

But I have no idea how to get all the traffic from 192.168.200.125 to pass through VPN instead of the WAN... I just have no idea where to start. The REDIRECT in iptables looks interesting, but I'm thinking thats only for ports

Any help would be greatly appreciated
 
Old 04-07-2008, 12:38 PM   #2
datopdog
Member
 
Registered: Feb 2008
Location: JHB South Africa
Distribution: Centos, Kubuntu, Cross LFS, OpenSolaris
Posts: 806

Rep: Reputation: 41
on which side is 192.168.200.125 ?
 
Old 04-08-2008, 09:45 AM   #3
Usogi
LQ Newbie
 
Registered: Feb 2006
Posts: 4

Original Poster
Rep: Reputation: 0
192.168.200.125 is on the LAN side (eth1)
10.0.0.* is the VPN (ppp0)
 
Old 04-08-2008, 09:46 AM   #4
datopdog
Member
 
Registered: Feb 2008
Location: JHB South Africa
Distribution: Centos, Kubuntu, Cross LFS, OpenSolaris
Posts: 806

Rep: Reputation: 41
Thats easy just change your default route to the ppp0 device.
 
Old 04-08-2008, 10:24 AM   #5
Usogi
LQ Newbie
 
Registered: Feb 2006
Posts: 4

Original Poster
Rep: Reputation: 0
I'd already tried these on the router:


route add -host 192.168.200.125 dev ppp0
or
route add -host 192.168.200.125 gw 10.0.4.253

but they just kill the connection on the .125 computer. I can nolonger ping out to the internet or to the vpn. I kinda thought i was going down the wrong path with the route command...
 
Old 04-09-2008, 04:47 PM   #6
datopdog
Member
 
Registered: Feb 2008
Location: JHB South Africa
Distribution: Centos, Kubuntu, Cross LFS, OpenSolaris
Posts: 806

Rep: Reputation: 41
You can use the magic of iproute2 to create a separate routing table to handle that.
Code:
ip ro add 10.0.0.0/16 dev ppp0 table 4
ip ro add 192.168.200.125 dev eth1 table 4
ip ro add default dev ppp0 table 4
ip ru add from 192.168.200.125 lookup 4
ip ru add from 10.0.0.0/16 to 192.168.200.125 lookup 4
ip ro fl cache
 
Old 04-11-2008, 01:29 AM   #7
Usogi
LQ Newbie
 
Registered: Feb 2006
Posts: 4

Original Poster
Rep: Reputation: 0
sorry it took me a bit to respond.

AWSOME! that worked like a charm. I really like iproute2 stuff aswell, seems theres tons i can do in there =D

thanks!
 
  


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
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
reroute traffic through linux box curos Linux - General 3 06-13-2006 09:54 AM
VPN Traffic on Windows bLaDe Linux - Networking 5 03-24-2005 03:32 PM
VPN load traffic fr_laz Linux - Networking 2 02-19-2005 07:34 AM
Routing traffic to VPN connection nadams Linux - Networking 4 12-09-2003 09:19 AM
redirecting vpn traffic brb5548 Linux - Networking 1 07-01-2003 01:13 PM


All times are GMT -5. The time now is 10:36 PM.

Main Menu
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
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration