From FreeBSD handbook on the topic of virtual hosts:
For a given interface, there must be one address which correctly represents the network's netmask. Any other addresses which fall within this network must have a netmask of all 1s (expressed as either 255.255.255.255 or 0xffffffff).
Can anybody explain why this is the case?
This page contains a good explanation imho:
Since aliases are, in a sense, duplicate tags, the system needs to know whether the subnet represented by the tag is new, and this is indicated by the netmask. With a "normal" netmask, the system is told this is a new subnet, and it can then set up internal tables correctly. If the subnet is not new, the tables will get set up incorrectly if the netmask is "normal".
With a netmask of 255.255.255.255, the system knows this is a duplicate of an existing subnet, and therefore will assign the address as if it were assigned to the loopback interface, with the "point-to-point" mask.
Assigning a netmask of 255.255.255.0 will, in most cases, appear to work. However, the internal tables will not be set up correctly, and if the alias is removed, problems may ensue. This can be overcome by adding appropriate host routes when the alias is added, and removing the routes when the alias is removed. However, the system works correctly with the "point-to-point" netmask, and maintenance is easier.
Well the FreeBSD manpage on ifconfig is not very helpful:
If the address is on the same subnet as the first network address for this interface, a non-conflicting netmask must be given. Usually 0xffffffff is most appropriate.
But what the above means is that a /32 mask makes this a specific network (The simplest network, a single host, is described by a /32 mask). Having the same netmask as the physical interface does not do any harm, as they are two interfaces on the same network.
Now imagine the alias having a mask that describes a superset network than that of the physical interface, e.g. the physical being 192.168.0.1/25 and the alias 192.168.0.2/24. Is 192.168.0.200 on the network and what does this mean for your alias interface?
User contributions licensed under CC BY-SA 3.0