Quote:
EDIT: So now i can access my guest OS using eth1 interface but when i try to access guest OS using ip of eth0 interface neither i can ping nor ssh.It means that it won't be accessible from internet (other than host OS and other guests).
|
You should be able to work around this by allowing internet access from the guest through your host's network interface.
Here's what I do if I want a virtual machine to be accessible through SSH while still having internet access:
1. Set up iptables/IP forwarding on the host:
Code:
iptables -t nat -A POSTROUTING -o <host network interface> -j MASQUERADE
echo 1 > /proc/sys/net/ipv4/ip_forward
(don't forget to (re)start iptables
)
2. Set the default gateway/DNS nameservers on the guest: point the gateway to the IP of the host virtual network interface (typically
vboxnet0), and set the DNS servers to be identical to those on the host. I usually stick these lines in
/etc/rc.local (or whatever the equivalent init script is in whatever distro/OS it is that I'm messing with
):
Code:
echo "nameserver <ISP DNS server IP, or maybe router IP>" > /etc/resolv.conf
route add default gw <IP of virtual host interface>
I don't guarantee that this exact setup will work for you, but it works for me, so…
:-\
EDIT: If you need more details on this,
the Arch Wiki delivers.
Most of the information there should apply just as well to a "share" between a host and a VM as it does a network between two real machines.