force vm to use eth1 as the public_network

1,659 views
Skip to first unread message

ask stack

unread,
Dec 10, 2013, 10:48:05 AM12/10/13
to vagra...@googlegroups.com
Most the time "vagrant up" will use eth0 as its dhcp interface and eth1 as the public interface. But often it will switches the two interfaces.
How do I ensure vm's eth1 as the public_network.
Thanks!


#host environment.
centos6, kvm/libvirt, bridged interface br0,

#Vagrantfile network section
config.vm.network :public_network, :bridge => 'br0', :device => "eth1", :mac => "52:54:00:25:01:1B"

#VM setup
I emptied /etc/udev/rules.d/70-persistent-net.rules

[root@cn20 network-scripts]# cat ifcfg-eth0
DEVICE="eth0"
BOOTPROTO="dhcp"
NM_CONTROLLED="no"
ONBOOT="yes"the
TYPE="Ethernet"
[root@cn20 network-scripts]# cat ifcfg-eth1
DEVICE="eth1"
BOOTPROTO="static"
BROADCAST="172.20.255.255"
DNS1="172.20.2.1"
GATEWAY="172.20.0.250"
IPADDR="172.20.2.21"
NETMASK="255.255.0.0"
NM_CONTROLLED="no"
ONBOOT="yes"
TYPE="Ethernet"
[root@cn20 network-scripts]#

Trevor Roberts

unread,
Dec 11, 2013, 10:12:32 AM12/11/13
to vagra...@googlegroups.com
Your first Vagrant network definition should always be eth1. If you are seeing that Vagrant is using eth1 as it's dhcp interface for its own VM configuration work instead of eth0, that is a bug that should be reported on the project's GitHub page.

Does this behavior happen with all your Vagrantfiles? Or just specific ones?

ask stack

unread,
Dec 11, 2013, 11:03:29 AM12/11/13
to vagra...@googlegroups.com

Trevor
Please take a look of vagrantfile. If you don't see anything wrong with it, I will report it as a bug. 
I do not have any other VMs/vagrantfile to test.
Thanks.


centos 6.4, vagrant-1.3.5-1.x86_64, libvirt 0.10.2, QEMU 0.10.2
###
VAGRANTFILE_API_VERSION = "2"
Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
  config.vm.box = "testvm5"
  config.vm.box_url = "/var/lib/libvirt/images/testvm1.box"
 
    config.vm.define :vm1 do |vm1|
vm1.vm.network :public_network, :bridge => 'br0', :device => "eth1", :mac => "52:54:00:25:01:1B"
    end
    config.vm.define :vm2 do |vm2|
vm2.vm.network :public_network, :bridge => 'br0', :device => "eth1", :mac => "52:54:00:25:02:1B"
    end
  config.vm.provider :libvirt do |libvirt|
    libvirt.driver = "qemu"
    libvirt.host = "localhost"
    libvirt.connect_via_ssh = true
    libvirt.username = "root"
    libvirt.storage_pool_name = "default"
    libvirt.memory = 2048
    libvirt.cpus = 2
  end
config.vm.synced_folder ".", "/vagrant", disabled: true
end
###

ask stack

unread,
Dec 12, 2013, 10:05:22 AM12/12/13
to vagra...@googlegroups.com
I build a barebone VM and did not have ssh-utils installed. after I installed that rpm, vagrant was able to reconfigure network interfaces.
thanks all.

Reply all
Reply to author
Forward
0 new messages