On Laravel Homestead, how to get the hosting machines' local IP address?

Viewed 1504

I am running Laravel Homestead on Macbook air.

  1. On Macbook Air, run ifconfig, it shows me the local ip address as "inet 192.168.1.20"
  2. 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!

1 Answers
Related