1

I'm creating a local network of three virtual machines (all Ubuntu 14.04, just from the box). The first one is connected to the third and the second is connected to the third as well.

That's it: comp1 (5.9.10.10) --- (5.9.10.20) comp3 (5.9.20.20) --- (5.9.20.10) comp2

This is how I set up the addresses and routing:

vm1:
ip link set eth0 up
ip a add 5.9.10.10/24 dev eth0

ip ro add 5.9.20.0/24 via 5.9.10.20

vm2:
ip link set eth0 up
ip a add 5.9.20.10/24 dev eth0

ip ro add 5.9.10.0/24 via 5.9.20.20

vm3:
ip link set eth0 up
ip link set eth1 up
ip a add 5.9.10.20/24 dev eth0
ip a add 5.9.20.20/24 dev eth1

Computers 1 and 3 can ping each other (5.9.10.10 to 5.9.10.20 and to 5.9.20.20 and back), the same with computers 2 and 3.

But when I try to ping computer 1 from computer 2, or 2 from 1 ping packets get lost.

PING 5.9.20.10 (5.9.20.10) 56(84) bytes of data.
--- 5.9.20.10 ping statistics ---
4 packets transmitted, 0 received, 100% packet loss, time 3049ms

Why does it happen and what am I doing wrong?

2
  • because comp3 is not working as a router.the reason that comp1 & comp2 can ping comp3 is not the routes you have added, because they are connected directly. By default the packets with different destination address received will be dropped not routed.
    – binarysta
    Apr 22 '20 at 11:24
  • how can I make it work as a router? Apr 22 '20 at 11:35
1

From what I can tell, your config is correct, you just need to tell the router to enable IP forwarding. Never did it with ufw, but for testing you can disable the firewall.

For IP forwarding you just need to add/edit this line in /etc/sysctl.conf

net.ipv4.ip_forward=1

Details about ufw https://www.cyberciti.biz/faq/how-to-configure-ufw-to-forward-port-80443-to-internal-server-hosted-on-lan/

1
  • yep, it worked. Thanks a lot Apr 22 '20 at 11:47

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.