The vboxnet I/F is then selected for the VM. Now using iptables, the following network forwarding rules are set up to provide internet connection to the VM:vboxmanage hostonlyif create
vboxmanage hostonlyif ipconfig vboxnet0 --ip 192.168.56.1
Now, IP forwarding in the kernel so that these settings are set to Active (required for WWW Internet access):sudo iptables -A FORWARD -o eth0 -i vboxnet0 -s 192.168.56.0/24 -m conntrack --ctstate NEW -j ACCEPT
sudo iptables -A FORWARD -m conntrack --ctstate ESTABLISHED,RELATED -j ACCEPT
sudo iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE
My questions are:echo 1 | sudo tee -a /proc/sys/net/ipv4/ip_forward
sudo sysctl -w net.ipv4.ip_forward=1
1. I would like to know what is going on here exactly and how do these rules allow a host-only VM to have internet when, otherwise, it shouldn't.
2. I have another VM configured with bridged networking. My host is able to ping my host-only VM, but my bridged VM is not able to ping the host only VM even though both host machine (not host VM) and the bridged VM are in the same subnet. Therefore why can't the bridged VM ping the host-only VM? Why do I need to add the host-only interface (vboxnet0) as a 2nd interface to my bridge VM so it can ping the host-only VM?
I would really appreciate it if someone could clarify this to me. Thank you in advance.