Vagrant VM无法通过DHCP为第二个接口分配IP

时间:2018-07-17 03:36:56

标签: vagrant vagrantfile dhcp

我遇到了一个问题,即流浪汉启动了VM,它的第二个接口eth1无法从DHCP服务器获取公共IP

流浪文件

VAGRANTFILE_API_VERSION = "2"
Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
   config.ssh.forward_agent = true
   config.vm.define "test-vm" do |s|
     s.vm.box = "ceph/ubuntu-xenial"
     s.vm.hostname = "test-vm"
     s.vm.network :public_network,
       :dev => "br0",
       :mode => "bridge",
       :type => "bridge",
       :use_dhcp_assigned_default_route => true
   end
 end

当我无所事事时

sudo vagrant up

Bringing machine 'int-satellite-1' up with 'libvirt' provider...
==> test-vm: Checking if box 'ceph/ubuntu-xenial' is up to date...
==> test-vm: Creating image (snapshot of base box volume).
==> test-vm: Creating domain with the following settings...
==> test-vm:  -- Name:              satellite_int-satellite-1
==> test-vm:  -- Domain type:       kvm
==> test-vm:  -- Cpus:              1
==> test-vm:
==> test-vm:  -- Feature:           acpi
==> test-vm:  -- Feature:           apic
==> test-vm:  -- Feature:           pae
==> test-vm:  -- Memory:            512M
==> test-vm:  -- Management MAC:
==> test-vm:  -- Loader:
==> test-vm:  -- Base box:          ceph/ubuntu-xenial
==> test-vm:  -- Storage pool:      default
==> test-vm:  -- Image:             /var/lib/libvirt/images/test-vm.img 
(301G)
==> test-vm:  -- Volume Cache:      default
==> test-vm:  -- Kernel:
==> test-vm:  -- Initrd:
==> test-vm:  -- Graphics Type:     vnc
==> test-vm:  -- Graphics Port:     -1
==> test-vm:  -- Graphics IP:       127.0.0.1
==> test-vm:  -- Graphics Password: Not defined
==> test-vm:  -- Video Type:        cirrus
==> test-vm:  -- Video VRAM:        9216
==> test-vm:  -- Sound Type:
==> test-vm:  -- Keymap:            en-us
==> test-vm:  -- TPM Path:
==> test-vm:  -- INPUT:             type=mouse, bus=ps2
==> test-vm: Creating shared folders metadata...
==> test-vm: Starting domain.
==> test-vm: Waiting for domain to get an IP address...
==> test-vm: Waiting for SSH to become available...
test-vm:
test-vm: Vagrant insecure key detected. Vagrant will automatically replace
test-vm: this with a newly generated keypair for better security.

test-vm: Inserting generated public key within guest...
test-vm: Removing insecure key from the guest if it's present...
test-vm: Key inserted! Disconnecting and reconnecting using new SSH key...
==> test-vm: Setting hostname...
==> test-vm: Configuring and enabling network interfaces...

现在它停留在“配置和启用网络接口”上的时间确实非常长,而接口eth1长时间没有获得IP

最终,接口在大约10分钟后获得IP。为什么会这样?

之前:

eth0      Link encap:Ethernet  HWaddr 52:54:00:3c:c2:a1
      inet addr:192.168.121.192  Bcast:192.168.121.255  
       Mask:255.255.255.0
      inet6 addr: fe80::5054:ff:fe3c:c2a1/64 Scope:Link
      UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
      RX packets:1032 errors:711 dropped:0 overruns:0 frame:711
      TX packets:1323 errors:0 dropped:0 overruns:0 carrier:0
      collisions:0 txqueuelen:1000
      RX bytes:129989 (129.9 KB)  TX bytes:185988 (185.9 KB)

eth1      Link encap:Ethernet  HWaddr 52:54:00:9c:d9:83
      inet6 addr: fe80::5054:ff:fe9c:d983/64 Scope:Link
      UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
      RX packets:4018 errors:0 dropped:0 overruns:0 frame:0
      TX packets:469 errors:0 dropped:0 overruns:0 carrier:0
      collisions:0 txqueuelen:1000
      RX bytes:681281 (681.2 KB)  TX bytes:132806 (132.8 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:160 errors:0 dropped:0 overruns:0 frame:0
      TX packets:160 errors:0 dropped:0 overruns:0 carrier:0
      collisions:0 txqueuelen:1
      RX bytes:11840 (11.8 KB)  TX bytes:11840 (11.8 KB)

eth1没有公共IP

10分钟后-确实很长,eth1获得了IP,这时候我的脚本也失败了

eth0      Link encap:Ethernet  HWaddr 52:54:00:3c:c2:a1
      inet addr:192.168.121.192  Bcast:192.168.121.255  Mask:255.255.255.0
      inet6 addr: fe80::5054:ff:fe3c:c2a1/64 Scope:Link
      UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
      RX packets:1275 errors:878 dropped:0 overruns:0 frame:878
      TX packets:1653 errors:0 dropped:0 overruns:0 carrier:0
      collisions:0 txqueuelen:1000
      RX bytes:162386 (162.3 KB)  TX bytes:229800 (229.8 KB)

eth1      Link encap:Ethernet  HWaddr 52:54:00:9c:d9:83
      inet addr:10.xx.xx.xx  Bcast:10.73.148.255  Mask:255.255.255.0
      inet6 addr: fe80::5054:ff:fe9c:d983/64 Scope:Link
      UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
      RX packets:4927 errors:0 dropped:0 overruns:0 frame:0
      TX packets:529 errors:0 dropped:0 overruns:0 carrier:0
      collisions:0 txqueuelen:1000
      RX bytes:812766 (812.7 KB)  TX bytes:141200 (141.2 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:160 errors:0 dropped:0 overruns:0 frame:0
      TX packets:160 errors:0 dropped:0 overruns:0 carrier:0
      collisions:0 txqueuelen:1
      RX bytes:11840 (11.8 KB)  TX bytes:11840 (11.8 KB)

0 个答案:

没有答案