Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Handle new 'predictable' network interface naming style #7241

Closed
wants to merge 2 commits into from
Closed

Handle new 'predictable' network interface naming style #7241

wants to merge 2 commits into from

Conversation

dougneal
Copy link

Explicitly discover the names of the ethernet interfaces, and don't assume that they are eth0, eth1 etc as this does not hold true under newer systemd-based distributions.

Addresses: #7155 #6871

Explicitly discover the names of the ethernet interfaces, and
don't assume that they are eth0, eth1 etc as this does not hold
true under newer systemd-based distributions.
@cnk
Copy link

cnk commented Apr 19, 2016

I would love to be able to try this out; it looks like it fixes a number of the issues I am having building an Ubuntu 16.04 LTS dev VM.

Where do the scripts live to build a binary release locally? I tried building the vagrant gem from source and installing it along with its dependencies. But when I run it, I just get the 'vagrant doesn't run as a gem anymore' warnings.

@dougneal
Copy link
Author

Hey @cnk - not sure on the process for doing a local build but you should be able to run it from the checked out source tree: https://github.com/mitchellh/vagrant/wiki/Installing-Vagrant-from-Source

@cnk
Copy link

cnk commented Apr 19, 2016

Yeh I figured that out. I still need to figure out how to run with a salt provisioner.

@dougneal I am still getting the error from sudo hostname -f not resolving. So I will have to do some more poking around.

@dougneal
Copy link
Author

I ran into that too, it's because the image doesn't have libnss-myhostname. Try the boxcutter/ubuntu1604 image for now, it seems to work better!

if type == :stdout then
data.split("\n").each do |line|
if (line =~ /^\/sys\/class\/net\/(enp[0-9]+s[0-9]+|eth[0-9]+)$/) then
kernel_ifnames << $1

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure this is technically correct. My systemd based machine (though not Ubuntu) has an ethernet adapter named enp0s31f6. This wouldn't be caught by this RE.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This would only be for debian-based guests... is your machine running a Debian derivative, or something else (e.g. RHEL)?

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Debian GNU/Linux stretch/sid

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The name format appears to be described in systemd's udev-builtin-net_id.c

@ahrenstein
Copy link

+1 for this fix

@geerlingguy
Copy link
Contributor

Here's a workaround for those interested in getting a Xenial base box working prior to this PR getting pulled in: geerlingguy/packer-boxes#1 (comment)

@krzysbaranski
Copy link

for now I use the following script in ubuntu/xenial64, after that I can reload box with provisioning

  # fix hosts ubuntu/xenial
  echo 127.0.0.1 `hostname` |sudo tee -a /etc/hosts

  # fix network ubuntu/xenial
  # disable Predictable Network Interface Names
  ip a show dev eth1 > /dev/null
  if (($? > 0)); then
    echo "#### eth1 not exists (eth1 and eth2 is expected by vagrant)"
    echo "#### turning off Predictable Network Interface Names"
    grep -q "net.ifnames=0" /etc/default/grub
    if (($? > 0)); then
      echo "GRUB_CMDLINE_LINUX=\"net.ifnames=0"\" | sudo tee -a /etc/default/grub
      sudo update-grub
      echo "#### restart box to disable Predictable Network Interface Names"
    fi
  fi

@hnakamur
Copy link

hnakamur commented May 6, 2016

I created a simpler pull request #7253 to fix this issue and also a patch to vagrant 1.8.1 #7253 (comment)

@domnulnopcea
Copy link

when is this going to be merged?

@sebi-hgdata
Copy link

Just tested it out with

Vagrant.configure(2) do |config|
  config.vm.box = "ubuntu/xenial64"

  config.vm.provider "virtualbox" do |v|
    v.memory = 1024
    v.cpus = 1
  end

  config.vm.define "b1" do |b1|
    b1.vm.network "private_network", ip: "192.168.33.2"
  end

end

and it works.

@ghost ghost locked and limited conversation to collaborators Apr 4, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

9 participants