Visit Jeremy's Blog.
Go Back > Forums > Linux Forums > Linux - Networking
User Name
Linux - Networking This forum is for any issue related to networks or networking.
Routing, network cards, OSI, etc. Anything is fair game.


  Search this Thread
Old 07-13-2012, 09:46 PM   #1
Registered: Apr 2011
Posts: 31

Rep: Reputation: 0
IPTABLES ? - 1 ip in a different subnet push all traffic from that ip through vpn


I have a linux machine that I use as a vpn openVPN server and a pptp client and home router.

I have another machine that I want to use for connecting to a foreign country. This machine does not need to connect to any other resources on the "home network".

How can I get IPTABLES or any other app to forward all traffic, TCP, UDP etc. everything this device might use through a VPN interface? I've tried a couple of things and its not working.

If the above doesn't work I do have space to put another NIC in the router. Whilst I'd rather not spend the money, if that is the only way to do it I'm open to that too.

Old 07-14-2012, 11:15 AM   #2
Registered: Apr 2011
Posts: 31

Original Poster
Rep: Reputation: 0
I see lots of views on this but no answers, do I need to rephrase the question? Or am I asking something that cant be done?
Old 07-18-2012, 03:40 AM   #3
Registered: Apr 2009
Location: Perth, Australia
Distribution: Ubuntu/CentOS
Posts: 208

Rep: Reputation: 51
Your question is not very clear. It would help if you could draw up a basic network diagram showing the configuration that you are hoping to achieve.

Do you currently have a VPN connection to the foreign country you have specified?
Old 07-18-2012, 04:34 AM   #4
Registered: Jan 2010
Distribution: Debian, Centos, Ubuntu, Slackware
Posts: 361
Blog Entries: 3

Rep: Reputation: 48
There's an option in OpenVPN server configuration file, which allows to pass all client's traffic through the VPN link, making it a default gateway.

# If enabled, this directive will configure
# all clients to redirect their default
# network gateway through the VPN, causing
# all IP traffic such as web browsing and
# and DNS lookups to go through the VPN
# (The OpenVPN server machine may need to NAT
# the TUN/TAP interface to the internet in
# order for this to work properly).
# CAVEAT: May break client's network config if
# client's local DHCP server packets get routed
# through the tunnel.  Solution: make sure
# client's local DHCP server is reachable via
# a more specific route than the default route
# of
;push "redirect-gateway"

Last edited by Lexus45; 07-18-2012 at 04:39 AM.
Old 07-18-2012, 11:25 PM   #5
Registered: Apr 2011
Posts: 31

Original Poster
Rep: Reputation: 0
Thanks for the replies. I found a solution this afternoon, sourced based routing.

It wasn't exactly what I wanted but it will do the job; I think the ideal would be destination based routing but I will look into that in the future.

Thanks for the replies.


client, router, vpn

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
IPTables unable to nat trough VPN traffic cygnusx Linux - Networking 1 04-27-2012 10:11 AM
Forcing all traffic through VPN (using iptables?) tbaac Linux - Networking 4 04-25-2011 09:24 AM
IPTABLES: Forward from VPN to LAN, Need traffic to appear as if its coming from LAN. a2brute Linux - Networking 3 11-17-2008 11:53 AM
Trying to configure shorewall to allow bridged vpn traffic to the local subnet perlchun Linux - Networking 4 06-25-2008 09:13 PM
IPTables Reroute Outing Traffic Through VPN Usogi Linux - Networking 6 04-11-2008 01:29 AM > Forums > Linux Forums > Linux - Networking

All times are GMT -5. The time now is 08:35 PM.

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