Score:0

Bifurcation of packets depending on LAN and WAN traffic and forwarding them to different gateways

in flag

The current scenario of my interfaces with their IPs and Gateways are as follows.

PC1 ->

   IF11  192.168.1.100     GW  192.168.1.220

PC2 ->

   IF21  192.168.1.210     GW  192.168.1.1
   IF22  192.168.1.220     GW  192.168.1.250

PC3 ->

   IF31  192.168.1.250     GW  192.168.1.1
   IF32   x.x.x.x

The way I want my network traffic to move is as follows:

In PC1 ->

All traffic from PC1 will move to PC2 IF22.

In PC2 ->

All LAN traffic will be forwarded to PC2 IF21 who in turn forwards them to my gateway.

All WAN traffic will be forwarded to PC3 IF31.

In PC3 ->

IF32 is a VPN tunnel interface. I already configured this PC such a way that all traffic coming to IF31 is forwarded to IF32 to communicate with WAN. The commands used in PC3 is as follows:

echo 1 >/proc/sys/net/ipv4/ip_forward
iptables -A FORWARD -i IF31 -o IF32 -j ACCEPT
iptables -A FORWARD -i IF32 -o IF31 -m state --state ESTABLISHED,RELATED -j ACCEPT
iptables -t nat -A POSTROUTING -o IF32 -j MASQUERADE
echo "net.ipv4.ip_forward = 1" >> /etc/sysctl.conf

Now I want help in configuring PC2 in such a way that it identifies the packets (maybe via destination?) and forwards them as needed. Or maybe if it is possible to use only 1 interface in PC2 and apply policy rules on it for forwarding to different gateways?

LAN destination network can be for example 192.168.20.0/24 and 192.168.30.0/24

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.