Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'm trying to set up proper networking on Ubuntu 12.04 LTS with 4 ethernet connections. Each connection is on a different subnet and two of the subnets are connected to other subnets. For example, one ethernet port is connected to the 192.168.2.x subnet and can also reach the 192.168.4.x subnet on that connection.

I'm successfully setting up static IP addresses, gateways, etc. However, connections from outside a subnet (i.e. a VPN on the 192.168.2.x subnet) always go out on the default gateway. When that default gateway is not the gateway for that particular subnet, the external VPN connections fail.

I've had some luck using iproute to create some functionality, but I'm in the dark about the best approach to resolving the issue in a long-term way.

share|improve this question

The default gateway really is just that, the default route that will be used when no other route is defined either statically or with a routing protocol. You can think of a computer connected to multiple subnets as a router. It will use the corresponding interface when it is connecting to that subnet, but otherwise use the interface containing the default route. If you want traffic going to the 192.168.2 subnet to go out a specific interface you can statically set that BUT you will probably run into trouble when you find your packets get returned to the subnet containing your VPN's default route.

I think its helpful to take to mind that multi-homed machines = big hassle

share|improve this answer

As far as I could see from your question, your computer is the core of the network and, I believe, the VPN Gateway. All you have to do is add some static routes to your configuration.

In order to add this configuration, you have to edit the file /etc/network/interfaces, that I figure you are already familiar with, and add some statements, as follow:

auto eth2
iface eth2 inet static
    up ip route add via

I added the route pointing to another gateway, but if the network is directly connected to this interface, you may just add as ip route add dev eth2. And you may replicate this to the other interface.

share|improve this answer

Your Answer


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.