1

if we took Windows as an example, we can use the command "netstat -rn" to show route table as follows:

    IPv4 Route Table
===========================================================================
Active Routes:
Network Destination        Netmask          Gateway       Interface  Metric
                              (omit other items..)
     192.168.56.0    255.255.255.0         On-link      192.168.56.1    281
     192.168.56.1  255.255.255.255         On-link      192.168.56.1    281
   192.168.56.255  255.255.255.255         On-link      192.168.56.1    281

we can also use the command "ipconfig" to list interfaces as follows:

Ethernet adapter Ethernet 3:
                       (omit other items..)
   Connection-specific DNS Suffix  . :
   Link-local IPv6 Address . . . . . : fe80::e1d6:d479:c8d3:3032%8
   IPv4 Address. . . . . . . . . . . : 192.168.56.1
   Subnet Mask . . . . . . . . . . . : 255.255.255.0
   Default Gateway . . . . . . . . . :

if we are sending an ip packet to "192.168.56.13", this dest ip address will be ANDed the "Netmask(255.255.255.0)" and compared to "Network Dest AND Netmask" for all items in IPv4 Route Table, and get the Interface "192.168.56.1".

my question is that in the interface information got from ipconfig, there is another "Subnet Mask(255.255.255.0)". What's the different purpose between "Netmask" and "Subnet Mask"? is "Subnet Mask" just used for another AND operation after getting interface from route table to determine if "192.168.56.13" is in the same LAN(broadcast domain) or not?

1
  • 1
    They are the same thing. Packets destined to 192.168.56.1/32 go to local CPU. Unicast packets destined to 192.168.56.xx/24 exit via Ethernet 3 interface, if there is an ARP entry to that destination. If there is no ARP to 192.168.56.xx host, OS first generates an ARP request.
    – manish ma
    Jul 23 at 19:49
2

Network and subnet are the same thing in the post-network address class world, and IPv6 never had network address classes, but still uses masks (always written as the mask length, not an explicit mask).

An address mask is used to distinguish the network and host portions of an address. It is used to determine the part of the destination address that should be matched against a routing table network address to determine if there is a match, and the longest match will be used (or the lowest metric in case of a length tie).

The interface is the actual interface to which the packet (not package) gets forwarded when a match is determined. It is quite possible, even required, in routers to have multiple interfaces, ether physical or logical, or both, because routers route packets between different networks.

6
  • but after "a match is determined"(we knew which interface to forward to), why there is another "Subnet Mask" assigned to this interface?
    – 柯鴻儀
    Jul 23 at 19:46
  • The interface address has a mask so that you know the network attached to that interface. You need to know if the network is directly attached, or if the network is distant and needs to be sent to a gateway.
    – Ron Maupin
    Jul 23 at 19:56
  • Interface information is reflected in the routing table as a "local route". Its is redundant.
    – manish ma
    Jul 23 at 19:56
  • No, the information on the interface is used to determine the data-link frame created for the packet. If the destination address is in the network on the interface, the the frame is built for the destination host, else the frame is built for the gateway to leave the network.
    – Ron Maupin
    Jul 23 at 19:59
  • @RonMaupin so if I understand the comment above right, the mask on interface will be used to get network id the second times after comparing to the route table, right?
    – 柯鴻儀
    Jul 23 at 20:00
2

They are the same thing. A subnet mask is used to divide the IP address into network address and host address. In this example the subnet mask 255.255.255.0 equals to 11111111.11111111.11111111.00000000 which is the equivalent of it in bits, stating that it has 256 hosts in which 254 are available.

The interface on the other hand is simply an actual interface that is used to forward traffic. the interface needs to have a mask so it knows to what subnet it relates to.

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.