RE: The basis for deciding which NIC to use in a multiple NIC system

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Martinez, Michael wrote:
> Let's say you have a Linux system with two NIC cards each on the same
> subnet. Let's say the system wants to talk to another computer on the
> subnet. How does the kernel decide which NIC to use?  

I believe the last initialized card is given the subnet route. I don't
believe they automatically equalize.

> Is there a way to force the use of a particular NIC for an
> application running under a particular username? 

Yes, at least for outgoing connections.

Setup a new routing table dedicated for this new channel. The only route
will be default -> some_network. I assume you can do this yourself.

The second part is forcing data to/from the user to go out on the
correct interface.

# Routing
# Any traffic with 111 fwmark should exit network if
if_second_one(eth0,eth1,...)
ip rule add fwmark 111 table 111
ip route add default dev $if_second_one table 111

# Tell the system to mark any packet leaving the system coming from root
as 111
iptables -A OUTPUT -m owner --uid-owner root -j MARK --mark 111 

# When sending the marked packets over the network, send it as the IP
address of the second NIC.
iptables -A POSTROUTING --mark --mark 111 -j SNAT $Outgoing_IP



[Index of Archives]     [Linux Netfilter Development]     [Linux Kernel Networking Development]     [Netem]     [Berkeley Packet Filter]     [Linux Kernel Development]     [Advanced Routing & Traffice Control]     [Bugtraq]

  Powered by Linux