{"record":{"id":"fcdb841d82ef6311","repo":"hashicorp/vagrant","slug":"network-settings-specified-in-your-vagrantfile-def","errorCode":null,"errorMessage":"Network settings specified in your Vagrantfile define an invalid\nIP address. Please review the error message below and update your\nVagrantfile network settings:\n\n  Address: %{address}\n  Netmask: %{mask}\n  Error: %{error}","messagePattern":"Network settings specified in your Vagrantfile define an invalid\nIP address\\. Please review the error message below and update your\nVagrantfile network settings:\n\n  Address: %(.+?)\n  Netmask: %(.+?)\n  Error: %(.+?)","errorType":"exception","errorClass":"Vagrant::Errors::NetworkAddressInvalid","httpStatus":null,"severity":"error","filePath":"lib/vagrant/util/guest_networks.rb","lineNumber":56,"sourceCode":"\n            if net_opts[:type] != \"dhcp\"\n              begin\n                addr = IPAddr.new(\"#{net_opts[:ip]}\")\n                if addr.ipv4?\n                  tmpl_opts[:ipv4] = addr.to_string\n                  masked = addr.mask(net_opts[:netmask])\n\n                  tmpl_opts[:ipv4_mask] = masked.prefix\n                  tmpl_opts[:ipv4_gateway] = masked.succ.to_string\n                else\n                  tmpl_opts[:ipv6] = addr.to_string\n                  masked = addr.mask(net_opts[:netmask])\n\n                  tmpl_opts[:ipv6_mask] = masked.prefix\n                  tmpl_opts[:ipv6_gateway] = masked.succ.to_string\n                end\n              rescue IPAddr::Error => err\n                raise NetworkAddressInvalid,\n                      address: net_opts[:ip],\n                      mask: net_opts[:netmask],\n                      error: err.to_s\n              end\n            end\n\n            entry = TemplateRenderer.render(\"networking/network_manager/network_manager_device\", options: tmpl_opts)\n            remote_path = \"/tmp/vagrant-network-entry-#{net_opts[:device]}-#{Time.now.to_i}-#{i}\"\n            final_path = \"#{nm_directory}/#{net_opts[:device]}.nmconnection\"\n\n            Tempfile.open(\"vagrant-nm-configure-networks\") do |f|\n              f.binmode\n              f.write(entry)\n              f.fsync\n              f.close\n              comm.upload(f.path, remote_path)\n            end\n","sourceCodeStart":38,"sourceCodeEnd":74,"githubUrl":"https://github.com/hashicorp/vagrant/blob/35f3160f4ad6edc3a9f3aa9570adfc1a4d73aaa5/lib/vagrant/util/guest_networks.rb#L38-L74","documentation":"While generating NetworkManager connection profiles inside the guest (lib/vagrant/util/guest_networks.rb), Vagrant validates the configured address with IPAddr#mask using the configured netmask; any IPAddr::Error (malformed address, invalid netmask, family mismatch such as an IPv4 mask on an IPv6 address) is re-raised as NetworkAddressInvalid with the address, mask, and original error text.","triggerScenarios":"`config.vm.network \"private_network\", ip: \"192.168.50.999\"` (invalid octet), a bad netmask like \"255.255.300.0\", or pairing ipv6: addresses with an IPv4-style netmask — surfacing during `vagrant up`/`reload` when the NetworkManager guest capability renders the device profile.","commonSituations":"Typos in Vagrantfile network stanzas; templates interpolating empty or wrong values into ip/netmask; IPv6 examples copied with IPv4 masks.","solutions":["Correct the ip/netmask so every octet is <= 255 and the mask is a valid contiguous netmask","Prefer CIDR notation (ip: \"192.168.50.10/24\") to keep address and mask consistent","For IPv6, use ipv6: with a proper prefix length instead of an IPv4 netmask","Dry-validate locally: `require 'ipaddr'; IPAddr.new(ip).mask(netmask)` — if Ruby's IPAddr raises, Vagrant will too"],"exampleFix":"# before\nconfig.vm.network \"private_network\", ip: \"192.168.50.10\", netmask: \"255.255.300.0\"\n\n# after\nconfig.vm.network \"private_network\", ip: \"192.168.50.10/24\"","handlingStrategy":"validation","validationCode":"require 'ipaddr'\n\ndef valid_network?(ip, netmask)\n  IPAddr.new(ip).mask(netmask)\n  true\nrescue IPAddr::Error\n  false\nend\n\nabort 'bad network stanza' unless valid_network?('192.168.50.10', '255.255.255.0')","typeGuard":null,"tryCatchPattern":"begin\n  machine.env.lock { configure_networks }\nrescue Vagrant::Errors::NetworkAddressInvalid => e\n  d = e.extra_data # :address, :mask, :error\n  machine.ui.error(\"fix #{d[:address]}/#{d[:mask]}: #{d[:error]}\")\nend","preventionTips":["Lint Vagrantfile network stanzas with an IPAddr-based check","Use CIDR notation consistently","Never template IPs/netmasks from unvalidated variables"],"tags":["network","ip-address","netmask","vagrantfile","guest"],"backgroundTag":"invalid-ip-address","analyzedSha":"35f3160f4ad6edc3a9f3aa9570adfc1a4d73aaa5","analyzedAt":"2026-08-21T13:34:32.514Z","schemaVersion":2},"datasetVersion":"2026-08-21T18:17:14.833Z"}