Next Previous Contents

2. IP addresses and host names

2.1 IP address and subnet mask

The first problem encountered is how do I address a computer. Just as we give names to people, each computer recieves a unique IP address. For example, my computer is 18.242.2.23. Given that number, anyone on the Internet can reach out and touch my computer, except my computer probably won't respond. For people with dialup Internet access, you're IP address changes each time you connect.

An IP address is refresented by 4 numbers, delimited by periods. The range for each number is 0-255. For those computer savvy people, you realize that these are 8 bit integers. Basically, each IP address is just a 32 bit field, but to make it easier for humans to understand, it is broken down into 4 8-bit integers. For those not so computer savvy, this means that the valid range of IP address is 0.0.0.0 to 255.255.255.255. This notation is also called "dotted decimal notation".

Back in the days before 386's and 286's (yes, you were born), the people who made the internet had to decide how to give out these IP addresses. What they arrived at is to slice up the consecutive IP addresses into groups. Then, when someone wanted IP addresses, they woul be handled a group of IP addresses.

Essentially, there are 3 groups or classes: A, B, and C. The different classes only differ in the number of IP addresses in each group. For example, MIT has a class A network 18.*, this means that they "own" all IP addresses from 18.0.0.0 to 18.255.255.255. This translates to enough IP addresses for 16,581,375 computers. 16 million computers is probably enough for a city, let alone a school. But in reality this wide range of addresses is used to build a good structured network with a couple of subnets. Class B networks are smaller, with 65,025 IP address. Class C networks, the smallest, have 255 addresses. For those of you who want more current information check out RFC 1918.


Class Netmask       Network Addresses
  A   255.0.0.0     0.0.0.0    - 127.255.255.255
  B   255.255.0.0   128.0.0.0  - 191.255.255.255
  C   255.255.255.0 192.0.0.0  - 223.255.255.255
Multicast 240.0.0.0 224.0.0.0  - 239.255.255.255 

The Netmask is the part of a network address that defines the netblock. The netmask might seem pretty odd with all the 255's. To make sense, it needs to be converted to binary.


               Dot Notation    Binary notation
Netmask        255.0.0.0       1111-1111-0000-0000-0000-0000-0000-0000
Subnet Mask    255.255.0.0     1111-1111-1111-1111-0000-0000-0000-0000
IP             18.242.3.42     0001-0010-1111-0010-0000-0011-0010-1010

Here the netmask shows that for the IP 18.242.3.42, the Net part is 18. Basically this shows that 18.* is a netblock, more specifically a Class A netblock.

The next question is to know what is the network part of an IP address and what the host part (the network part is the same for all computers within the same subnet). You've to define a special number in IP address format, the subnet mask. Combine this number by a logical AND with the IP address and the result is your network address:


     IP address     192.168.123.1
AND subnet mask     255.255.255.0
                    -------------
network address     192.168.123.0

2.2 Valid IP-address ranges for local networks

And there are some address ranges reserved for private LAN's. If you use such an address range for your TCP/IP LAN you won't have any conflict with internet addresses:


10.0.0.0    - 10.255.255.255  (Class A network)
172.16.0.0  - 172.31.255.255  (Class B network)
192.168.0.0 - 192.168.255.255 (Class C network)

There are however, many special IP addresses. For example 127.0.0.1 is referred to as the loopback address. Basically, anything sent to 127.0.0.1, is never actually sent out, but returned back. The purpose of this is for people to test their network services, such as their web server. There are some other special ips for special uses, such as the broadcast ip.

2.3 Host names

Now, let's assume that every computer has an IP address, and everyone is happily connected. I can now get school info from 18.69.0.3. Check my mail at 207.82.250.251. Grab gaming news at 207.38.120.69. This is all fine and dandy if we could remember numbers all that well. Could you imagine a company advertising their website as a set of 4 numbers? People don't want to type in 204.71.200.69 to go to Yahoo.

The solution was to use hostnames. So now, Yahoo can advertise their website as www.yahoo.com and not an IP address. However, the Internet still runs on TCP/IP, so there must be a way of converting a hostname (ie. www.yahoo.com) to a IP address (ie. 204.71.200.69). To do this, your computer goes through several sources, the two important ones being the HOST file (on WIN95/98/NT) and the DNS server.

The DNS server is a computer who's duty it is to remember hostnames and their IP address. When you tell your web browser to go to www.yahoo.com, your computer realizes that it doesn't know Yahoo's IP address, so it asks the DNS sever what the IP address is. The DNS server then goes through it's database to see if it knows.

If it does, it tells your computer IP address for www.yahoo.com. Well, what happens if it doesn't? That's where the great fun of internet regulation comes in.

2.4 Host names and domains

A name, such as www.yahoo.com, breaks down into 2 sections: the host name, and the domain name. The host name is basically everything before the first ".". For www.yahoo.com, it is the www. Everything else is called the domain name -- here, the yahoo.com part.

For longer ones, such as phobos.math.mit.edu, the phobos is the hostname, and the math.mit.edu is the domain name. One difference between hostname and domain name is who controls them. Domain names have to be registered with an Internet regulation company, generally InterNIC. Where as host names can be given at liberty by the owners of the domain name.

The DNS (Domain Name Service)

Let's say that you wanted to start a web server called, "www.myownpi3webserver.org". Then you would have to register "myownpi3webserver.org" with InterNIC. After that, you would have to setup a DNS (technically 2, due to a bunch of weird regulations) for "www.myownpi3webserver.org". The reason for this, is that if someone is going to "www.myownpi3webserver.org", but the DNS realizes that it doesn't know what www.myownpi3webserver.org is. Then it checks to see if it knows myownpi3webserver.org. If it also doesn't know that, it asks the top level DNS servers, what the ip to the DNS for myownpi3webserver.org is. Then using that, it asks myownpi3webserver.org's DNS what the IP to www.myownpi3webserver.org is.

Hosts file

Now let's say that you want to locally access your own web server, but you don't like to type in http://localhost/ or http://127.0.0.1/. Instead, you would much be happier typing in http://popcorn/. Well, generally this means that you would put an entry into the DNS that points popcorn to your IP address. But most people don't have acceess to change the DNS, or you might not be connected to the network at that time.

If you're running Win95 or WinNT, there is the HOSTS file in the windows directory, that basically acts like a DNS. In the file, it lists IP addresses, and their related name. Whenever you type in a name into your web browser, the OS goes throught the HOSTS file before it starts using any DNS; however, since this local file, the entries in this file only affect your computer.


IP Address         HostName        Alias1        Alias2
127.0.0.1          localhost       popcorn

So if you want to locally access your computer as pi3, then you would add an entry that points pi3 to 127.0.0.1.


Next Previous Contents