## Geek School: Learning Windows 7 – IP Addressing Fundamentals

In this edition of Geek School, we are going to look at how IP addressing works. We will also cover some advanced topics like how your PC determines if the device you are communicating with is on the same network as you. We will then finish with a brief look at two name resolution protocols: LLMNR and DNS.

Be sure to check out the previous articles in this Geek School series on Windows 7:

And stay tuned for the rest of the series all week long.

### IP Fundamentals

When you send a letter via snail mail you have to specify the address of the person you would like to receive the mail. Similarly, when one computer sends a message to another computer it needs to specify the address that the message should be sent to. These addresses are called IP addresses and typically look something like this:

192.168.0.1

These addresses are IPv4 (Internet Protocol Version 4) addresses and like most things these days they are a simple abstraction as to what the computer actually sees. IPv4 addresses are 32-bit, which mean they contain a combination of 32 ones and zeros. The computer would see the address listed above as:

11000000 10101000 00000000 00000001

Note: Each decimal octet has a maximum value of (2^8) – 1 which is 255. This is the maximum number of combinations that can be expressed using 8 bits.

If you wanted to convert an IP address to its binary equivalent you could create a simple table, like below. Then take one section of the IP address (technically called an octet), for example 192, and move from left to right checking if you can subtract the number in the header of the table from your decimal number. There are two rules:

• If the number in the header of the table is smaller than or equal to your number, mark the column with a 1. Your new number then becomes the number you had subtract the number in the header of the column. For example, 128 is smaller than 192 so I mark the 128s column with a 1. I am then left with 192 – 128, which is 64.
• If the number is larger than the number you have, mark it with a 0 and move on.

Here is how it would look using our example address of 192.168.0.1

 128 64 32 16 8 4 2 1 1 1 0 0 0 0 0 0 1 0 1 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1

In the above example, I took our first octet of 192 and marked the 128s column with a 1. I was then left with 64 which is the same as the number as the second column so I marked it with a 1 as well. I was now left with 0 since 64 – 64 = 0. That meant that the rest of the row was all zeros.

In the second row, I took the second octet, 168. 128 is smaller than 168 so I marked it with a 1 and was left with 40. 64 was then greater than 40 so I marked it with a 0. When I moved into the third column, 32 was less than 40 so I marked it with a 1 and was left with 8. 16 is greater than 8 so I marked it with a 0. When I got to the 8s column I marked it with 1 which left me with 0 so the rest of the columns were marked with 0.

The third octet was 0, and nothing can go into 0 so we marked all columns with a zero.

The last octet was 1 and nothing can go into 1 except 1, so I marked all columns with 0 until we got to the 1s column where I marked it with a 1.

Note: Subnet masking can get very complex, so for the scope of this article we are only going to discuss classful subnet masks.

255.255.255.0

Which in binary looks like this.

11111111.11111111.11111111.00000000

In a subnet mask the network bits are denoted by the 1s and the host bits are denoted by the 0s. You can see from the above binary representation that the first three octets of the IP address are used to identify the network that the device belongs to and the last octet is used for the host address.

Given an IP address and subnet mask, our computers can tell if the device is on the same network by performing a bitwise AND operation. For example, say:

• computerOne wants to send a message to computerTwo.
• computerOne has an IP of 192.168.0.1 with a subnet mask of 255.255.255.0
• computerTwo has an IP of 192.168.0.2 with a subnet mask of 255.255.255.0

computerOne will first calculate the bitwise AND of its own IP and subnet mask.

Note: When using a bitwise AND operation, if the corresponding bits are both 1 the result is a 1, otherwise it’s a 0.

11000000 10101000 00000000 00000001
11111111 11111111 11111111 00000000

11000000 10101000 00000000 00000000

It will then calculate the bitwise AND for computerTwo.

11000000 10101000 00000000 00000010
11111111 11111111 11111111 00000000

11000000 10101000 00000000 00000000

As you can see, the results of the bitwise operations are they same, so that means that the devices are on the same network.

### Classes

As you probably have guessed by now, the more networks (1s) you have in you subnet mask the less host (0s) you can have.  The number of hosts and networks you can have is divided up into 3 classes.

 Networks Subnet Mask Networks Hosts Class A 1-126.0.0.0 255.0.0.0 126 16 777 214 Class B 128-191.0.0.0 255.255.0.0 16 384 65 534 Class C 192-223.0.0.0 255.255.255.0 2 097 152 254

#### Reserved Ranges

You will notice that the 127.x.x.x range has been left out. This is because the entire range is reserved for something called your loopback address. Your loopback address always points to your own PC.

The 169.254.0.x range was also reserved for something called APIPA which we will discuss later on in the series.

#### Private IP Ranges

Up until a few years ago every device on the internet had a unique IP address. When IP addresses began to run out, a concept called NAT was introduced which added another layer between our networks and the internet. IANA decided that they would reserve a range of addresses from each class of IPs:

• 10.0.0.1 – 10.255.255.254 from Class A
• 172.16.0.1 – 172.31.255.254 from Class B
• 192.168.0.1 – 192.168.255.254 from Class C

Then instead of assigning each device in the world an IP address, your ISP provides you with a device called a NAT Router which is assigned a single IP address. You can then assign your devices IP addresses from the most suitable private IP range. The NAT Router then maintains a NAT table and proxies your connection to the internet.

