2

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?

Eugene Yarmash
  • 2,433
  • 5
  • 34
  • 54

3 Answers3

5

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.

Eugene Yarmash
  • 2,433
  • 5
  • 34
  • 54
  • However a "point-to-point" address is a /31 or a /30. A /32 describes a single host. – adamo Nov 08 '10 at 13:19
  • @adamo: [In practice point-to-point links are typically implemented using /30 networks, or occasionally by /32 and point-to-point explicit host routes](http://en.wikipedia.org/wiki/IPv4_subnetting_reference) – Eugene Yarmash Nov 08 '10 at 14:51
1

In fact you can set the netmask you think is useful.

But, if you change the netmask from /32 you will also need to set a route. If you follow the recommendation you can omit setting a route.

pacey
  • 3,833
  • 1
  • 16
  • 31
-1

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?

adamo
  • 6,925
  • 3
  • 30
  • 58