Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have computer A, computer B and computer C. Computer A and B are connected, and computer B and C are connected. How can I get computer A and C to communicate with each other? I'm assuming I need to add some routes to each machines but i'm unsure exactly what they should look like. For the sake of examples lets say computer A is and computer C is and computer B is Don't get them mixed up!

Thank you

share|improve this question
Do you mean, they're connected to each other? or to a switch? Does computer B have two nics? why does C's network need to be different from A and B? – l0c0b0x Aug 11 '09 at 16:43
Is this a thought experiment exercise in routing, or are you trying to achieve something simple like have all 3 computers communicate with each other on the same LAN? – Nick Kavadias Aug 11 '09 at 17:13
Once again, does Computer B have two network interface cards? Are you assuming Ethernet and TCP/IP? – kmarsh Oct 8 '09 at 11:41

You'll need another NIC on computer B with an address on the same network as computer C, so lets say you have that & its ip is

lets also assume that these networks are subnetted as class C's /24

make computer A have a default gateway of (computer B)
make computer C have a default gateway of (computer B)

run this on computer B:

 echo 1 > /proc/sys/net/ipv4/ip_forward
 ip route add via
 ip route add via
share|improve this answer
Those routes should exist simply by virtue of adding the IP address(es) to the network interfaces. – Vatine Aug 11 '09 at 17:46
i think it depends on the distro. either way, you can check with the route command to show you whats there in case adding these is redundant – Nick Kavadias Aug 11 '09 at 18:17

change the subnet mask to and connect all the machines to the same switch, no need for any routing

share|improve this answer
Good answer. To anyone implementing this, be careful though. It applies in this particular case, given the example IPs, not generally. – Lee B Oct 8 '09 at 9:21

This could be very simply a matter of merging subnets (by either changing IPs or relaxing the subnet masks), depending on your setup.

Assuming it's not that easy, then basically, you need to do three things for the general case:

  1. Tell computer B to act as a router. That's the "echo 1 > /proc/sys/net/ipv4/ip_forward" that's been mentioned. This just tells the linux kernel to accept packets for other machines, and to send them on to their destination using the machine's routing tables.

  2. Tell A to talk to C through B. Working on A, "ip route add c_ip via b_ip" should do it.

  3. Tell C to talk to A through B. Working on C, "ip route add a_ip via b_ip" should do it.

However, if A and C both use B as their default gateway, then they will (by definition) assume that everything should go through B, so steps 2 and 3 are unnecessary in that case.

share|improve this answer

add a second address to computer b on the same network range as computer c and enable ip routing, this will turn computer b into a router on a stick. no need for a second NIC

share|improve this answer

This question was actually posted by a colleague of mine. Here's the issue, all of our servers have Intel Pro/1000s, and it's cheaper to link those directly together than to buy a switch capable of handling the server-to-server load (tbh, we can't afford such a switch). We have ip_forward set to 1 on all servers. We're using Gentoo with iproute2. Server C is Gentoo with ifconfig. Here's copies of their conf.d/net's, with the server names being the only thing changed:

Server map:

Server A eth1 -> Server B eth1
Server B eth0 -> Server C eth2

Server A:

config_eth1=" netmask"
routes_eth1="add dev eth1
add -net dev eth1"

Server B:

config_eth1=" netmask"
routes_eth1=" dev eth1"
config_eth0=" netmask"
routes_eth0=" dev eth0"

Server C:

config_eth2=" netmask"
routes_eth2= dev eth2 via"

Server A has no problem talking with Server B, and server B has no problem talking with Server C, but A and C cannot communicate via B. During a communication attempt, tcpdump shows unanswered arp who-has requests. I've never used Linux as a router before, so my knowledge on the topic is quite limited.

share|improve this answer
Have you considered simply connecting A to C as well? Then each machine has a dedicated gigabit link to each other machine, and you don't have to deal with routing or server B becoming a point of failure for A-C communication. – mattdm Nov 19 '10 at 4:31

on machine B:

echo 1 > /proc/sys/net/ipv4/ip_forward
share|improve this answer
That simply allows machine B to act as a router. Teaching the other machines to USE that router is another matter. – Lee B Oct 8 '09 at 9:22

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.