Switch IP's in browser - macos

For my development environment I'm looking for a way to change/override IP addresses used in DNS lookup for a domain, so I can point the domain to my local vagrant box with ease and without changing the hostfile everytime I want to switch back and forth from the live env to the dev env. I couldn't find a way to do this so I'm hoping there is a solution for this. I'm using Mac OS X.

Perhaps the Vagrant Hostsupdater plugin can be of help. It automatically adds entries to your local hosts file, when you include the following config in your Vagrantfile:
config.vm.network :private_network, ip: "192.168.3.10"
config.vm.hostname = "www.testing.de"
config.hostsupdater.aliases = ["alias.testing.de", "alias2.somedomain.com"]
Source

Related

Expose windows vagrant by ngrok

Hi I'm using windows vagrant and homestead developing laravel application.
i have this in my hosts file
192.168.10.10 laravel.dev
I wanted to expose this url so that I can test one requirements like responsiveness and the like. How to do this?
Use the share command: https://laravel.com/docs/5.5/homestead#sharing-your-environment
Also, you should change your .dev TLD to .test otherwise browsers will start complaining about your site.
First of all you are you using a private network in your Vagrantfile ? something like :
config.vm.network "private_network", ip: "192.168.10.10"

Default shared folder in vagrant not visible

I have a problem with synced folder in Vagrant. My config is really simple:
Vagrant.configure(2) do |config|
config.vm.box = "ubuntu/xenial64"
config.vm.network :forwarded_port, guest: 80, host: 8080
config.vm.synced_folder ".", "/vagrant"
end
Vagrant usually creates /vagrant folder automatically on start - this time it did not happen so I've done it manually.
But when I create a file in my host system - it's not visible in guest. Any ideas why?
I've succesfully created a similar configuration with:
config.vm.box = "hashicorp/precise64"
but it's a little bit outdated and I want to use Ubuntu 16.04.
Is it a problem with my config, vagrant box, or something else?
You could try: Make sure you have the latest version of Vagrant and VB. Restart your computer (I know, but it sometimes does help in these cases). Try again in a new directory (or vagrant destroy if you want to start fresh and don't need any old content), i.e., make sure the old .vagrant directory isn't there.
vagrant up or vagrant reload and check again.
Assuming you are using VirtualBox, make sure you don't have any "Guest Additions" issues. You could try https://github.com/dotless-de/vagrant-vbguest
If it still doesn't work, check the --debug output again as #frédéric-henri mentioned -- look for all mentions of your share name. Also "/vagrant" isn't always the default, it depends on the box. Sometimes it's "/vagrant_data" or others, but if you specify "/vagrant" in the config -- that should work.

Boot2Docker private network setup

How can I do the private networking for the boot2docker docker container ?
For example, If I have a webapp, I can do the following in Vagrantfile
myapp1.vm.network "private_network", ip: "1.2.3.4"
myapp2.vm.network "private_network", ip: "1.2.3.5"
myapp3.vm.network "private_network", ip: "1.2.3.6"
Then I can use my browser to access my webapp at
http://1.2.3.4
http://1.2.3.5
http://1.2.3.6
How can I achieve the same result in docker easily ?
I also looked at How to expose docker container's ip and port to outside docker host without port mapping?
But in my boot2docker1.3, it said the interface eth0:1 does not exist
I looked at https://docs.docker.com/articles/networking
The tutorial does not work for boot2docker in mac.
Any help would be appreciated, thankyou!
I believe the instructions here, linked from this question give what you are looking for. The key is this line:
sudo route -n add 172.17.0.0/16 172.16.0.11
which tells your Mac how to route to the private network inside the VirtualBox VM that the Docker containers are on. (Obviously the specific addresses can change for your specific situation)
This still doesn't give you the ability to assign specific IP addresses to specific containers; as I said an add-on like weave can do that. (note: I work on weave)
You may also like this article which gives a beginner's overview of how Boot2Docker runs and illustrates how you have IP addresses inside the VirtualBox VM, and also an IP address of that box as a whole.

vagrant homestead - public network not working on osx

I've been trying all day to get a public network setup using Vagrant 1.6.5 with VirtualBox. I really need to be able to access all my Homestead sites on my other devices (iPad, iPhone, Android phone, etc.) on my local network. The box provisions fine but the sites all timeout.
homestead.rb
config.vm.network "public_network", :bridge => "en0: Wi-Fi (AirPort)", :ip => "192.168.1.200"
My host is OS X mavericks using DHCP (192.168.1.137).
Private networking works fine, but I can't get public networking to work with any variation of the above config.
You can just grab the host's internal IP address (NOT the VM ip) and add the port :8000. Let's say your host ip is 192.168.0.5, then from any other device on your network, you can just browse to the host at 192.168.0.5:8000 and you'll hit the VM and see the Laravel home page.
This works great for me with the default homestead.rb setting:
# Configure A Private Network IP
config.vm.network :private_network, ip: settings["ip"] ||= "192.168.10.10"
To get my homestead machine to be visible from my LAN I did the following:
Edit the Homestead/scripts/homestead.rb file and set config.vm.network :public_network, ip: "192.168.1.123" (just make sure the IP is free).
Do a vagrant reload
Make sure my old local hosts file now points to the new IP.
The result is I can ping 192.168.1.123 from another machine in my LAN.
What is the error that you are getting? Make sure that 192.168.1.200 is not being used by any other device.
Network configuration for vagrant boxes
This row works fine for me:
config.vm.network :public_network, ip: settings["ip"] ||= "192.168.10.10", bridge: "eth0"
Then it uses the ip variable from ~/.homstead/Homestead.yaml and if thats not set it uses 192.168.10.10

Setting a VM's mac address in Vagrant

The documentation lists that the mac address of a VM can be set in the Vagrantfile, however everything I add seems to end up being a syntax error. Anyone successfully done this?
I used this:
config.vm.network :bridged , :mac => "080027XXXXXX"
and got what I wanted.
The docs are unclear on what the syntax for the options hash were, and there seemed to be no example on what this should look like. So, here it is! Bridged with a mac address (edited of course). This brings up eth1 with the mac specified, which makes my DHCP server happy, and gives it a proper fqdn on my network.
This is an old question, but I had the same issue just now. Vagrant documentation v2 still seems incomplete. In the end I used this line in the Vagrantfile with vagrant 1.2.7:
config.vm.network "public_network", :bridge => 'enp4s0', :mac => "5CA1AB1E0001"
This:
sets the host interface named 'enp4s0' as the bridge interface,
which as 'eth0' on the guest is then assigned an ip address by the same DHCP the host uses
Also sets 5C:A1:AB:1E:00:01 as the guest's mac address
hmm, the network config didn't help in my case. After defining the MAC Address directly in the Vagrantfile via config.vm.base_mac = "MyEth0MacAddressWithoutSlashes" my machine started =)
On Vagrant version 2.0.1, I write in the Vagrantfile for a private_network (provider = VirtualBox ; version 5.2.0) :
config.vm.network "private_network", ip: "X.X.X.X", mac: "080027xxxxxx"
The information provided below is outdated. As per documentation to allow IP to be assigned via DHCP simply use:
config.vm.network "public_network"
This way you don't need to deal with mac address, it will be generated on its own.
If you need custom mac address attached to the network device then:
config.vm.network "public_network", :mac=> "080027xxxxxx"

Resources