<?xml version="1.0" encoding="utf-8"?>
<?xml-stylesheet type="text/xsl" href="../assets/xml/rss.xsl" media="all"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>Konstantin Shemyak - Tech Notes (Posts about network)</title><link>https://technotes.shemyak.com/</link><description></description><atom:link href="https://technotes.shemyak.com/categories/network.xml" rel="self" type="application/rss+xml"></atom:link><language>en</language><copyright>Contents © 2021 &lt;a href="mailto:konstantin@shemyak.com"&gt;Konstantin Shemyak&lt;/a&gt; </copyright><lastBuildDate>Fri, 02 Apr 2021 15:51:34 GMT</lastBuildDate><generator>Nikola (getnikola.com)</generator><docs>http://blogs.law.harvard.edu/tech/rss</docs><item><title>ARP messages: Request, Reply, Probe, Announcement</title><link>https://technotes.shemyak.com/posts/arp-messages/</link><dc:creator>Konstantin Shemyak</dc:creator><description>&lt;div&gt;&lt;p&gt;ARP, as originally specified in &lt;a href="http://tools.ietf.org/html/rfc5227"&gt;RFC 826&lt;/a&gt;,
had two message types: &lt;code&gt;REQUEST&lt;/code&gt; and &lt;code&gt;REPLY&lt;/code&gt;.
But besides that one can hear of two "other" ARP messages:
&lt;code&gt;PROBE&lt;/code&gt; &lt;code&gt;ANNOUNCEMENT&lt;/code&gt;, the latter also called "&lt;strong&gt;gratuitous ARP&lt;/strong&gt;".
They happen when a host send the &lt;strong&gt;reply&lt;/strong&gt; message not in response to any
preceding request; this has been formalized in
&lt;a href="http://tools.ietf.org/html/rfc5227"&gt;RFC 5227&lt;/a&gt;. &lt;/p&gt;
&lt;p&gt;One may find confusing that:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;The two "new" messages do not extend the protocol. In particular,
they do not introduce new ARP message types. How can we speak about
"new messages"?&lt;/li&gt;
&lt;li&gt;Source and destination MAC addresses are present in the MAC headers,
but there are also "&lt;strong&gt;Source Hardware Address&lt;/strong&gt;" and 
"&lt;strong&gt;Target Hardware Address&lt;/strong&gt;" fields in the ARP body.
Why this duplication?&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;These two questions are related. The table below shows the 
&lt;strong&gt;MAC headers&lt;/strong&gt; and (relevant) &lt;strong&gt;ARP protocol fields&lt;/strong&gt; for each of the
four messages. The differences help to understand how each field is used.&lt;/p&gt;
&lt;table border="1"&gt;&lt;tbody&gt;
&lt;tr style="background-color: #e0e0e0;"&gt;&lt;td rowspan="2"&gt;Message&lt;/td&gt;&lt;td rowspan="2"&gt;Sent when the host...&lt;/td&gt;&lt;td colspan="2"&gt;MAC headers&lt;/td&gt;&lt;td colspan="5"&gt;ARP body&lt;/td&gt;&lt;/tr&gt; 
&lt;tr style="background-color: #e0e0e0;"&gt;&lt;td&gt;src MAC&lt;/td&gt;&lt;td&gt;dst MAC&lt;/td&gt;&lt;td&gt;message type&lt;/td&gt;&lt;td&gt;Source Hardware Address&lt;/td&gt;&lt;td&gt;Source Protocol Address&lt;/td&gt;&lt;td&gt;Target Hardware Address&lt;/td&gt;&lt;td&gt;Target Protocol Address&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;request&lt;/td&gt;&lt;td&gt;wants to send an IP packet, but does not know the MAC address of the destination&lt;/td&gt;&lt;td&gt;own&lt;/td&gt;&lt;td&gt;broadcast&lt;/td&gt;&lt;td&gt;REQUEST&lt;/td&gt;&lt;td&gt;own&lt;/td&gt;&lt;td&gt;own&lt;/td&gt;&lt;td&gt;0&lt;/td&gt;&lt;td&gt;destination's&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;reply&lt;/td&gt;&lt;td&gt;receives an ARP request to an IP address this host owns&lt;/td&gt;&lt;td&gt;own&lt;/td&gt;&lt;td&gt;destination's, or broadcast&lt;sup&gt;1&lt;/sup&gt;&lt;/td&gt;&lt;td&gt;REPLY&lt;/td&gt;&lt;td&gt;own&lt;/td&gt;&lt;td&gt;own&lt;/td&gt;&lt;td&gt;requestor's&lt;/td&gt;&lt;td&gt;requestor's&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;probe (RFC 5227, 2.1)&lt;/td&gt;&lt;td&gt;configures a new IP address for an interface&lt;/td&gt;&lt;td&gt;own&lt;/td&gt;&lt;td&gt;broadcast&lt;/td&gt;&lt;td&gt;REQUEST&lt;sup&gt;2&lt;/sup&gt;&lt;/td&gt;&lt;td&gt;own&lt;/td&gt;&lt;td&gt;0&lt;sup&gt;3&lt;/sup&gt;&lt;/td&gt;&lt;td&gt;0&lt;/td&gt;&lt;td&gt;probed&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;announcement (RFC 5227, 2.3)&lt;/td&gt;&lt;td&gt;after a probe, concludes that it will use the probed address&lt;/td&gt;&lt;td&gt;own&lt;/td&gt;&lt;td&gt;broadcast&lt;/td&gt;&lt;td&gt;REQUEST&lt;sup&gt;2&lt;/sup&gt;&lt;/td&gt;&lt;td&gt;own&lt;/td&gt;&lt;td&gt;new own&lt;/td&gt;&lt;td&gt;0&lt;/td&gt;&lt;td&gt;new own&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;

