9

I have my network set up like this. http://docs.google.com/Doc?docid=0AZ1YxuLE4djaZGhqN2s1NmRfMjhjNjc0Ym1meg&hl=en

In words: I have a machine (Calcium, running Arch Linux) that has two network interfaces. eth0 is hoooked up to a router, and is gigabit. Eth1 is hooked up directly to the university network over 10Megabit. The router's uplink is hooked up to the university network as well, and it is also 10Megabit.

Currently (I believe) all traffic on Calcium is going through eth0, through the router, regardless of whether it is internal or external. (How can I confirm this?)

Ideally, traffic that is destined for the internal network (192.168.10.0/24) would travel over eth0 to the router, and wherever it is going. ALL other traffic should go over eth1.

  • Added tags: tcpip routing route – Warner Mar 17 '10 at 20:10
  • Your Google document doesn't help much here if you don't grant people permissions to access it. – Zoredache Mar 17 '10 at 21:32
  • Sorry. I thought I made it public, but Google docs didn't seem to remember my setting. It should be accessable now. – Mike Cooper Mar 17 '10 at 21:43
8

Your network routing table will determine how the packets are routed. You can add additional routes or change the default gateway to affect the routing.

If you would like additional assistance, please provide your routing table.

To display the routing table:

/sbin/route -n

To delete default gw:

/sbin/route del default gw $IP

To add default gw:

/sbin/route add default gw $IP

For additional details, check out the manpage. There are other ways to manipulate and display the routing table as well.

netstat -r to display and ip to manipulate further.

14

Here's the complete answer, in case it helps others:

To make packets with destinations 192.168.10.* use eth0, and all other packets use eth1:

1) View your current routing table

ip route list

One entry will be something like "default via 192.168.1.1" where 192.168.1.1 is your router (a.k.a. gateway) ip address. Remember the gateways for eth0 and eth1, as we'll need them later.

2) Delete the default route(s). (Warning: this will kick you offline.)

ip route del default

3) Add a new default route (this will bring you back online). Replace 192.168.1.1, below, with your gateway ip address from above.

ip route add default via 192.168.1.1 dev eth1

4) Add a specific route that will be served by eth0. More-specific routes automatically take precedence over less-specific ones.

ip route add 192.168.10.0/24 via 192.168.1.1 dev eth0

Finally, you can ask Linux which interface will be used to send a packet to a specific ip address:

ip route get 8.8.8.8

If the configuration worked, packets to 8.8.8.8 (Google's server) will use eth1. Packets to any ip on your local network:

ip route get 192.168.10.7

will use eth0.

  • excellent answer for beginners – Stephane Aug 17 '17 at 6:27

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.