My NIC on my computer has a subnet mask. Is this only for it's own information? Or does the subnet mask get tossed into the TCP/IP headers to help the next device up route it? I'm guessing it's only for the individual device's information. Thanks for your replies in advance!


Neither IP or TCP include the subnet mask in their headers.

The subnet mask is used when receiving traffic - if traffic appears on the wire that is not within a subnet that the interface is assigned, it will drop it. If the interface is placed in promiscuous mode, then all traffic it receives is sent up the TCP/IP stack.

The OS uses the subnet mask to know if it should direct traffic directly to the destination IP (if it's within the subnet) or toward a (default) gateway (if it's not).

As NICs on the hardware level traditionally send and receive Ethernet frames, and not IP packets, I don't think this is necessarily a hardware function of the NIC - though modern NICs have "TCP Offload Engines" (TOEs) that perform much of the processing required by TCP on the NIC itself - those probably filter by subnet in hardware too.

  • 1
    Your answer is correct, but the last paragraph makes no sense. The router receives NO information in the TCP packet regarding the netmask (you said so yourself in the first line and that is correct). It also doesn't care about the target IP netmask. It just matches the target IP itself against it's routing tables to see which next-hop router it must be send to. And what has DHCP to do with this ? Routing tables are learned through a routing protocol or configured statically. Even if the router get's one of its own IP addresses through DHCP it contains no info about routing (except next-hop... – Tonny Feb 12 '14 at 22:34
  • ... gateway for that interface). Baring any other information the router may use that next-hop gateway as "route of last resort". (This is the typical scenario for a customer-router connecting to an ISP. Infrastructure routers typically don't use DHCP at all.) – Tonny Feb 12 '14 at 22:37
  • Very true, once I read that again that didn't make a lot of sense. (I removed it.) I was thinking typical residential router where it gets its WAN IP from the upstream cable/DSL DHCP. – LawrenceC Feb 12 '14 at 22:43
  • Ah... Thanks @ultrasawblade and Tonny. I understand what you're saying perfectly. I think I'm going to go the library and get some networking books! Any recommendations would be appreciated. Thanks! – pkSML Feb 13 '14 at 2:16
  • if traffic appears on the wire that is not within a subnet that the interface is assigned what do you mean by wire? My computer is only connected by one wire to my router – CodyBugstein Feb 24 '15 at 12:32

The netmask, associated with a network interface, is used in the following situations:

  • Normally (but not necessarily) the routing system automatically creates a route to the subnet of the interface
  • IPv4 only: the host determines whether a packet received by an interface is a broadcast to own subnet (and should be processed as such).

These options are detailed in an article "Implications of Netmask Mismatch".

The netmask itself does not directly affect whether the host should send the packet directly to the destination address or to a gateway; it is the routing system which is responsible for this decision (but, as said above, netmasks are normally used for constructing the routing tables).

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.