&lt;h3&gt;Notes to the table&lt;/h3&gt;
&lt;ol&gt;
&lt;li&gt;&lt;a href="https://tools.ietf.org/html/rfc5227#section-2.6"&gt;RFC 5227, section 2.6&lt;/a&gt;
   explains why "Broadcast replies are not
   universally recommended, but may be appropriate in some cases".&lt;/li&gt;
&lt;li&gt;&lt;a href="https://tools.ietf.org/html/rfc5227#section-3"&gt;RFC 5227, section 3&lt;/a&gt;
   notes that the type here could be REPLY as well,
   then continues to give reasons why REQUEST is recommended.&lt;/li&gt;
&lt;li&gt;Zero is specified here in order not to pollute ARP caches of other
   hosts in case when the probed address is already taken by someone else.&lt;/li&gt;
&lt;/ol&gt;&lt;/div&gt;</description><category>network</category><guid>https://technotes.shemyak.com/posts/arp-messages/</guid><pubDate>Tue, 26 Jan 2016 18:46:00 GMT</pubDate></item><item><title>Possible implications of netmask mismatch</title><link>https://technotes.shemyak.com/posts/netmask-mismatch/</link><dc:creator>Konstantin Shemyak</dc:creator><description>&lt;div&gt;&lt;p&gt;&lt;strong&gt;Summary:&lt;/strong&gt; an IPv4 host with a netmask not matching that of the subnet to which the interface is connected likely builds incorrect routing tables, misses some broadcasts, may incorrectly identify broadcasts as unicasts, and unintentionally broadcast to own subnet.&lt;/p&gt;
&lt;h3&gt;What does it mean - a "wrong netmask"?&lt;/h3&gt;
&lt;p&gt;The &lt;em&gt;netmask&lt;/em&gt; (in IPv4 terminology) and &lt;em&gt;network prefix&lt;/em&gt; (in IPv6 terminology)
can be associated with an &lt;em&gt;IP subnet&lt;/em&gt;, and correspondingly with a 
&lt;em&gt;network interface&lt;/em&gt;. This post handles IPv4 only, so the term "netmask"
will be used. Together with own IP address, the netmask determines whether
another IP address belongs to the same IP subnet as the NIC.&lt;/p&gt;
&lt;p&gt;Good, so how is this knowledge used?&lt;/p&gt;
&lt;p&gt;Processing of &lt;strong&gt;multicast&lt;/strong&gt; packets is not affected by the netmask,
thus multicast would not be mentioned here further. For &lt;strong&gt;unicast&lt;/strong&gt;
and &lt;strong&gt;broadcast&lt;/strong&gt;, the netmask is consulted in three different situations,
listed in the following sections.&lt;/p&gt;
&lt;h3&gt;Case 1. Netmask can be used as input for constructing the routing table.&lt;/h3&gt;
&lt;p&gt;The routing system normally automatically creates routes to the subnet
to which each network interface belongs. I.e. for each network interface
&lt;code&gt;I&lt;/code&gt; with address &lt;code&gt;AI&lt;/code&gt; and netmask &lt;code&gt;M&lt;/code&gt;, the host calculates the subnet of
this interface as &lt;code&gt;SI = AI &amp;amp; M&lt;/code&gt;.
Outgoing packets to any address &lt;code&gt;AP&lt;/code&gt; such that &lt;code&gt;AP &amp;amp; M = SI&lt;/code&gt; would be
emitted from the interface &lt;code&gt;I&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;While this behavior is typical, nothing mandates hosts to create such
routing table entry. For example, if a host has two interfaces on the
same subnet, then obviously some more information is needed to decide,
which of the interfaces shall emit the packets destined to their common
subnet. Another example is a firewall with more restrictive forwarding
policy than just &lt;em&gt;"put every packet for subnet &lt;code&gt;SI&lt;/code&gt; to interface &lt;code&gt;I&lt;/code&gt;"&lt;/em&gt;.&lt;/p&gt;
&lt;h3&gt;Case 2. Netmask is used to determine whether an arrived packet is a (directed) broadcast to a subnet of some local interface.&lt;/h3&gt;
&lt;p&gt;After the routing is covered, we can limit our further 
investigation to only:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Unicast&lt;/strong&gt; packets, destined to "this host" (i.e. one of its interfaces).&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Directed broadcast&lt;/strong&gt; packets to "this network". There can be more than 
  one "this" network if the host has more than one network interface
  (the host can be or not be a router).&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Really,&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Directed broadcast&lt;/strong&gt; to a network not in "our network" set is handled as
  any other packet subject to possible routing.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Local broadcast&lt;/strong&gt; packets are obviously not affected by the netmask
  setting.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;For hosts which are &lt;strong&gt;not routers&lt;/strong&gt; &lt;a href="https://tools.ietf.org/html/rfc922"&gt;RFC922&lt;/a&gt;
