Solaris 中的默认网络掩码

Solaris 中的默认网络掩码

在 Solaris 本地区域上,默认网络掩码是什么?

我有一个空白/etc/netmasks文件,但如果我运行,ifconfig我可以看到网络掩码设置为ffffff00.

[username@servername]# /usr/sbin/ifconfig -a
lo0:10: flags=2001000849<UP,LOOPBACK,RUNNING,MULTICAST,IPv4,VIRTUAL> mtu 8232 index 1
        inet 127.0.0.1 netmask ff000000
ifname5:3: flags=1000843<UP,BROADCAST,RUNNING,MULTICAST,IPv4> mtu 1500 index 7
        inet 10.56.20.179 netmask ffffff00 broadcast 10.56.20.255

netmasks如果文件为空,重新启动时如何设置子网掩码?这是基于全局区域中的某些内容吗?

ifconfig同样(??),如果该命令用于设置接口的地址并且未在命令中显式设置网络掩码,那么默认子网掩码在哪里设置?

澄清我想根据静态配置文件检查非全局区域的已配置子网掩码,以预测重新启动或故障转移时的行为。哪些文件包含此信息?

正如 schlly 提到的,我给出的示例可能不是 10.xxx 网络的典型设置,但我认为有人(比我更有经验)故意配置了其设置,我正在尝试为所有非 10.xxx 网络创建网络设置清单。全球区域。

答案1

根据区域和 Solaris 版本,您可能必须以不同的方式指定网络。使用共享网络接口,区域操作系统不需要了解网络配置,因为它与全局区域共享。因此,实际上您的网络将在全局区域中定义,您只需在 zonecfg 配置中指定 IP。

如果您使用的是独占 IP(Solaris 11 上可用),则需要手动配置每个区域内的 IP,因为它们具有单独的 IP 堆栈。

schily 提到得很好,如果没有指定网络掩码,它将从默认值中获取。如果你看这里你会发现以下内容:

网络掩码 掩码

For IPv4 only. Specify how much of the address to reserve for subdividing networks into subnetworks. The mask includes the network part of the local address and the subnet part, which is taken from the host field of the address. The mask contains 1's for the bit positions in the 32-bit address which are to be used for the network and subnet parts, and 0's for the host part. The mask should contain at least the standard network portion, and the subnet field should be contiguous with the network portion. The mask can be specified in one of four ways:

    with a single hexadecimal number with a leading 0x,

    with a dot-notation address,

    with a “+” (plus sign) address, or

    with a pseudo host name/pseudo network name found in the network database networks(4).

If a “+” (plus sign) is given for the netmask value, the mask is looked up in the netmasks(4) database. This lookup finds the longest matching netmask in the database by starting with the interface's IPv4 address as the key and iteratively masking off more and more low order bits of the address. This iterative lookup ensures that the netmasks(4) database can be used to specify the netmasks when variable length subnetmasks are used within a network number.

If a pseudo host name/pseudo network name is supplied as the netmask value, netmask data may be located in the hosts or networks database. Names are looked up by first using gethostbyname(3NSL). If not found there, the names are looked up in getnetbyname(3SOCKET). These interfaces may in turn use nsswitch.conf(4) to determine what data store(s) to use to fetch the actual value.

For both inet and inet6, the same information conveyed by mask can be specified as a prefix_length attached to the address parameter.

此外,如果您在区域配置中使用共享地址,并且配置了无法通过 zonecfg 识别的 IP,您将看到以下消息:

zone 'zone-shared-ip': warning: net0: no matching subnet found in netmasks(4): 10.0.2.150; using default of 255.0.0.0

答案2

与 UNIX 中通常一样,网络掩码设置为与地址范围匹配的默认值。

127.0.0.1例如,A 类地址,因此网络掩码为 255.255.255.0

您的示例中的另一个网络似乎已使用本地配置特定值进行设置。

相关内容