IP estático no Ubuntu provisionado via Vagrant (VirtualBox)

1

Estou tentando configurar minha VM Ubuntu (VirtualBox) definida pelo Vagrant para ficar visível sob IP estático.

Arquivo Vagrant:

# -*- mode: ruby -*-
# vi: set ft=ruby :

Vagrant.configure(2) do |config|
  config.vm.box = "ubuntu/trusty64"
  if (/cygwin|mswin|mingw|bccwin|wince|emx/ =~ RUBY_PLATFORM) != nil
    config.vm.synced_folder ".", "/vagrant", mount_options: ["dmode=777,fmode=666"]
  end   
  config.vm.provider "virtualbox" do |v|
    v.memory = 4096
  end

  config.vm.define :dev do |dev|
    dev.vm.hostname = "local-dev"   
    dev.vm.network "private_network", ip: "10.0.0.20"
    dev.vm.provision :shell, path: "bootstrap.sh"
    dev.vm.provision :shell,
      inline: 'PYTHONUNBUFFERED=1 ansible-playbook \
        /vagrant/ansible/dev.yml -c local'
  end
  if Vagrant.has_plugin?("vagrant-cachier")
    config.cache.scope = :box
  end

  if Vagrant.has_plugin?("vagrant-vbguest")
    config.vbguest.auto_update = false
    config.vbguest.no_install = true
    config.vbguest.no_remote = true
  end
end

Mas na caixa real ifconfig retorna:

root@local-dev:/etc/network# ifconfig                                                           
docker0   Link encap:Ethernet  HWaddr 02:42:6c:68:ef:5f                                         
          inet addr:172.17.0.1  Bcast:0.0.0.0  Mask:255.255.0.0                                 
          UP BROADCAST MULTICAST  MTU:1500  Metric:1                                            
          RX packets:0 errors:0 dropped:0 overruns:0 frame:0                                    
          TX packets:0 errors:0 dropped:0 overruns:0 carrier:0                                  
          collisions:0 txqueuelen:0                                                             
          RX bytes:0 (0.0 B)  TX bytes:0 (0.0 B)                                                

eth0      Link encap:Ethernet  HWaddr 08:00:27:16:16:86                                         
          inet addr:10.0.2.15  Bcast:10.0.2.255  Mask:255.255.255.0                             
          inet6 addr: fe80::a00:27ff:fe16:1686/64 Scope:Link                                    
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1                                    
          RX packets:3578 errors:0 dropped:0 overruns:0 frame:0                                 
          TX packets:2584 errors:0 dropped:0 overruns:0 carrier:0                               
          collisions:0 txqueuelen:1000                                                          
          RX bytes:314181 (314.1 KB)  TX bytes:423174 (423.1 KB)                                

lo        Link encap:Local Loopback                                                             
          inet addr:127.0.0.1  Mask:255.0.0.0                                                   
          inet6 addr: ::1/128 Scope:Host                                                        
          UP LOOPBACK RUNNING  MTU:65536  Metric:1                                              
          RX packets:17 errors:0 dropped:0 overruns:0 frame:0                                   
          TX packets:17 errors:0 dropped:0 overruns:0 carrier:0                                 
          collisions:0 txqueuelen:0                                                             
          RX bytes:1904 (1.9 KB)  TX bytes:1904 (1.9 KB)                                        

/etc/network/interfaces :

root@local-dev:/etc/network# cat interfaces                                                     
# This file describes the network interfaces available on your system                           
# and how to activate them. For more information, see interfaces(5).                            

# The loopback network interface                                                                
auto lo                                                                                         
iface lo inet loopback                                                                          

# Source interfaces                                                                             
# Please check /etc/network/interfaces.d before changing this file                              
# as interfaces may have been defined in /etc/network/interfaces.d                              
# NOTE: the primary ethernet device is defined in                                               
# /etc/network/interfaces.d/eth0                                                                
# See LP: #1262951                                                                              
source /etc/network/interfaces.d/*.cfg                                                          

#VAGRANT-BEGIN                                                                                  
# The contents below are automatically generated by Vagrant. Do not modify.                     
auto eth0                                                                                       
iface eth0 inet static                                                                          
      address 10.0.0.20                                                                         
      netmask 255.255.255.0                                                                     
#VAGRANT-END                                                                                    

/etc/network/interfaces.d/eth0.cfg (as linhas comentadas são minhas tentativas de fazer o trabalho resultar na impossibilidade de renderizar a caixa)

root@local-dev:/etc/network# cat interfaces.d/eth0.cfg                                          
# The primary network interface                                                                 
auto eth0                                                                                       
iface eth0 inet dhcp                                                                            
#iface eth0 inet static                                                                         
#      address 10.0.0.20                                                                        
#      netmask 255.255.255.0                                                                    
#      gateway 10.0.0.1                                                                         
root@local-dev:/etc/network#     

Como posso fazer isso funcionar? E o que está aparecendo sob IP 10.0.0.20 como está respondendo a pings?

    
por wciesiel 05.12.2016 / 18:35

0 respostas