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

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
add comment

2 Answers 2

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
add comment

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
    address 192.168.2.1
    netmask 255.255.255.0
    up ip route add 192.168.4.0/24 via 192.168.2.200

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 192.168.4.0/24 dev eth2. And you may replicate this to the other interface.

share|improve this answer
add comment

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.