-
Notifications
You must be signed in to change notification settings - Fork 4.4k
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
Modify configure_networks to support udev's predicatable network interface names on Ubuntu/Debian #7253
Modify configure_networks to support udev's predicatable network interface names on Ubuntu/Debian #7253
Conversation
Confirmed ubuntu/xenial64 (virtualbox, 20160420.3.0) on Vagrant 1.8.1 with this patch works well with VirtualBox 5.0.20 |
I also created a patch for vagrant 1.8.1 |
available_interfaces = data.chomp.split("\n") if type == :stdout | ||
end | ||
available_interfaces.delete(main_interface) | ||
@logger.debug("debian configure_networks. available_interfaces=#{available_interfaces.inspect}") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do you still need the debug logging? Should "require log4r" and logger references be removed?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@chrisvire I removed the debug logging. Thanks!
@@ -6,6 +6,23 @@ def self.change_host_name(machine, name) | |||
super | |||
end | |||
|
|||
def initialize(machine, new_hostname) | |||
super | |||
@logger = Log4r::Logger.new("vagrant::plugins::guest") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Still some logging
main_interface = data.chomp if type == :stdout | ||
end | ||
available_interfaces = [] | ||
comm.execute("ls /sys/class/net | grep -v -E '^(lo$|docker|lxc)'") do |type, data| |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think ^(lo$|docker|lxc)
should be ^(lo$|docker|lxc|lxd)
. The lxd project recently started calling their bridge interfaces lxdbrX instead of lxcbrX.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for a good catch!
I add a commit to ignore ^lxd and another commit to ignore ^veth
7802c21
I also updated my patch for vagrant 1.8.1 to ignore network interfaces whose name matches the regex ^lxd, ^veth as well as ^lo$, ^docker and ^lxc |
Using this patch makes my ubuntu12-04 vm hang on "Configuring and enabling network interfaces..." |
main_interface = data.chomp if type == :stdout | ||
end | ||
available_interfaces = [] | ||
comm.execute("ls /sys/class/net | grep -v -E '^(lo$|docker|lx[cd]|veth)'") do |type, data| |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
somewhat related, CoreOS also uses systemd naming, maybe we want to unify it? https://github.com/mitchellh/vagrant/pull/6610/files
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think commas in the regex (e[n,t][h,s,p][[:digit:]]([a-z][[:digit:]])?
in https://github.com/mitchellh/vagrant/pull/6610/files should be deleted to say the least.
- PredictableNetworkInterfaceNames
- systemd/udev-builtin-net_id.c at 25b0e6cb99c2a13c8f1ae9c5057f6941b722e764 · systemd/systemd
After reading the pages above, I think ^(en|eth)
or ^e(n|th)
would do for the whitelist approach.
However PredictableNetworkInterfaceNames says:
You create your own manual naming scheme, for example by naming your interfaces "internet0", "dmz0" or "lan0"
So I think the blacklist approach may be better.
On the other hand, you can change the network interface name for lxd from the default lxdbr0
to some other value. So the ideal way is detecting the type of network interfaces, not checking the names. But I had not found the way to do that, so I took the blacklist approach this time.
@sni Could you share your Vagrantfile? Did you use the patch for Vagrant 1.8.1 or for master? |
My Vagrantfile contains nothing special, except i create a bridged interface like:
|
Any word on this? There's been at least a few bug reports about this behavior and the PR has been outstanding for now literally months. I find it a little hard to believe this has sat for so long - private IP addresses on Xenial guests (my broken use case) can't be that rare, can they? If there's anything I can do to test or build this (though I'm more a JS/Python guy than Ruby), please let me know. #7155 is an increasingly problematic bug for me and my team as we look to upgrade our infrastructure from Trusty to Xenial with local testing. |
Thank you so much for this patch, it took forever to find but finally ended my public network suffering! |
is this going to be merged? |
This is a showstopper for a lot of people I think, the bug addressed by this fix is stopping me from adopting Xenial at all. |
I would like to see this merged as well |
Me too |
This pull request is another try to fix to #7241 and #6871.
This is based on Add networking cap for Ubuntu guest by gMagicScott · Pull Request #6724 · mitchellh/vagrant and modified so that:
ip route | awk '$1=="default"{print $NF;exit}'
to get the main_interface.ls /sys/class/net | grep -v -E '^(lo$|docker|lxc)'
to get available_interfaces then remove the main_interface from them.if [
/bin/cat /sys/class/net/#{interface}/operstate= up ]; then /sbin/ifdown #{interface} 2> /dev/null; fi
to bring down a network interface.hostnamectl --static status
to get the current hostname on distributions with systemd.Tested with following Vagrantfiles.
Ubuntu Xenial with predicatable network interface names
Ubuntu Trusty with old network interface names
Debian Wheezy with old network interface names
Debian Jessie with old network interface names
Tested with
Note you need to use VirtualBox 5.0.16, not the latest 5.0.18.
Bug #1573058 “Ubuntu 16.04 current not booting in Vagrant (gurum...” : Bugs : cloud-images