defines handling of broadcast packets in a simple way:&lt;/p&gt;
&lt;pre class="code literal-block"&gt;&lt;span&gt;&lt;/span&gt;&lt;span class="nv"&gt;In&lt;/span&gt; &lt;span class="nv"&gt;the&lt;/span&gt; &lt;span class="nv"&gt;absence&lt;/span&gt; &lt;span class="nv"&gt;of&lt;/span&gt; &lt;span class="nv"&gt;broadcasting&lt;/span&gt;, &lt;span class="nv"&gt;a&lt;/span&gt; &lt;span class="nv"&gt;host&lt;/span&gt; &lt;span class="nv"&gt;determines&lt;/span&gt; &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="nv"&gt;it&lt;/span&gt; &lt;span class="nv"&gt;is&lt;/span&gt; &lt;span class="nv"&gt;the&lt;/span&gt;
&lt;span class="nv"&gt;recipient&lt;/span&gt; &lt;span class="nv"&gt;of&lt;/span&gt; &lt;span class="nv"&gt;a&lt;/span&gt; &lt;span class="nv"&gt;datagram&lt;/span&gt; &lt;span class="nv"&gt;by&lt;/span&gt; &lt;span class="nv"&gt;matching&lt;/span&gt; &lt;span class="nv"&gt;the&lt;/span&gt; &lt;span class="nv"&gt;destination&lt;/span&gt; &lt;span class="nv"&gt;address&lt;/span&gt; &lt;span class="nv"&gt;against&lt;/span&gt;
&lt;span class="nv"&gt;all&lt;/span&gt; &lt;span class="nv"&gt;of&lt;/span&gt; &lt;span class="nv"&gt;its&lt;/span&gt; &lt;span class="nv"&gt;IP&lt;/span&gt; &lt;span class="nv"&gt;addresses&lt;/span&gt;.  &lt;span class="nv"&gt;With&lt;/span&gt; &lt;span class="nv"&gt;broadcasting&lt;/span&gt;, &lt;span class="nv"&gt;a&lt;/span&gt; &lt;span class="nv"&gt;host&lt;/span&gt; &lt;span class="nv"&gt;must&lt;/span&gt; &lt;span class="nv"&gt;compare&lt;/span&gt; &lt;span class="nv"&gt;the&lt;/span&gt;
&lt;span class="nv"&gt;destination&lt;/span&gt; &lt;span class="nv"&gt;address&lt;/span&gt; &lt;span class="nv"&gt;not&lt;/span&gt; &lt;span class="nv"&gt;only&lt;/span&gt; &lt;span class="nv"&gt;against&lt;/span&gt; &lt;span class="nv"&gt;the&lt;/span&gt; &lt;span class="nv"&gt;host&lt;/span&gt;&lt;span class="s1"&gt;'&lt;/span&gt;&lt;span class="s"&gt;s addresses, but also&lt;/span&gt;
&lt;span class="nv"&gt;against&lt;/span&gt; &lt;span class="nv"&gt;the&lt;/span&gt; &lt;span class="nv"&gt;possible&lt;/span&gt; &lt;span class="nv"&gt;broadcast&lt;/span&gt; &lt;span class="nv"&gt;addresses&lt;/span&gt; &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="nv"&gt;that&lt;/span&gt; &lt;span class="nv"&gt;host&lt;/span&gt;.
&lt;/pre&gt;


