1

My Vagrantfile

 config.vm.network :private_network, ip: "172.16.0.22"
  config.vm.provider :virtualbox do |v|
      v.customize ["modifyvm", :id, "--cpus", 2]
      v.customize ["modifyvm", :id, "--memory", 2048]
      v.customize ['modifyvm', :id, '--nicpromisc1', 'allow-all']

After vagrant up

The IP address configured for the host-only network is not within the
allowed ranges. Please update the address used to be within the allowed
ranges and run the command again.

  Address: 172.16.0.22
  Ranges: 10.0.0.0/8, 192.168.0.0/16, 2001::/64

As I understand 172.16.x.x are private IPs.My wlo1

wlo1: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state UP group default qlen 1000
    link/ether c8:94:32:93:05:p2 brd ff:ff:ff:ff:ff:ff
    altname wlp3s0
    inet 192.168.1.19/24 brd 192.168.1.255 scope global dynamic noprefixroute wlo1
       valid_lft 3068sec preferred_lft 3068sec

I changed network.conf file,by adding 172.16.0.0 cat /etc/vbox/networks.conf

* 10.0.0.0/8 192.168.0.0/16 172.16.0.0
* 2001::/64

The same problem is still here.

Why is IP outside of the network range?

3
  • 2
    You forgot the prefix length in the conf. /12 (or maybe longer; depends on what you really want).
    – Tom Yan
    Commented Sep 21, 2023 at 12:51
  • @TomYan Yeah,I got it. Commented Sep 21, 2023 at 13:14
  • @TomYan, Though brief, your comment really is an answer. You might expand just a bit (e.g., showing syntax), to make it complete, to help others with that issue. Commented Sep 21, 2023 at 16:53

1 Answer 1

3

So as per the OP, apparently vagrant determines which IP subnet block(s) can be used for host-only network based on the file /etc/vbox/networks.conf.

An IP subnet is only valid if comes with a subnet mask or prefix length (which are essentially the same thing in different representations), as it indicates the size of the subnet. Address / subnet ID like 172.16.0.0 indicates only the "starting point" of a block or is otherwise considered a single, arbitrary host address.

Therefore, if you want to allow the whole 172.16.0.0/12 block as defind in the RFC, put that (whole thing) in the conf file. (Or, if necessary and/or desired, I'm pretty sure you can allow just part(s) of the block, as long as you have a valid subnet ID and prefix length combination. I'm not gonna tell the full story of subnetting 101 here.)

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .