get VM IP address on Windows - ruby-on-rails

I am running a Debian VMware virtual machine on Windows7. I am developing a Rails web app on the virtual machine, I would like to access the app (localhost:3000) from outside the vm, i.e from windows.
Is there a way to do that?
Thanks.

This really depends on how your virtual network adapters are setup between the guest and host. Assuming you have not changed anything, they will be bridged by default. In your VM from a terminal run:
ifconfig
This will give you the IPv4 address (generally a 10.x.x.x) of the virtual interface which you should be able to access from your Windows host. You should be able to put that into your browser on the host with the :3000 port and access it.
If you have modified the network adapters, things may be different. For instance, setting it up as a NAT will give it an address on your physical network; i.e. 192.x.x.x, but accessing it the same. A host only netowork, would also most likely provide a 10.x.x.x address, but should also provide access.

Related

Freezing my machines IP only for the containers and internal communications

We have a system of numerous microservices, which when setup in local, refers to certain services in my local using their IP(of course resolved via Consul).
It becomes a problem when I connect my laptop from different networks, when the IP of my machine changes. Is there a way in which I can freeze the IP of my machine only for the communications from the containers and the services within my machine?
PS:
Of course, loop-back address won't work, as the loop-back address from container will refer to the container itself and not the host machine.
I can't run with network=host, as there will be many services in different containers running in same port.
I'm using Mac, but looking for generic solution, which would also work in Ubuntu.
Your containers shouldn't ever need to know the ip address of your host. For Docker on MacOS, you can use the hostname host.docker.internal to refer to the host, and this will work regardless of how your host's primary address changes.
While in the past this wasn't possible on Linux, you can now set up the equivalent alias by mapping that hostname to the magic address host-gateway:
docker run --add-host host.docker.internal:host-gateway ...
That will give you consistent behavior for your configurations under both Mac and Linux.

Connecting to BACNET Server on Host Machine Using Client Container

I am trying to connect my BACNET client which has been containerized and the BACNET server which is running on the host machine. I am using Docker for Windows on Windows 10 (host machine) with Linux containers.
I have tried the following:
a. Publishing the ports 47808 for the client container with the run command.
b. Running the container with network=host, to access services of localhost.
c. Tried specifying the gateway IP as the server's IP address with run command.
d. Running the container in the same subnet as my server
e. Running the container with the host IP specified and the ports published.
My bacnet server, taken from https://sourceforge.net/projects/bacnet/ always connects to the DockerNAT, 10.0.75.1? Any idea why does this happens? The server application is not a container but an executable file.
Server IP:10.0.75.1 (dockerNAT)
Client container running on host machine.
From a quick google:
For Windows containers this component is not used and containers and
their ports are only accessible via the NATed IP address.
With respect to BACnet, this is going to put you in a world of hurt. You will have to use BACnet BBMD with NAT support in your container to achieve this, and your BACnet Client will have to register as a BACnet Foreign Device. The BACnet Stack at SourceForge does seem to have some NAT support (the code seems to be there but I have never tested it in its original form).
So what you are seeing is 'expected', but your solution is going to require that you become much more familiar with BACnet BBMDs than you ever want to be. Read the BACnet specification carefully. Good luck.

How to set a fixed IP for a VirtualBox machine to make it appears identical on different computers

I have an Ubuntu VM (with a Varnish Cache) running in VirtualBox on my local computer. When I'm at home the ip address of my computer is 192.168.178.34. I use the network bridge to connect the VM with my computer. The ip of the VM is then 192.168.178.38. That allows me to reach the cache-server e.g. like that: http://192.168.178.38:6081/index.html
The problem is, i want that this URI is static. My goal is to share the vm with somebody and make a documentation about how to use the cache-server. Therefore it would be great if the ip adress would be always the same, even if the vm will be started in a VirtualBox on a different computer.
Is there a way to set a fixed ip address for the vm, regardless of the host computer?
Thanks a lot!
martin.martin
You can set up a host-only network adapter, which uses the subnet 192.168.56.0/24 by default. Inside the VM, you can set a static IP address.

Accessing lamp container over lan using Kitematic

I have a basic Lamp container installed and running using Kitematic. I want to access the url over lan for testing purpose.
Enabling bridged networking on the dev VM should allow you to do this, though it requires take a few steps for now. Make sure you understand the security implications of allowing all other machines on the network to contact the VM.
Add a third network adapter in the VM settings pane. For Name, choose the adapter or network on which you want your VM to be accessible.
To get the the IP of the VM, type the following on CLI:
docker-machine ssh dev
ifconfig
And look for the IP with the same subnet as other machines on the network. E.g. 192.168.0.x
Open the web preview as usual in Kitematic.
Lastly, replace the IP in the browser bar with the one found in step 3.
This should be accessible to other machines on the network.

Use VirtualBox to access site on host from guest? the host and guest is linux

I'm running VirtualBox on a ubuntu (host), the VM i'm using is fedora (guest). VirtualBox is setup to use the NAT network adapter, and I'm able to get to the internet.
i use Port Forwarding to access ssh and the rails web server
port Forwarding Rules
<NAT>
<DNS pass-domain="true" use-proxy="false" use-host-resolver="false"/>
<Alias logging="false" proxy-only="false" use-same-ports="false"/>
<Forwarding name="Rule 1" proto="1" hostport="5679" guestport="22"/>
<Forwarding name="Rule 2" proto="1" hostport="3080" guestport="3000"/>
</NAT>
now i can access internet on guest machine , and i can logging through ssh
but i cannot access the Rails web server on port 3080
i tried :
localhost:3080
10.0.2.15:3080 #the guest IP
what i can do all i need is SSH and internet connection and open the web site i host on gust machine by Browser in host machine
thanks
Just a stab in the dark here but this might be your issue...
When you provision a new Linux Virtual Machine in VirtualBox, the Network settings for that VM are set to 'NAT'. This results in your new VM being assigned a 10.x.x.x address.
Change this setting to Bridged mode, which will assign your VM an address within the same subnet as your host (most likely 192.168.x.x).
Try to connect to the site running on your host.
If you're still not able to access the site running on localhost, confirm the app isn't blocking connections from your new VM. Add a rule in to your access list (possible iptables) permitting tcp port 80 traffic from your VM's address (found using ifconfig).
Happy hunting!
In your VB you have to set network only with host. It is in preferences->network.
Then you can access your virtual machine via 192.168.56.101 from ubuntu. Port forwarding set on this network card. List it with ifconfig. I recommend to use iptables for port redirects.

Resources