Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I have a LAN in my building that uses the 10.10.19.* IP range. In addition, I have an ADSL connection at home that uses the 192.168.1.* IP range internally. I also have two Ethernet cards.

Is there any way by which I can access the two networks at the same time? I need a rule that routes all 10.10.19.* traffic through eth0 and everything else through eth1. Is this possible?

I need to do this on Ubuntu 9.10 as well as Windows 7.

share|improve this question
add comment

3 Answers

up vote 9 down vote accepted

Absolutely possible. You need to configure your routes properly to do this. You want your default route to go through your eth1, so your routing table should look like this:

$ /sbin/route
Kernel IP routing table
Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
10.10.19.0      *               255.255.255.0   U     0      0        0 eth0
192.168.1.0     *               255.255.255.0   U     0      0        0 eth1
default         192.168.1.1     0.0.0.0         UG    0      0        0 eth1

Windows will look somewhat similar (with formatting variations of course) using the route print command.

You can set up the routes dynamically with the route commands on either platform. I'm not sure what configuration options you need to set one as default (and the other as not-default, obviously)... will edit with that info.

Edit: If you're working with the GNOME or KDE GUI network managers, look for a "set this interface as default" option in the configuration for your eth1 device.

If you're configuring /etc/network/interfaces by hand, take a look at the examples in this HOWTO. In particular, the up option allows you to run commands after an interface comes up. In your case, you may need to use that to run a route-delete command on an extra default route, or to run a route-add if neither of your interfaces set themselves as a default route:

# example /etc/network/interfaces
# replace the IP addresses in the route-del and route-add commands below
# with those appropriate to your network

auto eth0
iface eth0 inet dhcp
    up route del default gw 10.10.19.1
    # runs a route-delete if dhcp adds a default gateway for this interface

auto eth1
iface eth1 inet dhcp
    up route add default gw 192.168.1.1
    # runs a route-add if dhcp neglects to add a default gateway for this interface
share|improve this answer
add comment

Yes, you can.

If you setup both NIC with the right IP addresses, they will take care of routing packets through the right Interface.

The only thing you need to do is setup the default route (probably router on 192.168.1.* ADS network) for the packets not going directly to 10.10.19.* and 192.168.1.* networks.

In Linux:

$ sudo route add default gw 192.168.1.1

In Windows:

Use the control panel to setup default route.

share|improve this answer
add comment

This should JustWork(tm) as long as both networks use DHCP to hand out IP addresses and only one of them tries to be your default gateway.

If both try to be the default gateway and both do allow routing to the Internet at large, it'll probably work also, though I'm guessing the point of the ADSL line is that you want your external Internet traffic to go over that rather than through what-ever connection the rest of the LAN shares?

With the network cards connected as you intend to use them, could run the following commands in Ubuntu and let us know the output:
sudo ifconfig
sudo route
This will tell use what addresses and routes get set automatically in your current arrangement.

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.