Communication from ROS in a virtual machine to the host or outside machines should work fine. Normally, if you create a VM (virtual box as an example on linux) it sets your network information to NAT (network address translation). Usually, this will connect your VM to the network with no problems. ROS should run fine within this VM as long as you have your allocations (memory, HD, etc) setup to be sufficient enough to run ROS (which shouldnt be very much) and the VMs operating system.
However, it is common for VMs to crawl compared to the host machine. If you run into this problem, it is not ROS' fault, but just the VM/OS in general. Again, try giving your VM a larger share of memory or processor or whatever settings you have. You may run into this issue moreso if you start using significant graphics within the VM.