module Vagrant::Util::NetworkIP

Constants

DEFAULT_MASK
LOGGER

Public Instance Methods

network_address(ip, subnet) click to toggle source

Returns the network address of the given IP and subnet.

@return [String]

# File lib/vagrant/util/network_ip.rb, line 14
def network_address(ip, subnet)
  begin
    IPAddr.new(ip).mask(subnet).to_s
  rescue IPAddr::InvalidPrefixError
    LOGGER.warn("Provided mask '#{subnet}' is invalid. Falling back to using mask '#{DEFAULT_MASK}'")
    IPAddr.new(ip).mask(DEFAULT_MASK).to_s
  end
end