Note: The IP of your NAT Router is usually assigned dynamically via DHCP so it normally changes depending on the constraints your ISP has in place.

### Name Resolution

It is way easier for us to remember human readable names like FileServer1 than it is to remember an IP address like 89.53.234.2. On small networks, where other name resolution solutions like DNS don’t exist, when you try to open a connection to FileServer1 you computer can send a multicast message (which is a fancy way of saying send a message to each device on the network) asking who FileServer1 is. This method of name resolution is called LLMNR (Link-lock Multicast Name Resolution), and while it’s a perfect solution for a home or small business network it doesn’t scale well, firstly because broadcasting to thousands of clients will take too long and secondly because broadcasts don’t typically traverse routers.

#### DNS (Domain Name System)

The most common method to solve the scalability issue is to use DNS. The Domain Name System is the phonebook of any given network. It maps human readable machine names to their underlying IP addresses using a giant database. When you try to open a connection to FileServer1 your PC asks your DNS Server, which you specify, who FileServer1 is. The DNS Server will then respond with an IP address which your PC can in turn make a connection to. This is also the name resolution method used by the largest network in the world: the internet.

Right click on the network settings icon and select Open Network and Sharing Center from the context menu.

Now click on the Change adapter settings hyperlink on the left hand side.

Now select Internet Protocol Version 4 and then click on the properties button.

Here you can configure a static IP address by selecting the radio button for “Use the following IP address”. Armed with the information above, you can fill in an IP address and subnet mask. The default gateway, for all intents and purposes, is the IP address of your router.

Near the bottom of the dialog you can set the address of your DNS server. At home you probably don’t have a DNS server, but your router often has a small DNS cache and forwards queries to your ISP. Alternatively, you could use Google’s public DNS server, 8.8.8.8.

### Homework

• There is no homework for today, but this has been a long one, so read over it again. If you are still hungry for more information you can read up on an advanced networking subject called CIDR (Classless Interdomain Routing).

Taylor Gibb is a Microsoft MVP and all round geek, he loves everything from Windows 8 to Windows Server 2012 and even C# and PowerShell. You can also follow him on Google+

• Published 03/12/13

1. Tek9

I would have thought there would be some touching on public versus private addressing. I see you pretty much just went with private addresses but didn’t distinguish the fact that you’re solely dealing with private or internal IP addressing. Also at least brush up against real world cases where it’s preferrable to have a static IP (or reserved at the router level) versus a dynamic IP. e.g., Networked printers (those attached directly to a network either via cable or wireless) are better off assigned a static IP (or reserved) address rather than dynamic as not all situations allow you to locate the printer via a hostname only (or even resolve it via that). Otherwise if a network printer gets an IP dynamically, it is eventually going to get a different IP address and then you have to reconfigure all the devices trying to print to it.

It seems you’re trying to steer away from the corporate aspect in regards to not branching out to topics covered in an enterprise environment, but nothing in the article really addresses real world scenarios or information. Essentially it kind of reads like a wikipedia article. Doesn’t help readers that are coming here to learn more about a topic and how they can turn around and use that knowledge for themselves.

2. Chemical

Thank you for the informative article! Also note, OpenDNS is a viable alternative to Google’s public DNS.

3. Taylor Gibb

@Tek9 thanks for your feedback, what you have said is true. However, this is based on what is covered in the 70-680 exam which doesn’t go into the Private vs Public IP ranges. Most environments, as far as desktop users go are behind a NAT firewall anyway.

We will be sure to take this kind of thing into account going forward.

4. TheFu

Nice start to IPv4 networking.
With NAT, most people don’t need to know too much more, unless they run a VPN. When running a VPN, it is critical that the internal addresses – often NAT’d need to be different so routing can be setup through the VPN. THAT means that selecting an unpopular internal network subnet or at least something different between the 2 VPN end-points is critical.

Commonly used tools on Windows for IPv4 networking are:
* ipconfig
* nslookup
* ping
* netstat
* route

Understanding the different notations between 192.168.1.0/24 and 192.168.1.0/255.255.255.0 is helpful too.

IPv6 makes things a little more complex in some ways and a little easier in others. Free IPv6 certifications are available for your time: https://ipv6.he.net/certification/

5. Two Bits

I’m not sure what Tek9 is complaining about. The entire series is a classroom type discussion. So heck yes! this reads somewhat like a Wikipedia article. The concept of what IP’s are, how they are masked and what a DNS server is, is quite a lot for any new comer to swallow. Any other skills like binary to decimal math skills also had to be dealt with (although I’m not sure I liked the way it was done). I’m just thankful we didn’t start getting into what CIDR rules were/are or how to deal with non classfull subnets. However, I suppose port numbers and how many services use them in conjunction with our new found IP networking knowledge will be up next – or coming up pretty soon. Keep it coming. I love being reminded of things like LLMNR (I completely forgot about it).

6. Taylor Gibb

Thanks @Two Bits, we really are trying to cater for everyone! One thing i noticed is that you weren’t sure you liked the way i explained the Dec/Bin conversions, id be very interested to hear why. I thought this was by the easiest explanation i could give, do you use a different method – perhaps the dividing by 2 save the remainder method?

7. Cho

Why is the Dec to Binary illustration even relevant herein?
Though adequately explained, why do we need to know this to understand “IP addressing fundamentals” which is the fabric of the article?

### More Articles You Might Like

• Get exclusive articles before everybody else.