Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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 8.8.8.8 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 8.8.8.8 may mean 8.8.8.8/8, 8.8.8.8/24 etc.

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

share|improve this question

migrated from stackoverflow.com 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. –  ultrasawblade Nov 17 '13 at 15:57
add comment

3 Answers

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
add comment

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 (8.8.8.8 in your example) isn't inside any of your local network(s) (say, 172.16.3.0/24 & 127.0.0.1/8 & 192.168.45.88/29), then your machine is unable to contact it directly. In that case, it'll send the traffic to a gateway (say 192.16.3.1), if configured, and hope it gets to its destination.

share|improve this answer
add comment

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 255.25.255.0 can be used.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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