lib/vagrant/util/network_ip.rb
# Returns the network address of the given IP and subnet.
#
# If the IP address is an IPv6 address, subnet should be a prefix
# length such as "64".
#
# @return [String]
Returns the network address of the given IP and subnet.
If the IP address is an IPv6 address, subnet should be a prefix
length such as "64".
Returns the network address of the given IP and subnet . If the IP address is an IPv6 address subnet should be a prefix length such as " 64 " .
def network_address(ip, subnet)
        if subnet.to_s =~ /^\d+$/
          ip = IPAddr.new(ip)
          return ip.mask(subnet.to_i).to_s
        end
        ip      = ip_parts(ip)
        netmask = ip_parts(subnet)
        ip.map { |part| part & netmask.shift }.join(".")
      end
def network_address ( ip , subnet ) if subnet . to_s =~ / ^ \d +$ / ip = IPAddr . new ( ip ) return ip . mask ( subnet . to_i ) . to_s end ip = ip_parts ( ip ) netmask = ip_parts ( subnet ) ip . map { | part | part & netmask . shift } . join ( "." ) end
Returns the network address of the given IP and subnet.
Returns the network address of the given IP and subnet .
# If this is an IPv6 address, then just mask it # Bitwise-AND each octet to get the network address # in octets and join each part with a period to get # the resulting network address.
None
String
ip
subnet