Take the 2-minute tour ×
Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

This is really broad so tell me if I'm outside the scope of this site. With that said....

I want to setup an Ubuntu machine on my network which has an OpenVPN client installed configured to send all network traffic. I then want to use the Ubuntu machine as a gateway for some devices on my LAN so that they too are using the connection provided by the OpenVPN client.

I've been digging through the Ubuntu forums and am coming up blank, mainly because I'm not sure exactly what I'm looking for.

Do I need to be using static routes to accomplish this? Or is there an easy way to setup this type of configuration?

Many thanks.

share|improve this question

1 Answer 1

up vote 1 down vote accepted

I think you're asking how to change how outgoing traffic is routed when leaving your network based on the device generating the outgoing traffic. Say, for example, have your appleTV use a VPN tunnel instead of your regular default gateway. If that's the case, you're asking about Policy Based Routing.


Prerequisites:

  • IPRoute2

What you want is made possible by the above package. This is typically referred to as policy-based routing, and in your specific case source policy routing.

You'll need to complete the following:

  • Check which routing table numbers are used: cat /etc/iproute2/rt_tables
  • Create a routing table which includes the machine in question
  • Add the default route for the specific table
  • Flush the route cache

I don't have a Linux terminal handy; but it should be something like this:

echo ### tableName >> /etc/iproute2/rt_tables ## pick a number not in use

ip rule add from ip.add.of.box table tableName

ip route add 0.0.0.0/0 dev tun0 table tableName ##assuming tun0 is your VPN

ip route flush cache

share|improve this answer
    
That's exactly what I was getting at, thanks Sean I'll give this a go. –  sgtbeano Mar 7 '13 at 20:40

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.