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 3 normal desktop machine A,B and C which are part of same network. I have an apache web server on C. I want to have a scenario to test where i would like to route requests from A to C always through B. Is it possible to achieve this? B is not a designated gateway machine, its one of my normal desktop machines. Can i play around with routing table for achieving this? Please advice. B runs linux always and A and C can be any OS (for now i am using Windows).

Thanks in advance.

share|improve this question
up vote 1 down vote accepted

If machiens A, B and C are on the same network, that can easily be done bvy some host-specific routes on A and C. Normally, IP forwarding is disabled under linux, so you will have to enable that.

echo 1 > /proc/sys/net/ipv4/ip_forward


sysctl net.ipv4.ip_forward=1

If host A is, host B is and host C is, you'll need routes added as below. Host A:

ip route add via

Host C:

ip route add via

Equivalent routing should be doable under Windows, but I don't have the commands readily at hand.

share|improve this answer
thanks a lot vatine. I tried its equivalent in windows and it says, it cannot add the route for computers in a different subnet. Is it a requirement? i tried like this (IP is different) route ADD MASK – vpram86 Nov 5 '09 at 8:15

Do you mean something like setting up a proxy/socks tunnel? You could use ssh with the -D switch to create a tunnel from a port on A through to B.

E.g. run the below command on A then you should be able to point your web browser proxy configuration to port 8080 on your local computer (A) and everything will go through B

ssh -D 8080 -N username@serverB

If you want it to run until you shut computer A down you can use the -f switch as well which will send that ssh command into the background.

Note, you'll need ssh on machine B (you're running linux so no problem there) but you'll also need it on machine A. You could try Cygwin but it would be easier to install putty on machine A. (google for setting up a socks proxy login with putty -- it is quite easy and there are be plenty of tutorials)

share|improve this answer
Thanks a lot! I will give this a try. Don't i need any specific setting on B, for forwarding it to the actual destination C? Or its taken care by default? – vpram86 Nov 3 '09 at 10:21
As long as you have an account on B that you can ssh into then you're fine. To get to machine C when using the tunnel just do the same as what you'd do if you were physically at B using a web browser. – phoenix8 Nov 3 '09 at 10:51
I just remembered that if you want DNS resolution as well in firefox you might have to go to your about:config page (filter on 'socks' to narrow down the search) and set network.proxy.socks_remote_dns to true. – phoenix8 Nov 3 '09 at 11:00

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.