Home » Questions » Computers [ Ask a new question ]

Can I connect to two networks simultaneously with two Ethernet cards?

Can I connect to two networks simultaneously with two Ethernet cards?

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.

Asked by: Guest | Views: 271
Total answers/comments: 2
Guest [Entry]

"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"
Guest [Entry]

"This should JustWork™ 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."