Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I know how IP basically works, and knows that an IP address composed of a network ID portion and a host ID portion, but when I type a IP address, say into the web browser, I didn't supply any subnet mask information.

So, how does the browser know where the dividing line is between the network ID and host ID? Since may mean, etc.

In a nutshell, the IP address I supplied is ambiguous.

share|improve this question

migrated from Jan 7 '11 at 8:37

This question came from our site for professional and enthusiast programmers.

Unless your application (in this case, the browser) is doing routing, it doesn't need to be concerned with subnet masks. A browser will use the system's TCP/IP facility to send traffic, and that facility routes (routing here meaning shipping traffic somewhere based on subnet) on behalf of any/all applications if necessary. Your PC gets its subnet from DHCP. – LawrenceC Nov 17 '13 at 15:57
up vote 6 down vote accepted

In the case where the other end is outside your local network, your PC doesn't need to know the subnetting arrangements at the other end it just needs to know enough to deliver the packets to the nearest router. For that it uses two pieces of info.

  • local subnet mask
    it uses this in conjunction with it's own IP address to see if the other IP-address is local or not.
  • default gateway (or explicit routes - see netstat -nr)
    anything non-local gets sent there

The router at the other end (i.e. with an interface in the other LAN) knows about subnet arrangements there. Nothing else needs to.

If you look at netstat -nr you'll see your PC's routing table consists of destination-network, network-mask (the other side of subnet-mask) and gateway (router). Usually PCs have a single default gateway plus some kibble for things you don't use much (loopback, multicast etc).

You can think of the network masks in routing tables as equivalent to a high level summary or aggregation of millions of target subnets.

share|improve this answer

The subnet mask is only used to figure out if an address is local to a particular network, and for routing.

If the address you want to contact ( in your example) isn't inside any of your local network(s) (say, & &, then your machine is unable to contact it directly. In that case, it'll send the traffic to a gateway (say, if configured, and hope it gets to its destination.

share|improve this answer

It is not the browser which is finding out the mask, rather the TCP/IP at the lower layer. This also depends on the implementation of the TCP/IP. In most implementations, when an IP is configured without specifying the subnet mask, the default mask for that IP-class will be used. Say, when a class-C IP is configured without mask, then by default mask of can be used.

share|improve this answer

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .