1

Hello SuperUser Community!!

I'm so happy to write here, I'm stuck on a strange issue:

I've 2 VM on my VirtualBox lab

one VM has only the HostOnly Interface (eth0) the other VM has the HostOnly Interface (eth0) and also a NAT Interface (eth1) with public internet access (ping 8.8.8.8 result OK)

So I just want do a very simple task: I wanna ping 8.8.8.8 via the first VM, so I added a route on this VM saying to use the HostOnly Interface in order to find 8.8.8.8

ip route add 8.8.8.8 dev eth0

I enabled the Forwarding Packets option on the second VM:

sudo echo 1 > /proc/sys/net/ipv4/ip_forward

And I tried, with no success, I mean, on the second VM I receive the Ping request from the first VM but I don't obtain response.

Can you help me?

If can help, here the IPs assigned to the VMs: -Net conf of VM 1: eth0: 192.168.56.104 (host only net) -Net Conf of VM 2: eth0: 192.168.56.102 (host only net), eth1:10.0.2.9 (with public access).

Thank you so much!!!

2
  • Your 1st VM is connected to host only. There are only 2 machines in this network: host and VM. There's no 8.8.8.8.
    – gronostaj
    Commented Jul 17, 2020 at 14:36
  • actually from VM1 I can ping VM2 and if I ping 8.8.8.8 from VM1, VM2 receive the Ping (due to the static route added)
    – alessandro
    Commented Jul 17, 2020 at 14:38

1 Answer 1

1

try to MASQUERADE the packet received in the VM2. In your case, I would try with:

iptables -t nat -A POSTROUTING -o eth1 -j MASQUERADE
1
  • Thank you Giuseppe! It worked, you made my day. Bye!
    – alessandro
    Commented Jul 18, 2020 at 21:30

You must log in to answer this question.

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