&lt;p&gt;Now imagine that an interface of some host has netmask, which does not
match one of the subnet this interface is connected to. This is what
happens.&lt;/p&gt;
&lt;h4&gt;Netmask of the interface is shorter&lt;/h4&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;Interface misconfigured with a &lt;strong&gt;shorter netmask&lt;/strong&gt; fails to process broadcasts:
  they are understood as unicasts by such host.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Example: in &lt;code&gt;/24&lt;/code&gt; network &lt;span style="color: red;"&gt;1.1.1&lt;/span&gt;.&lt;span style="color: #38761d;"&gt;0&lt;/span&gt;, a packet to a broadcast address &lt;span style="color: red;"&gt;1.1.1&lt;/span&gt;.&lt;span style="color: #38761d;"&gt;255&lt;/span&gt; will not be recognized as broadcast by a misconfigured interface &lt;span style="color: red;"&gt;1.1&lt;/span&gt;.&lt;span style="color: #38761d;"&gt;1.1&lt;/span&gt;/16.&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;That is, unless the network has all bits in the netmask difference equal to 1.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;Example: in &lt;code&gt;/24&lt;/code&gt; network &lt;span style="color: red;"&gt;1.1.255&lt;/span&gt;.&lt;span style="color: #38761d;"&gt;0&lt;/span&gt;, a packet to a broadcast address &lt;span style="color: red;"&gt;1.1.255&lt;/span&gt;.&lt;span style="color: #38761d;"&gt;255&lt;/span&gt; will be, by a coincidence, correctly accepted as broadcast by a misconfigured interface &lt;span style="color: red;"&gt;1.1&lt;/span&gt;.&lt;span style="color: #38761d;"&gt;1.1&lt;/span&gt;/16.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Broadcast packet which is incorrectly understood as unicast by a 
  misconfigured interface can also happen to bear the destination address
  of this interface itself.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Example: in &lt;code&gt;/16&lt;/code&gt; network &lt;span style="color: red;"&gt;1.1&lt;/span&gt;.&lt;span style="color: #38761d;"&gt;0.0&lt;/span&gt;, a broadcast packet to &lt;span style="color: red;"&gt;1.1&lt;/span&gt;.&lt;span style="color: #38761d;"&gt;255.255&lt;/span&gt; will be received as unicast by a misconfigured interface &lt;span style="color: red;"&gt;1&lt;/span&gt;.&lt;span style="color: #38761d;"&gt;1.255.255&lt;/span&gt;/8.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Additionally, the host may attempt to send a unicast packet which would
  appear as a valid broadcast on the network.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Example: in &lt;code&gt;/16&lt;/code&gt; network &lt;span style="color: red;"&gt;1.1&lt;/span&gt;.&lt;span style="color: #38761d;"&gt;0.0&lt;/span&gt;, a host misconfigured as &lt;span style="color: red;"&gt;1&lt;/span&gt;.&lt;span style="color: #38761d;"&gt;1.1.1&lt;/span&gt;/8 sends a unicast to destination address &lt;span style="color: red;"&gt;1&lt;/span&gt;.&lt;span style="color: #38761d;"&gt;1.255.255&lt;/span&gt;. It appears as broadcast on this network. In fact, there can be no host with address &lt;span style="color: red;"&gt;1.1&lt;/span&gt;.&lt;span style="color: #38761d;"&gt;255.255&lt;/span&gt; on this network (as it is a broadcast address), so nobody answers ARP query and the host will not be able to send such packet.&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;h4&gt;Netmask of the interface is longer&lt;/h4&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;Interface misconfigured with a &lt;strong&gt;longer netmask&lt;/strong&gt; fails to process broadcasts
