Nur Rony
Polyglot Programmer, DevOps and Forever Learner

Vagrant: Common Settings Tips

Customize vagrant according to your choice

Vagrant: Common Settings Tips

I heard about Vagrant in 2013. I am playing with Vagrant about a year. It is really an awesome tool. It totally changed the way of my development. From the beginning I faced some problem and solved it by googling. Today I would like to summarize the common problem and how I got rid of them.

Change Vagrant Box Name

config.vm.define 'nurrony-devbox' do |devbox|  

Change Provider Box Name:

config.vm.provider 'virtualbox' do |vb| = 'devbox'

Change Hostname of Vagrant box:

config.vm.hostname = 'YourBoxHostname'  


config.vm.define 'nurrony-devbox' do |devbox|  
  devbox.vm.hostname = 'devbox'

The above configuration also change the name of Vagrant box from default to nurrony-devbox

Private Networking: 'private_network', type: 'dhcp'  

Or with specific IP 'private_network', ip: ''  

Public Networking

Vagrant.configure('2') do |config|  
  #DHCP 'public_network'
  #STATIC 'public_network', ip: '';
  #Defining Default Network interface 'public_network', bridge: 'wlan0'

Disabling Auto config: 'private_network', ip: '', auto_config: false  

Resolve Vagrant Box Slow Internet Issue:

config.vm.provider 'virtualbox' do |vb|  
  vb.customize ['modifyvm', :id, '--natdnshostresolver1', 'on']
  vb.customize ['modifyvm', :id, '--natdnsproxy1', 'on']

Packaging a box:

vagrant package --base SPECIFIC_NAME_FOR_VM --output /yourfolder/  

Sending Command to Vagrant

vagrant ssh -c 'sudo service httpd restart'

I will update this list eventually... ?