weixin_39542093
weixin_39542093
2020-12-01 12:25

use_dhcp_assigned_default_route does not work

vagrant-libvirt 0.0.20, vagrant 1.6.3 or 1.6.5, ubuntu 13.10 VM, ubuntu 13.10 Host


config.vm.define "image" do |image|
  config.vm.hostname = "image"
  config.vm.network "public_network", :bridge => 'eth0', use_dhcp_assigned_default_route: 'true', :mac => '0A0A000C0A0A'
end

This stanza is added to /etc/network/interfaces with vagrant-libvirt:


#VAGRANT-BEGIN
# The contents below are automatically generated by Vagrant. Do not modify.
auto eth1
iface eth1 inet dhcp
    post-up route del default dev $IFACE || true
#VAGRANT-END

However, this stanza is added when using the same box (after mutating) with Virtualbox:


#VAGRANT-BEGIN
# The contents below are automatically generated by Vagrant. Do not modify.
auto eth1
iface eth1 inet dhcp
    # We need to disable eth0, see GH-2648
    post-up route del default dev eth0
    post-up dhclient $IFACE
    pre-down route add default dev eth0
#VAGRANT-END

End result is - public_network is default in VB but not with libvirt,

该提问来源于开源项目:vagrant-libvirt/vagrant-libvirt

  • 点赞
  • 写回答
  • 关注问题
  • 收藏
  • 复制链接分享
  • 邀请回答

5条回答

  • weixin_39759060 weixin_39759060 5月前

    For those curious, thsis feature in in vagrant here

    点赞 评论 复制链接分享
  • weixin_39542093 weixin_39542093 5月前

    I'll add a bit from each debug log where it is editing network/interfaces..

    libvirt:

    
    DEBUG guest: Searching for cap: configure_networks
    DEBUG guest: Checking in: ubuntu
    DEBUG guest: Checking in: debian
    DEBUG guest: Found cap: configure_networks in debian
     INFO guest: Execute capability: configure_networks [#<:machine: image>, [{:interface=>1,
    :type=>:dhcp}]] (ubuntu)
    DEBUG ssh: Re-using SSH connection.
     INFO ssh: Execute: sed -e '/^#VAGRANT-BEGIN/,/^#VAGRANT-END/ d' /etc/network/interfaces > /tmp/vagrant-network-interfaces (sudo=true)
    DEBUG ssh: Re-using SSH connection.
     INFO ssh: Execute: echo; printf $SSH_AUTH_SOCK (sudo=false)
    DEBUG ssh: stderr: stdin: is not a tty
    
    DEBUG ssh: stdout:
    
    DEBUG ssh: stdout: /tmp/ssh-TxSJMhnbMt/agent.1624
    DEBUG ssh: Exit status: 0
     INFO ssh: Setting SSH_AUTH_SOCK remotely: /tmp/ssh-TxSJMhnbMt/agent.1624
    DEBUG ssh: Exit status: 0
    DEBUG ssh: Re-using SSH connection.
     INFO ssh: Execute: su -c 'cat /tmp/vagrant-network-interfaces > /etc/network/interfaces' (sudo=true)
    DEBUG ssh: Re-using SSH connection.
     INFO ssh: Execute: echo; printf $SSH_AUTH_SOCK (sudo=false)
    DEBUG ssh: stdout:
    </:machine:>

    VB:

    
    DEBUG guest: Searching for cap: configure_networks
    DEBUG guest: Checking in: ubuntu
    DEBUG guest: Checking in: debian
    DEBUG guest: Found cap: configure_networks in debian
     INFO guest: Execute capability: configure_networks [#<:machine: image>, [{:type=>:dhcp
    , :use_dhcp_assigned_default_route=>"true", :auto_config=>true, :interface=>1}]] (ubuntu)
    DEBUG ssh: Re-using SSH connection.
     INFO ssh: Execute: sed -e '/^#VAGRANT-BEGIN/,/^#VAGRANT-END/ d' /etc/network/interfaces > /tmp/vagrant-network-interfaces (sudo=true)
    DEBUG ssh: Re-using SSH connection.
     INFO ssh: Execute: echo; printf $SSH_AUTH_SOCK (sudo=false)
    DEBUG ssh: stdout:
    
    DEBUG ssh: stdout: /tmp/ssh-yjbW9KZ2MJ/agent.1316
    DEBUG ssh: Exit status: 0
    DEBUG ssh: stderr: stdin: is not a tty
    
     INFO ssh: Setting SSH_AUTH_SOCK remotely: /tmp/ssh-yjbW9KZ2MJ/agent.1316
    DEBUG ssh: Exit status: 0
    DEBUG ssh: Re-using SSH connection.
     INFO ssh: Execute: su -c 'cat /tmp/vagrant-network-interfaces > /etc/network/interfaces' (sudo=true)
    DEBUG ssh: Re-using SSH connection.
     INFO ssh: Execute: echo; printf $SSH_AUTH_SOCK (sudo=false)
    DEBUG ssh: stderr: stdin: is not a tty
    </:machine:>
    点赞 评论 复制链接分享
  • weixin_39542093 weixin_39542093 5月前

    Ok, just worked around it.

    Ruby is not something I work with, but if anyone wants to implement (looks like it is not supported at all), then looks like it should be done here

    :use_dhcp_assigned_default_route is not being passed at all so vagrant doesn't put in the necessary part to /etc/network/interfaces

    点赞 评论 复制链接分享
  • weixin_39692830 weixin_39692830 5月前

    +1

    how did you worked around it?

    点赞 评论 复制链接分享
  • weixin_39542093 weixin_39542093 5月前

    Went back to nat with what I could, stayed with Virtualbox with what I couldn't. I use packer to create the images so I don't have to keep track of multiple image format or images.

    点赞 评论 复制链接分享

相关推荐