Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How do I tell linux to use one NIC/IP for LAN and the other for router 1

Status
Not open for further replies.

dalchri

Programmer
Apr 19, 2002
608
US
I have a Redhat 9 linux server that has two NICs:

1) Gigabit PCI (eth0)
192.168.0.8
255.255.255.0
no gateway
DNS: 192.168.0.3 (a local dns server)

2) 100/10 onboard (eth1)
192.168.0.9
255.255.255.0
Gateway: 192.168.0.254 (the router)
DNS: 192.168.0.3
(and a few other outside DNS servers)

I would like to use the faster NIC for the LAN and the slower NIC for traffic from the Internet from our router.

I have no trouble setting up DNS and the router so that the LAN clients all use 192.168.0.8 and the router uses 192.168.0.9. However, I have trouble getting the linux box to reply to LAN requests using the correct NIC.

For example, if I only plug in the gigabit card, I cannot ping either 192.168.0.8 or 192.168.0.9 from a LAN client. If I only plug in the 100/10 card, I can ping BOTH 192.168.0.8 and 192.168.0.9. Its like the linux box isn't even using the gigabit card.

Both of these identify a unique ip address:
/etc/sysconfig/network-scripts/ifcfg-eth0
/etc/sysconfig/network-scripts/ifcfg-eth1

What did I do wrong? Is there even a way to control this?

I want all traffic for 192.168.0.* to go through the gigabit card and all other traffic to go through the 10/100 card.

-or-

At the very least, I'd like all traffic to exit using the same card that it came in on and the IP addresses that I've assigned to the NIC's to actually stick.

Thank you for any suggestions!
 
They key that you're missing is that from a routing standpoint, traffic destined for the internet has to go to the router, which is on 192.168.0.*, so the traffic as far as the IP stack is concerned *is* for 192.168.0.*.

You need to configure your interfaces on different subnets. Make the lan 192.168.0.0/24 and the link between the router and the other NIC 192.168.1.0/24 with the router on the same subnet.

If that breaks the other single homed hosts on the net, then just forget the whole thing, because you're not going to gain anything substantial by doing it.

You may also look at adding a host route for the router, but seriously, you're not going to get any noticible performance boost from all this.

 
For grins, try this:
Code:
route add -host 192.168.0.254 gw 192.168.0.9
I think that will force the stack to use eth1 to talk to the router.
 
That worked like a champ. Once I explored the routing table, I found that eth1 was set to be used for all traffic.

route add -host 192.168.0.254 gw 192.168.0.9

combined with

route add -net 192.168.0.0/24 dev eth0

Gave me my solution. I know what you mean, not much of a performance boost but I'd hate not to use the onboard NIC.

Thanks for the tip!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top