Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

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 two systems with ip address say name -wlan0) and,now what i want is , everytime I ping B from my system A, it has to be routed via a router say with address want this to be my next hop to reach B) , but this router is on a different subnetwork than the two systems.How do I do this?

/* Things I tried: I used 'route add -host B gw C wlan0', and got an error saying " no such process exist or no such device found". Tried ping C and traceroute and found the gw addr at my side is some, so added another entry route add -host C gw D wlan0, I was able to do this without any error! */

share|improve this question

Your wlan0 of your A computer exists on its own IP network block, you have not specified the netmask so let's assume it is or /24. In this case, A can reach any system with the IP without using a router (those systems of course need to be connected to the same layer 2 broadcast domain, ie. switch).

To reach your computer B, which is on a totally different network, computer A needs to know how to get to computer B. All computer A cares about is what IP address in its own network can help it get to computer B. This IP does not have to be directly attached to computer Bs network, which it does not seem to be in your case.

You need to figure out the routed path between your network A and network B. Your computer A will never be able to directly send packets to a router with IP as it doesn't know how to get to, A can only send packets to a router in its own IP network block. This is also everything A needs to care about. When the packet reaches the router connected to network A there needs to exist a route entry in A that knows how to get to B, either by being directly attached to router Bs network or by forwarding the packet to yet another router.

Please provide more detail on your network setup if you are looking for a more direct answer.

share|improve this answer
well,the netmask is /24, and yes i can reach B without using a router also it being on the same network,but i want it to explicitly pass through this router C which is on a different subnetwork. i can ping to C(my router), and B from A, but as of now the route taken to B is not via C but this is the route i want it to take! On running traceroute, the first gateway on my network is some, but then again C doesn't fall in this route from A ->B, also the A->C ping has the same D as first hop. – netg Mar 9 '11 at 9:20
I don't think am goin to be clear enough abt the network setup, but this is how i've understood, A,B are in the same network(Lan), can ping each other. – netg Mar 9 '11 at 9:31
Now am trying to test a particular client/server model, where A and B are the clients registered to C(a box running the server code), which is on a different network. – netg Mar 9 '11 at 9:31
In a normal scenario the route taken from A to B doesn't pass through C, and the first hop from A->B is a router(D) in the same network. But Now that I want to test a particular case I want C to be the next hop(or rather in the route) to reach B instead of the normal route(which doesn't involve C) it takes. A and B can individually ping C and each other successfully, the only thing I want now is to add entries to the routing table on my system(A) that'll route packets to B(same subnet) via C(on a different subnet). Thanks again:) – netg Mar 9 '11 at 9:32

Your Answer


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

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