I am running Laravel Homestead on Macbook air.
On Macbook Air, run ifconfig, it shows me the local ip address as "inet 192.168.1.20"
I am running a Homestead on Macbook Air, from Homestead, I would call some of the services running on Macbook Air but calling the ip address, 192.168.1.20. The problem is that I hard coded this Macbook Air addresses as 192.168.1.20 in my codes. If I log in to another local area network, my macbook air local ip addresses would be changed. Then I would have to change my codes.
One thing I did is to use .env to set up the hosting machine ip, so I would only need to change ip at one place each time.
Any way that homestead would know its hosting machine's ip address?
Thanks!
The address of the hosting machine would normally be 10.0.2.2 which you can find when you type route -n | grep 'UG[ \t]' | awk '{print $2}'.
Related
I would like to find IP address of host on which VM is running. How can I find that?
For example,
There are 2 machine. Machine A & Machine B.
Machine A is running on Windows OS,
Machine B is running on Ubuntu in virtuallization environment inside Machine A.
How can I get IP address of Machine A from Machine B?
Sometimes in Vmware environment detects the ip addresses which you can find under summary tab. Otherwise you will need to login to the virtual machine and find the ip.
I have a VMWare Player (14.1.2 build-8497320) running a Ubuntu 18.04 guest on a Windows 10 host. The Ubuntu guest has a LAMP stack that runs a few web applications. I am using NAT to connect the Ubuntu guest to the Windows host's network.
I can access these applications by using the local IP address of the guest (e.g., http://192.168.80.128/mediawiki) from my Windows host. But I want to access it like so from my Windows host: http://localhost/mediawiki. I think this should be possible if I can forward the port 80 of my Ubuntu guest to that of the Windows host.
How do I make this happen please? I don't have access to VMWare Workstation and its Virtual Network Editor.
Edit: I should probably add the motivation for wanting to do this. Basically, I want to avoid figuring out the IP address of the virtual machine everytime I access the web applications.
The (further) reason is that the local IP address of the Ubuntu guest might (I suspect) change, and that will affect quite a few things, such as the base URLs configured in the webapps' configuration files (e.g., the $wgServer variable in LocalSettings.php of MediaWiki).
VMWare Player supports port forwarding over NAT natively:
In the file C:\ProgramData\VMware\vmnetnat.conf put under section [incomingtcp] a line like:
80 = 192.168.80.128:80
Then restart the VMWare NAT Service :
net stop "VMWare NAT Service"
net start "VMWare NAT Service"
Source/credits: https://hitchhikingtheweb.wordpress.com/2014/09/02/portforwarding-with-vmware-player-and-nat/
Also: VMWare documentation of this
You can do it using SSH Tunneling for example.
From windows you open a tunnel from the windows port 80 to the ubuntu port 80.
You can do it using Putty on Windows and having the ssh deamon running on ubuntu, which I guess you should already have.
There are many tutorials on how to do this.
I'll add just one link, but you can always google it and find one that suites you.
Portforwarding with SSH (Putty)
For the possible changes in the guest’s ip:
If you can’t fix the ip in settings then perhaps you can edit the windows hosts file and add a host name for the current Ubuntu ip. Then build the urls using the host name. If the ip changes you change it in the hosts file.
I'll try to explain without confusing you.
I built multiple Hyper-V VM's (using External VS, not Internal VS) on Windows 10 and when I'm connected to my home network, all is well. I can get out to the internet. Everything works as expected.
When I connect to my corporate network via Eth, strange things happen.
Linux VM does not get an IP
Win10 Network Adapters show VS with a public IP - 146... (strange)
Laptop stops routing via corp network and instead is routing using the VS IP (also strange)
As I said, none of these problems occur at home so if there's a specific IT policy blocking me at work, I would appreciate knowing which one so I can tell my Help Desk what to fix. Or is it something else?
Thanks.
You may have to do a ipconfig /release and ipconfig /renew (Windows) or a sudo dhclient -v -r and sudo dhclient -v (Linux) on the remote machine to get it to renew its DHCP settings and retrieve an IP address.
How do I run my meteor code on two different devices in the same network (using IP address).
I have a chatApp which I would like to test on two diff devices.
In your host computer where you are running the meteor app check the IP address. In Windows use ipconfig, or in Linux-based OS use ifconfig
Meteor app usually runs in port 3000 unless you changed it.
In your "other" devices, enter the IP address including the port number of the host machine. Assuming your host's IP address is 192.168.0.101 and the port the app is running on is 3000, then it is http://192.168.0.101:3000
I have a virtual machine with Windows 8 running. This VM is configured as a shared network with my Macbook Pro. From my Macbook Pro, where i'm running the VM I can access the ip address over the network.
But when I try to access it on a different computer in the network I can't access it. When I change my network configuration to bridged I can access it, but when i'm on another location, the ip address of the VM is changed. And thats not what I want.
Solution to this problem was that i needed to add ".local" after the hostname. For example my VM has a hostname "CoolMachine", the url in the browser wil be "CoolMachine.local" :)