Page 1 of 1

Issue with providing access to a DB running in a Guest VM

Posted: 30. Mar 2020, 00:16
by GVVM
Host runs Ubuntu
Virtualbox version is 6.1
Guest runs Ubuntu as well
Postgres db runs on guest.

I would like to give access to clients from outside my LAN to the postgres db.

Here is what I tried and it did not work. Any suggestions appreciated.
First let me explain the network.

I have a router/model that is connected to the ISP line.
Then there is a mesh network Which feeds off of the ISP Router.
My HOST is connected to the WIFI network of the MESH NETWORK. I do not connect to the ISP Router at all...

My ISP router default IP is 192.168.1.1 and subnet mask is 255.255.255.0
I checked my host IP of the Linux machine and the IP of the guest VM they both are 192.168.82.xx.

Q1. Why are they seemingly from a different subnet?

Q2. When I tried to setup NAT forwarding on my ISP Router. It complains that the "LAN Host IP is not in the same subnet as LAN IP".

I am not sure how to login to the mesh network to see if this is causing the issue.

Any help/insights appreciated.

Ganesh

Re: Issue with providing access to a DB running in a Guest VM

Posted: 30. Mar 2020, 03:38
by scottgus1
Check your Virtualbox network setting and compare to Virtualbox Networks: In Pictures.

Bridged or NAT will be where you'll end up, though Bridged does not always work with Wi-Fi, and if you want folks to get access to your guest from the internet you should consider being wired.

Please post the text output of 'ifconfig' in the host and the guest, as well as 'vboxmanage list hostonlyifs'

Re: Issue with providing access to a DB running in a Guest VM

Posted: 30. Mar 2020, 23:45
by fth0
If the ISP router is not part of the Mesh Network, then you'll have two cascaded NAT gateways: One between the 192.168.82.0/24 network and the 192.168.1.0/24 network (the Mesh router), and one between the 192.168.1.0/24 network and the Internet (the ISP router). In this case, you'll accordingly need two port forwardings.

Re: Issue with providing access to a DB running in a Guest VM

Posted: 1. Apr 2020, 13:52
by GVVM
@scottgus1

Thank You for your suggestion. I was able to get an IP from the ISP router (set) 192.168.1.x by hardwiring the internet cable.

@fth0

My settings are as follows (a bit reversed) from what you mentioned.
My ISP provider router/modem has a subnet CIDR if 192.168.1.0/24
I have a mesh network as well. The subnet is 192.168.86.0/24

I eliminated the wifi issue in this exercise by following @scottgus1 idea by plugging the host OS to the router.
Now my host machine and guest machines have a 192.168.1.x IP.
So far so good.

My router is a TPLINK (router/modem) TC-W7960. Though I have setup port forwarding rules like below

service external port ip internal port protocol
5432 192.168.1.159 5432 TCP
SSH 22 192.168.1.159 22 TCP

(159) is my guest OS IP. I tried setting it to the host OS as well it did not work either.

my attempts to connect fails.
PING to my ISP IP fails.

called support but it was not helpful.

Any ideas

Re: Issue with providing access to a DB running in a Guest VM

Posted: 1. Apr 2020, 19:44
by scottgus1
Like fth0 said, you have two cascaded routers, it appears. I used to have the same setup. A DSL modem acted as a router, 192.168.1.#/24, and a Linksys WRT54G, also acting as a router, 192.168.0.#/24. The ethernet output of the modem went to the WAN side of the Linksys, and the modem gave the Linksys WAN an IP of 192.168.1.10. When I wanted services accessible to the internet, I had to port-forward in the modem to 192.168.1.10, then port forward in the router to the computer's 192.168.0.### IP address.

I eventually set up the Linksys router as a wireless access point and switch instead of a router, and had the modem be the router for the whole network. Then there were no more double-NAT and twice the port-forwarding.

You must either port-forward in each device to the next device's IP address, or set the "mesh network" device to be a switch instead of a router, then the ISP router will handle the whole network. I would suggest the second choice: simplify your network by setting the mesh device to be a switch.

Your guest should be Bridged, then it will get an IP address from the network same as the host PC does. Then port-forward to the guest's network name or MAC address if the router can do so. You can also set a static IP address on the Bridged guest in the network's IP range, then port-forward to that guest's IP address.

Re: Issue with providing access to a DB running in a Guest VM

Posted: 3. Apr 2020, 14:45
by GVVM
From your earlier comment, I hardwired the host machine to the MODEM/Router. Now I get a 192.168.1.x IP for my host and guest os.
The issue of 192.168.86.x IPs were because I did not hardwire the pc to the modem/router and that it was connected to the WIFI point of the mesh router.

But now that problem is solved.

So since the host and guest has IPs from the modem/router and essentially the mesh network is not in play anymore, do I have to still convert my mesh router to a access point? Should it not work with the new setup?

yesterday, I tried to access the mode/router remote admin port from outside my LAN and that is working. So I am able to hit the modem/router but just the port forwarding is not working at this point.

Thanks

Re: Issue with providing access to a DB running in a Guest VM

Posted: 3. Apr 2020, 16:22
by GVVM
Just to add more clarity, though I have a mesh network, it's not applicable to the issue. (at least I think so).

The PC is hardwired to the router and so the troubleshooting can happen just between port forwarding and external router access.

Access to the router admin page works so at least this tells me the access to my router is ok.
But port forwarding is not. This makes me think that the issue is with the port forwarding rules all internal to my router and my configuration.
However, I have done this many times before with other ISP providers and other router brands and I have had no issues. So I think I know what I am doing. Still I am hitting a wall.

When I do a traceroute to my router IP, after about 10 hops, it starts timing out.. not sure why?

Re: Issue with providing access to a DB running in a Guest VM

Posted: 5. Apr 2020, 02:48
by GVVM
Good News (Partially)...

First of all thanks @scottgus @fth et al.

I was able to successfully remote ssh into a PC in my LAN.

It turned out 3 things that helped with this fix.

1. When I set the firewall settings to MEDIUM, it defaults to opening ssh, http, https and whole other ports. However this really did not let me connection come in, When I set the firewall settings to LOW. It made a difference.

2. In this forum I read that for SSH port forwarding to work, I should never have the external port same as ssh intenal port (22). This turned out to be false in my case. I had to keep external and internal port the same. Only then it works otherwise it doesn't

3. Finally, my host firewall was blocking all. I was not aware it was. I thought I had set it to allow ssh. This was a big miss on my part. But I went back to check every little thing and caught this.

Now I can ssh into my host machine.

But one last challenge remains, I am unable to ssh to my guest VMs from outside. I tried editing the port forwarding on the NAT adapter in myVM. did not help.

Now this seems entirely in VM settings related issue.

Please. Any help appreciated. Thanks you all.

-Ganesh

Re: Issue with providing access to a DB running in a Guest VM

Posted: 5. Apr 2020, 18:44
by GVVM
ISSUE RESOLVED...


The last item in the whole process, being able to connect to the guest vm was resolved today.

It turned out, the NAT port forwarding in the guest VM was not working.

Thanks to https://www.howtogeek.com/122641/how-to ... -a-server/

my virtualbox version is 6.1.2

When I removed NAT adapter and enabled a bridged adapter, it started working.

Thanks all..


Hope my updates will help someone someday.

Re: Issue with providing access to a DB running in a Guest VM

Posted: 10. Apr 2020, 00:11
by scottgus1
Thanks for the info!