Open der-eismann opened 2 years ago
I'm also experiencing a this but in MicroOS (#12777). In the case of MicroOS there's no way of installing a working version of ifup
or ifdown
, so there's no workaround possible.
From what I understood, Vagrant lets the VM OS configure the interface (using dhcp) before trying to set a the static address.
I naively tried this, but it didn't work as expected (vagrant also tries to use ifup
/ifdown
):
config.vm.network "private_network", :type => 'dhcp', ip: 10.0.0.123
Since the dhcp server is there anyway, couldn't we just use it to assign our "static" IP? And perhaps even set the hostname?
Having same issue. I've found out that recently Fedora deprecated usage of /etc/sysconfig/network-scripts/*
scripts. Instead keyfiles are used, they are stored under /etc/NetworkManager/system-connections/
. Example configuration for static IP:
[connection]
id=Wired connection 2
uuid=0fc877a1-e3a9-30d3-951b-aa05544ff3e6
type=ethernet
autoconnect-priority=-999
interface-name=eth1
timestamp=1683239079
[ethernet]
[ipv4]
address1=10.0.1.3/32
method=manual
[ipv6]
addr-gen-mode=default
method=auto
which works perfectly for me.
Here's note left in /etc/sysconfig/network-scripts/readme-ifcfg-rh.txt
:
NetworkManager stores new network profiles in keyfile format in the
/etc/NetworkManager/system-connections/ directory.
Previously, NetworkManager stored network profiles in ifcfg format
in this directory (/etc/sysconfig/network-scripts/). However, the ifcfg
format is deprecated. By default, NetworkManager no longer creates
new profiles in this format.
Connection profiles in keyfile format have many benefits. For example,
this format is INI file-based and can easily be parsed and generated.
Each section in NetworkManager keyfiles corresponds to a NetworkManager
setting name as described in the nm-settings(5) and nm-settings-keyfile(5)
man pages. Each key-value-pair in a section is one of the properties
listed in the settings specification of the man page.
If you still use network profiles in ifcfg format, consider migrating
them to keyfile format. To migrate all profiles at once, enter:
# nmcli connection migrate
This command migrates all profiles from ifcfg format to keyfile
format and stores them in /etc/NetworkManager/system-connections/.
Alternatively, to migrate only a specific profile, enter:
# nmcli connection migrate <profile_name|UUID|D-Bus_path>
For further details, see:
* nm-settings-keyfile(5)
* nmcli(1)
If someone needs ad-hoc workaround, you can add following provisioner for your VM:
config.vm.provision "shell", inline: <<-SHELL
nmcli conn modify 'Wired connection 2' ipv4.addresses $(cat /etc/sysconfig/network-scripts/ifcfg-eth1 | grep IPADDR | cut -d "=" -f2)
nmcli conn modify 'Wired connection 2' ipv4.method manual
service NetworkManager restart
SHELL
This is likely to break when using more interfaces than just one for private network.
Starting with version 36 Fedora stopped supporting
ifcfg
files by default. Support can be restored by installing theNetworkManager-initscripts-ifcfg-rh
package, but depending on the scenario this might not be possible. You can see this in the debug output:NetworkManager managed systems should use keyfiles instead.
Vagrant version
Vagrant 2.2.19
Host operating system
Fedora 35
Guest operating system
Fedora 36
Vagrantfile
Debug output
https://gist.github.com/der-eismann/e9165908def8df95574c8e67ab3f102b
Expected behavior
The guest should receive a static IP as usual
Actual behavior
The guest receives a dynamic IP via DHCP instead
Steps to reproduce