Two NICs, one server

I have two NICs on a fresh install of Ubuntu 10.04 LTS. Both are config'd be dhcp. Both cards are on the same lan with same gateway. everything about the cards is the same except the IPs they get, which is what I want.

What I'm trying to achieve is having both NICs operational at the same time.

Currently when the server boots, it activates both NICs, but the server can't resolve any domains. If I ifdown one of them and bring it back up, the server is able to resolve domains, but the NIC I bring up won't respond to any traffic.

Any ideas?

SOLVED

So basically both NICs should be on different subnets. The kernel will drop packets otherwise in the scenario I outlined.

A stopgap solution is to disable the dropping of packets with

# for i in /proc/sys/net/ipv4/conf/*/rp_filter ; do echo 0 > $i done

More info here: http://lartc.org/howto/lartc.kernel.html


Solution 1:

I've just recently had something quite alike. Please read http://lartc.org/howto/lartc.kernel.html.

Ubuntu 10.04 LTS by default filters packets that could have reached the host more directly. This makes networking dysfunctional on hosts with multiple paths to a network unless the kernel parameter is changed.

Solution 2:

It's a similar setup to a multi-homed router. I think it's a routing issue. Local processes receiving packets won't automatically send the response packets back out over the same adaptor.

You can check this with tshark. Run tshark -i eth0 and tshark -i eth1 (If those are your adaptors) on separate shells, then watch the flow of packets as you connect to each IP from an external source. If you see all return traffic going back out of eth0 for instance, then you'll need a couple of routing rules to sort that out, which is where iproute2 comes in. The HOWTOs (1) (2) are enormous , but I've found a useful blog post that should cover what you need, here:

http://kindlund.wordpress.com/2007/11/19/configuring-multiple-default-routes-in-linux/

(You can probabaly skip the kernel compilation stage.)

Solution 3:

If you have two NICs on the one LAN you almost certainly want to create a bonded interface (sometimes called teamed). They will share a single IP and can be configured to load-balance.