From 35d3be865f9651c8cfae37aa77cce9834743a4e2 Mon Sep 17 00:00:00 2001 From: Tomoyuki Sakurai Date: Wed, 13 Dec 2017 18:34:17 +0900 Subject: [PATCH] Atomically apply new hostname.if(5) This fixes an issue when the interface being configured is the interface through which ssh traffic is forwarded. In a complex scenario, one needs to disable the default interface for NAT, and use other interface for ssh. In this case, when vagrant run `ifconfig #{ifname} inet delete`, the second ifconfig that is supposed to restore interface settings will never be called. This might be a rare need, but it is also strongly recommended to use `netstart` when reconfiguring interfaces after updating `hostname.if(5)`. The issue can be triggered when ssh connection has issues between two `ifconfig` commands. --- plugins/guests/openbsd/cap/configure_networks.rb | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-) diff --git a/plugins/guests/openbsd/cap/configure_networks.rb b/plugins/guests/openbsd/cap/configure_networks.rb index 30c4be060..fefc05b9e 100644 --- a/plugins/guests/openbsd/cap/configure_networks.rb +++ b/plugins/guests/openbsd/cap/configure_networks.rb @@ -36,15 +36,8 @@ module VagrantPlugins machine.communicate.sudo("mv /tmp/vagrant-network-entry /etc/hostname.#{ifname}") - # remove old configurations - machine.communicate.sudo("sudo ifconfig #{ifname} inet delete", { error_check: false }) - machine.communicate.sudo("pkill -f 'dhclient: #{ifname}'", { error_check: false }) - - if network[:type].to_sym == :static - machine.communicate.sudo("ifconfig #{ifname} inet #{network[:ip]} netmask #{network[:netmask]}") - elsif network[:type].to_sym == :dhcp - machine.communicate.sudo("dhclient #{ifname}") - end + # apply new configurations + machine.communicate.sudo("sh /etc/netstart #{ifname}") end end end