Monday 21 May 2018

Accessing guest webservice in hosted vm

Wasted hours on this.
If having set up port forwarding or bridged you still can't connect to the guest's web server then possibly the guest firewall is blocking it.
For instance I was able to SSH to the guest OS instance but not connect to port 8000 where my guest was running a web service.
Using 'curl -v' I was able see that curl was making a connection and sending headers but getting no response.
So in my guest, which was centos, I put in a set of rules to effectively disable it iptables.
That fixed it!
---

Do in this in iptables has temporary effect until reboot...
   sudo su -
Then..
  iptables -P INPUT ACCEPT
  iptables -P OUTPUT ACCEPT
  iptables -P FORWARD ACCEPT
  iptables -F
Then try hitting the  address from the host again.


To make the changes permanent on Centos it's firewalld that I need to interact with as the front end of the firewall. This worked for me ...

   firewall-cmd --zone=home --add-port=8000/tcp --permanent

---
Other details...
My guest web service was running on centos and listening on 0.0.0.0:8000, ie all interfaces on port 8000. My host was Windows 10.
I had success with the following..
A) I setup NAT forwarding of port 8888 on my host in virtualbox to port 8000 of the guest. In virtualbox I did not provide an ipaddress for either the host or guest in the nat forwarding config. I then hit 127.0.0.1:8888 in the host and was able to access my site.
B) I also tried turning on bridged in virtual box then, after restarting the guest, I ran ifconfig  and found the network interface that was assigned a dhcp address by my router. This address was one starting with 192.168.0. as that's how my router is setup. Mine was 192.168.0.62 but yours will be different.
I then hit 192.168.0.62:8000 and was able to contact my site.
C) Finally I setup a bridged network in VMware workstation Player and did the same steps as B and that also worked.
In VMware player I couldn't see a place to configure the port forwarding so didn't try that. Probably need the paid version for that feature??

---

Hardware Hacking

Since the last post here I've taken to a bit of further hardware hacking and most of this is recorded on Hackaday  https://hackaday.io/j...