as well: it will consider them not belonging to own subnet.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Example: in &lt;code&gt;/8&lt;/code&gt; network &lt;span style="color: red;"&gt;1&lt;/span&gt;.&lt;span style="color: #38761d;"&gt;0.0.0&lt;/span&gt;, a packet to a broadcast address &lt;span style="color: red;"&gt;1&lt;/span&gt;.&lt;span style="color: #38761d;"&gt;255.255.255&lt;/span&gt; will not be received by a misconfigured interface &lt;span style="color: red;"&gt;1.1&lt;/span&gt;.&lt;span style="color: #38761d;"&gt;1.1&lt;/span&gt;/16.&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Again, unless the address of the misconfigured interface happens to have
  all bits in the netmask difference being equal to 1.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Example: in that same network, that same broadcast packet will be
    accepted just fine by a misconfigured interface
    &lt;span style="color: red;"&gt;1.255&lt;/span&gt;.&lt;span style="color: #38761d;"&gt;1.1&lt;/span&gt;/16.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;For hosts which &lt;strong&gt;are routers&lt;/strong&gt;, RFC922 adds the clause concerning for broadcast packets destined to other interface than the one on which the packet is received:&lt;/p&gt;
&lt;pre class="code literal-block"&gt;&lt;span&gt;&lt;/span&gt;...&lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="nv"&gt;the&lt;/span&gt; &lt;span class="nv"&gt;datagram&lt;/span&gt; &lt;span class="nv"&gt;is&lt;/span&gt; &lt;span class="nv"&gt;addressed&lt;/span&gt; &lt;span class="nv"&gt;to&lt;/span&gt; &lt;span class="nv"&gt;a&lt;/span&gt; &lt;span class="nv"&gt;hardware&lt;/span&gt; &lt;span class="nv"&gt;network&lt;/span&gt;
&lt;span class="nv"&gt;to&lt;/span&gt; &lt;span class="nv"&gt;which&lt;/span&gt; &lt;span class="nv"&gt;the&lt;/span&gt; &lt;span class="nv"&gt;gateway&lt;/span&gt; &lt;span class="nv"&gt;is&lt;/span&gt; &lt;span class="nv"&gt;connected&lt;/span&gt;, &lt;span class="nv"&gt;it&lt;/span&gt; &lt;span class="nv"&gt;should&lt;/span&gt; &lt;span class="nv"&gt;be&lt;/span&gt; &lt;span class="nv"&gt;sent&lt;/span&gt; &lt;span class="nv"&gt;as&lt;/span&gt; &lt;span class="nv"&gt;a&lt;/span&gt;
&lt;span class="ss"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;data&lt;/span&gt; &lt;span class="nv"&gt;link&lt;/span&gt; &lt;span class="nv"&gt;layer&lt;/span&gt;&lt;span class="ss"&gt;)&lt;/span&gt; &lt;span class="nv"&gt;broadcast&lt;/span&gt; &lt;span class="nv"&gt;on&lt;/span&gt; &lt;span class="nv"&gt;that&lt;/span&gt; &lt;span class="nv"&gt;network&lt;/span&gt;.  &lt;span class="nv"&gt;Again&lt;/span&gt;, &lt;span class="nv"&gt;the&lt;/span&gt;
&lt;span class="nv"&gt;gateway&lt;/span&gt; &lt;span class="nv"&gt;should&lt;/span&gt; &lt;span class="nv"&gt;consider&lt;/span&gt; &lt;span class="nv"&gt;itself&lt;/span&gt; &lt;span class="nv"&gt;a&lt;/span&gt; &lt;span class="nv"&gt;destination&lt;/span&gt; &lt;span class="nv"&gt;of&lt;/span&gt; &lt;span class="nv"&gt;the&lt;/span&gt; &lt;span class="nv"&gt;datagram&lt;/span&gt;.
&lt;/pre&gt;


