2

I have 4 pc´s and another pc, which will act as a proxy, all being in the same network: 172.16.96.0/20 . I can ping between each other. But, I want to separate them into two groups. That is:

pc1 is directly connected to pc2
pc3 is directly connected to pc4

But, all traffic from pc1 or pc2 to pc3 or pc4 has to go through proxy and all traffic from pc3 or pc4 to pc1 or pc2 has to go through proxy. Something like:

pc1          pc3
 |   -proxy-  |
pc2          pc4

pc1 IP: 172.16.97.24 
pc3 IP: 172.16.97.27
proxy IP: 172.16.97.2

To do that on pc1 I added:

ip route add 172.16.97.27 via 172.16.97.2

But, when I do traceroute 172.16.97.27, 172.16.97.2 does not appear as a hop..I am not sure if it should..

On proxy the routing table looks like:

default via 172.16.111.254 dev eth0 
172.16.96.0/20 dev eth0  proto kernel  scope link src 172.16.97.2  

Because of the last line, I think I should add another source that is pc1 172.16.97.24. And to be able to forward the traffic received from pc1 (172.16.97.24) to its destination(either pc3 or pc4), I used this:

ip route add 172.16.96.0/20 via 0.0.0.0 src 172.16.97.24

Error: RTNETLINK answers: No such device

ip route add 172.16.96.0/20 dev eth0:0 via 0.0.0.0 src 172.16.97.24

Error: RTNETLINK answers: Invalid argument

and:

ip route add 172.16.96.0/20 src 172.16.97.24

Error: RTNETLINK answers: No such device

I am not sure if I am going on the right path to do this configuration. Please tell me if not. Thank you!

0

You need to divide your IP networks to smaller sections if you want to perform IP routing using the proxy.

Your pc1/pc2/pc3/pc4 all have a network mask of 255.255.240.0, which means that all those IP addresses are in the same IP subnet. Therefore they will communicate directly with each other and don't route packets via routers.

A working routing configuration could be something like this:

pc1: IP 172.16.96.3/24
pc2: IP 172.16.96.4/24
pc3: IP 172.16.97.3/24
pc4: IP 172.16.97.4/24

Proxy: IP 172.16.96.1/24, 172.16.97.1/24

And then you would add routing table entries in PC1/2:

ip route add 172.16.97.0/24 via 172.16.96.1

And in PC3/4 respectively

ip route add 172.16.96.0/24 via 172.17.97.1

So, you would have two separate IP subnetworks.

  • Hello! Thank you for your answer! Putting them in different subnets would be a good idea, but I am not sure yet if I am allowed to change the existing configuration. Until now I managed to do it like this: stackoverflow.com/questions/31435640/… What do you think about this approach? When I trouceroute I can see that the traffic passes through proxy..But from time to time, it doesn´t..it´s like it realises that it has a shorter route. Maybe there is a way to set priorities. – Roxana Roman Jul 16 '15 at 14:06

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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