How to connect with host PostgreSQL from vagrant virtualbox machine - postgresql

I have a VirtualBox machine running Ubuntu 12.04 in a Mac OS X host machine. In my host machine (Mac OS X), I have PostgreSQL installed. I would like to connect to this PostgreSQL server from my Ubuntu virtual machine (I know normally it's the opposite way).
I guess I should configure some networking parameters in VirtualBox itself. All I get from Vagrant docs is I need to assign my vm a static IP to use a private network. But once created, how do I reach my host from my guest?
I didn't find anything like that in vagrant docs. So, there's probably a good reason for that. Does it make sense? I don't want to duplicate PostgreSQL installation. Just use my current existent one.

You can reach your host from your guest by using the default gateway on your VM.
See this answer for an explanation.
By running netstat -rn you can get the default gateway and then use that ip address in your config file of your application.
Running netstat -rn | grep "^0.0.0.0 " | cut -d " " -f10 should give you the correct ip address. (only tested this on my machine)

Easy way - simply use this "magic" IP from inside of vagrant without any additional configurations:
10.0.2.2
Don't know if it's always static, though for me works and it's very convenient - I can use laptop at home, from office - having assigned different IPs to me by routers, but my VMs know the "trusty name" of their master 🐶

Related

no internet on cloned virtual machine (Vmware workstation)

so i setup a centOS vm in VMware workstation, installed qradar..everything ran fine. I call this vm as QR1.
I was able to use qradar console on QR1 from my host machine, the internet works perfectly fine in QR1.
I make a full clone of QR1 called it QR2.
I boot it up and only running QR2 vm (QR1 is closed) but there is no internet on this vm. Even though all the network setting are same as QR1 and QR1 works just fine(i double checked).
QR2 has same adapter, same ip, same gateway and dns as of QR1 but it doesnt work...
previously i was thinking that i cannot have them both running at same time but QR2 just doesnt connect.
I am also not able to ping QR2 from my host and other way around.
What could be causing this ?
According to this vmware link reference, try these steps:
To change the MAC address of the Linux operating system:
Connect to vCenter Server using the vSphere Client Right-click the
virtual machine and click Edit Settings. Click Network adapter and
note the MAC Address.
For example, you see a MAC Address similar to:
xx:xx:xx:xx:xx:xx
1.Power on the Linux virtual machine.
2.Open a console and log in as root.
3.Change directory to etc/sysconfig/network-scripts.
4.Edit ifcfg-eth0 using a plain text editor and update the MAC address to reflect the MAC address in Step 3.

Oracle VirtualBox VM network not working

I am attempting to set up a VM using VirtualBox. I am hosting on Windows 10 and want to set up a CentOS vm. I have a VM running but have had problems getting network connectivity with it. I have no experience with VirtualBox and it has been a long time since I worked on Linux. Any ideas on what I need to do to correct this? Are there some steps I need to take during the creation of the image?
Image is : CentOS-7-x86_64-Everything-1708.iso
VirtualBox : Version 5.1.28 r117968 (Qt5.6.2)
When I try to ping anything I get " connection the Network is unreachable
The very best thing you should do is running the following command:
ifconfig -a
Then, If you have an interface listed (not just 'lo'), you can do that:
# cd /etc/sysconfig/network-scripts/
# sed -i -e 's#^ONBOOT="no#ONBOOT="yes#' ifcfg-{{network_device}}
replace {{network_device}} for your default network_device (from ifconfig-a command).
Then restart and it should connect.

run a distribution test with jmeter in Vm Centos

I'm trying to run a distribution test for learning purpose and i'm using a Virtual machine Centos 7 as a slave in my Windows 7 ( master running in window 7) but even if i configure the master with the IP of the slave ( VM ), modifying the file jmeter.properties, doesn't work, i try run Jmeter-server in the Centos machine but this problem appears.
Created remote object: UnicastServerRef [liveRef: [endpoint:[127.0.0.1:44341](lo
cal),objID:[4e68a212:14a8564a618:-7fff, 5760053273490727502]]]
Server failed to start: java.rmi.RemoteException: Cannot start. localhost.locald
omain is a loopback address.
An error occurred: Cannot start. localhost.localdomain is a loopback address.
Can somebody give me a direction where look or a explanation how can i do it?
Thanks!
Put the following line in system.properties file: java.rmi.server.hostname=xxx.xxx.xxx.xxx
Alternatively start JMeter providing above property as a command-line argument as:
jmeter (or jmeter-server) -Djava.rmi.server.hostname=xxx.xxx.xxx.xxx
Double check your network configuration, i.e. make sure that your /etc/hosts file contains the following lines:
127.0.0.1 localhost localhost.localdomain
xxx.xxx.xxx.xxx your CentOS machine hostname
In all above cases xxx.xxx.xxx.xxx should be IP address of your CentOS machine and this IP address must be different from 127.0.0.1.
Also make sure that you select "Bridged" networking in your Virtual Machine, machines should be able to reach each other over the network, firewalls should be properly configured to allow communication, etc.
For more information on different JMeter Properties and ways of setting/overriding them see Apache JMeter Properties Customization Guide

How to use a webserver installed on a guest machine from the host

I am using VMWare player and I have a webserver installed in my Linux guest machine
(Linux Mint with Tomcat).
I want to access the webserver from my host machine
(Windows 7).
What are the steps required?
Thank you
On your Linux box (the guest), open a terminal, and type:
ifconfig
Look at the output, you should see a INET ADDR (or something like that) and it will have your ip address beside it. Something like 192.168.7.10 (this is an example).
Then go back to your host, amd in a web browser type in 'http://(the ip you just found)'
This should connect to your webserver
Alternatively, use the hostname command on the guest Linux machine to figure out its name (I think the default is ubuntu), then use it from your host -- e.g. http://(the name you just found) (in my case, http://ubuntu/)

Accessing documents on a http server running in a virtual machine

I run Windows 7 as my main OS, and for development work I installed CentOS on a virtual machine under VirtualBox. Everything is installed, including httpd and php with mysql, but I can't figure out what IP to use to gain access to the server.
For example, I used to have XAMPP installed on 7 and I just used "localhost" to get to the servers document root, but I have no clue what it is for the virtual machine.
I have tried "locahost", "192.168.11.2" (my address on the network) and my own IP address and I can't seem to get it working.
Any help would be appreciated. Thank you. :)
I don't know VirtualBox, but can you do an ifconfig from the terminal window to your VM. If it doesn't give you a terminal window, your CentOS setup probably does DHCP to get an address. Browse to the web interface of your home router (192.168.11.1?) and check the DHCP clients table to see if it registered and get its address.