&lt;p&gt;In this case, the netmask of the router's interface, where the packet has been received, is not relevant - packet should be processed anyway. Instead, the packet's destination interface configuration is the basis for the decision. Correspondingly, mismatch between the netmask of the destination interface and the sender's expectation of the netmask leads to same consequences as listed above for non-forwarding hosts.&lt;/p&gt;
&lt;p&gt;Have we covered all cases? Three independent factors affect the outcome:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Is the receiver's netmask shorter or longer than of the subnet it is connected to?&lt;/li&gt;
&lt;li&gt;Are the bits from the difference in netmask lengths all equal to one?&lt;/li&gt;
&lt;li&gt;Is the packet unicast or (directed) broadcast?&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;All 8 possibilities have been considered above.&lt;/p&gt;
&lt;h3&gt;Case 3. Netmask is used for setting destination address of outgoing broadcast packets.&lt;/h3&gt;
&lt;p&gt;When a host wishes to send a broadcast packet from certain interface,
it sets the destination address to that of the interface and puts &lt;code&gt;1&lt;/code&gt; to
all bits which are zeros in the netmask. Correspondingly:&lt;/p&gt;
&lt;h4&gt;Netmask of the network interface is shorter&lt;/h4&gt;
&lt;p&gt;Host with &lt;strong&gt;shorter netmask&lt;/strong&gt; will set too many bits to &lt;code&gt;1&lt;/code&gt;.
On the local subnet, these packets will be recognized as belonging
to other subnet by other hosts and consequently not processed.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Example: in &lt;code&gt;/24&lt;/code&gt; network &lt;span style="color: red;"&gt;1.1.1&lt;/span&gt;.&lt;span style="color: #38761d;"&gt;0&lt;/span&gt;/24, host misconfigured as &lt;span style="color: red;"&gt;1.1&lt;/span&gt;.&lt;span style="color: #38761d;"&gt;1.1&lt;/span&gt;/16 sends what it thinks a "broadcast" with destination &lt;span style="color: red;"&gt;1.1&lt;/span&gt;.&lt;span style="color: #38761d;"&gt;255.255&lt;/span&gt;. (It will be sent as link-layer broadcast.) No other host on this network accepts it.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Unless if the network has all bits in the netmask difference being equal to one.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Example: in /24 network &lt;span style="color: red;"&gt;1.1.255&lt;/span&gt;.&lt;span style="color: #38761d;"&gt;0&lt;/span&gt;/24, a misconfigured host &lt;span style="color: red;"&gt;1.1&lt;/span&gt;.&lt;span style="color: #38761d;"&gt;255.1&lt;/span&gt;/16 sends a "broadcast" packet to &lt;span style="color: red;"&gt;1.1&lt;/span&gt;.&lt;span style="color: #38761d;"&gt;255.255&lt;/span&gt;, which happens to be a valid broadcast on this network.&lt;/li&gt;
&lt;/ul&gt;
&lt;h4&gt;Netmask of the network interface is longer&lt;/h4&gt;
&lt;p&gt;Host with &lt;strong&gt;longer netmask&lt;/strong&gt; will not set enough bits to &lt;code&gt;1&lt;/code&gt;.
The packets sent as broadcast will be recognized as unicast by other hosts
on this subnet.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Example: in &lt;code&gt;/8&lt;/code&gt; network &lt;span style="color: red;"&gt;1&lt;/span&gt;.&lt;span style="color: #38761d;"&gt;0.0.0&lt;/span&gt;/8, a host misconfigured as &lt;span style="color: red;"&gt;1.1&lt;/span&gt;.&lt;span style="color: #38761d;"&gt;1.1&lt;/span&gt;/16 sends what it thinks to be a broadcast packet to &lt;span style="color: red;"&gt;1.1&lt;/span&gt;.&lt;span style="color: #38761d;"&gt;255.255&lt;/span&gt;. It appears as valid unicast on this subnet. If there is a host with address &lt;span style="color: red;"&gt;1&lt;/span&gt;.&lt;span style="color: #38761d;"&gt;1.255.255&lt;/span&gt;, this host will accept this packet. (Besides probably unexpected IP content, the host may also notice that the layer 2 address of this packet was a layer 2 broadcast.)&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Naturally, these cases are "reversed" repetition of the cases for the receiving hosts.&lt;/p&gt;
&lt;h3&gt;Conclusion&lt;/h3&gt;
&lt;p&gt;Netmask is normally (but not necessarily) used as input for the &lt;strong&gt;routing table&lt;/strong&gt; construction. If used, then a wrong interface netmask makes possible the following routing failures:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Too long netmask&lt;/strong&gt;: the host will have no route for some packets, actually belonging to a subnet of this interface. Attempt to send packet to a host outside the too long misconfigured netmask but inside the correct netmask of the net results in ICMP error &lt;em&gt;"Destination net unreachable"&lt;/em&gt;. If there is a default outgoing interface, the host will not generate the error, but send the packets to the default interface instead of the interface of this subnet.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Too short netmask&lt;/strong&gt;: the host may attempt to send to the interface packets, which would not be received by any host of the connected subnet. This attempt probably fails, because no host answers the ARP request. This results in ICMP error "Destination host unreachable".&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;In IPv4, &lt;strong&gt;directed broadcast&lt;/strong&gt; packets are sent and received utilizing the netmask information. Directed broadcast is a marginal case; such packets are rarely used and dropped by most routers as per &lt;a href="https://tools.ietf.org/html/rfc2644"&gt;RFC2644&lt;/a&gt;.
But if directed broadcasts are used, then mismatched netmask results in any of:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;failure to receive broadcast packets&lt;/li&gt;
&lt;li&gt;failure to forward broadcast packets by routers&lt;/li&gt;
&lt;li&gt;forwarding broadcast packets, destined to own network&lt;/li&gt;
&lt;li&gt;accepting unicast packets, destined to some host, as broadcasts&lt;/li&gt;
&lt;li&gt;accepting broadcast packets as unicast.&lt;/li&gt;
&lt;/ul&gt;&lt;/div&gt;</description><category>network</category><guid>https://technotes.shemyak.com/posts/netmask-mismatch/</guid><pubDate>Sat, 03 Oct 2015 10:51:00 GMT</pubDate></item></channel></rss>