1

My understanding is that the netmask of the interface tells what subnet the interface belongs to. Meaning of this information is that the routing system knows that packets to this subnet should be routed to this interface. In particular, Linux automatically adds this route when an address is configured:

# ip address add 1.1.1.1/24 dev eth0
# ip route
1.1.1.0/24 dev eth0  proto kernel  scope link  src 1.1.1.1

Additionally, subnet defines broadcast address, so that the host knows how to send broadcast packets and when to accept packets which have several 1's in the end of the address.

Is there any other meaning for the netmask? I.e. if I manually delete the automatically created route, and if this interface never sends broadcast and is not interested in broadcast reception - will there be any difference from the address with /32 netmask?

0

First of all, a primary network interface on Linux can't be configured with /32.

From the host point of view, the netmask defines the scope of the subnet the host is in.

With it the host knows when to send the packet to another host directly or through the default gateway.

The interface needs to send and receive broadcast, because without it ARP won't work and therefore it won't be able to use the network.

  • "With it the host knows when to send the packet to another host directly or through the default gateway." - This is determined by the routing table, not by the address netmask. The routing table itself may be constructed using netmasks, which I mentioned in the question, but I specifically ask what would be the difference between interfaces with different netmasks when the routes are manually adjusted. – Konstantin Shemyak Aug 28 '15 at 10:12
  • The netmask defines the routing table for the immediate neighborhood (1-hop), because it identifies the subnet. Packet addressed to hosts in the same subnet are delivered directly; packet addressed to hosts in different networks are sent to the local gateway, according to the routing table. – dr01 Aug 28 '15 at 10:24
  • Packet addressed to hosts in the same subnet are delivered directly; packet addressed to hosts in different networks are sent to the local gateway, according to the routing table. - so it is only the routing table what matters? – Konstantin Shemyak Aug 28 '15 at 10:30
  • Yes, it is the routing table that tells which route a packet takes depending on the destination. – dr01 Aug 28 '15 at 10:31
-1

My understanding is that the netmask of the interface tells what subnet the interface belongs to.

What written above could be interpreted as "a netmask is something that is arbitrarily applied to an interface so that it can freely choose to which network communicate", which is not.

A network address (e.g. 10.0.7.0) and a netmask (e.g. 255.255.255.0 i.e. /24 in prefix notation) identify a subnet (here, 10.0.7.0/24). One must correctly configure the interface (e.g. eth0) with an unique IP address belonging to the subnet the interface it's attached to (e.g. we might choose 10.0.7.42); furthermore, one needs to specify the interface's netmask as identical to the subnet netmask.

A /32 netmask doesn't exist as it would have no meaning. The biggest netmask in use is /30 which allows for two valid hosts and is used only in point-to-point connections.

  • It looks like you think a netmask is something that is arbitrarily applied to an interface so that it can freely choose to which network communicate. I still think so. I can configure the interface with the address/mask I chose, and the interface will behave in certain way (e.g. respond to some packets and receive others). My question is how this way depends on the netmask. – Konstantin Shemyak Aug 28 '15 at 10:02
  • 1
    The netmask is applied (via logic AND) to your host's configured IP address to find the network address used for communications between hosts. This is supposed to be the network address the host's interface is attached to; if it's not, the host won't be able to communicate anything coherent. – dr01 Aug 28 '15 at 10:16
  • the host won't be able to communicate anything coherent - what exactly the host will not be able to communicate? Leave aside ARP (my interface is NOARP anyway). I understand it so that the host will send and receive all unicast and multicast packets in exactly the same way, no matter what the netmask is (provided the routing is the same). Broadcast packets are affected. Is this correct? – Konstantin Shemyak Aug 28 '15 at 10:28
  • 1
    Netmask and routing table must be consistent. Mess up the netmask and you'll get a messed-up routing table which affects all uni/multi/broadcast communications. – dr01 Aug 28 '15 at 10:34

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.