In this article we will learn how to configure networking between Linux host OS and Windows Guest (VM) using Virtualbox
1. First of all download and install Virtualbox on your Linux host and install the guest operating system
2. Now configure network on Guest OS, open VM settings and click Network
3. Select Host-Only Adapter from "Attached to" combo
The VM will create the default network interface named by "vboxnet0" on the host OS,
vboxnet0 Link encap:Ethernet HWaddr 0A:00:27:00:00:00
inet addr:192.168.56.1 Bcast:192.168.56.255 Mask:255.255.255.0
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:0 errors:0 dropped:0 overruns:0 frame:0
TX packets:3599 errors:0 dropped:0 overruns:0 carrier:0
RX bytes:0 (0.0 b) TX bytes:3896747 (3.7 MiB)
VirtualBox automatically assigned IP address 192.168.56.1 on the host to that network interface.
4. Launch the XP guest OS from virtualbox and configured the network upon VM successfully boot
PING 192.168.56.10 (192.168.56.10) 56(84) bytes of data.
64 bytes from 192.168.56.10: icmp_seq=1 ttl=128 time=1.83 ms
64 bytes from 192.168.56.10: icmp_seq=2 ttl=128 time=0.512 ms
Enabling Internet for VM.
Above steps was fine as far as networking between Host and VM is concerned, however if you want to let VM also access the Internet then you have to configure the following iptables rules and enable ipfowarding on Host OS.
# insert NAT rule
iptables -t nat -A POSTROUTING -o vboxnet0 -j MASQUERADE
iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE
# enable forwarding
echo 1 > /proc/sys/net/ipv4/ip_forward