0

Basically I would like to know what should I do to connect two PCs in different networks and make them to see each other.

The diagram is like the following

linux-pc-1-1 (192.168.0.2 eth0) <---> (192.168.0.1 eth0) linux-pc-1 (10.0.0.1 eth1) <---> (10.0.0.2 eth0) linux-pc-1-2

Basically I want to ping from linx-pc-1-1 and get an answer from linux-pc-1-2 and the oposite.

I was trying to create a route in linux-pc-1-1 to the net 10.0.0.0/24 via 192.168.0.1

ip route add 10.0.0.0/24 via 192.168.0.1

And in linux-pc-1-2

ip route add 192.168.0.0/24 via 10.0.0.1

But it doesn't work.

Can anyone help me explaining why I can't do this and how to solve this problem?

1 Answer 1

0

basicaly you need to enable packet forward on linux-pc-1:

echo 'net.ipv4.ip_forward = 1' >> /etc/sysctl.conf
sysctl -p

and then add rules in firewall to allow forwarding:

iptables -A FORWARD -j ACCEPT

and if your pcs linux-pc-1-1/linux-pc-1-2 have correct route settings, all should work.

1
  • Thank you. I've already found a solution. The linux-pc-1 should have the configuration you told. but additionally, we should set the gateway from eth0 and eth1 of linux-pc-1 to 0.0.0.0. And the gateways from linux-pc-1-1 and linux-pc-1-2 192.168.0.1 and 10.0.0.1 respectively. By the way, thank you for answering. Commented Jun 13, 2020 at 22:15

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .