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 ( --- ( comp3 ( --- ( comp2

This is how I set up the addresses and routing:

ip link set eth0 up
ip a add dev eth0

ip ro add via

ip link set eth0 up
ip a add dev eth0

ip ro add via

ip link set eth0 up
ip link set eth1 up
ip a add dev eth0
ip a add dev eth1

Computers 1 and 3 can ping each other ( to and to 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 ( 56(84) bytes of data.
--- ping statistics ---
4 packets transmitted, 0 received, 100% packet loss, time 3049ms

Why does it happen and what am I doing wrong?

  • 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

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


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

  • 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.