DHCP and fixed IP
Dynamic Host Configuration Protocol

As we already learned in the Private and Public IPs section, every computer interface connected to a Local Area Network must have an unique IP number, such as 192.168.1.100. The IP can be fixed, that means it is always the same, or dynamic, assigned automatically from another machine on the network. The service of offering automatic IPs is called DHCP (Dynamic Host Configuration Protocol) and is runned by a DHCP server. Mostly every LAN, has such a service running. This service do not only assign an unique IP to our machine, but also instructs it about the whole network configuration settings, such as assigning a gateway and DNS servers, virtually connecting a computer to the Internet.

To access such a service, our machine has to perform a DHCP request. Mostly all operating systems perform, by default, such a request automatically each time that a network device is attached. But the automatic request could have been disactivated: in this case we will have to instruct the computer in performing such a request.

In the grafical environement of Microsoft, Macintosh and GNU/Linux operating systems, that is simply done through a mouseclick in the "Network Settings" configuration tool, selecting the DHCP option.

In a GNU/Linux environement, in the shell environement (terminal) the command to perform a DHCP request, is

user@host:~# dhclient


Manual IP assignment

If there is no DHCP service running on our network, than we will have to instruct manually our computer about how to reach the Internet.

The informations needed by a computer to succesfully connect to a TCP/IP network are the following:

  • address
  • gateway
  • netmask (Network Mask)
  • DNS (Name Server)

In addiction to these there could be also a request for:

  • network
  • broadcast

Knowing the IP address of the gateway, we can easily come to all these informations! Otherwise, we should ask for help to somebody familiar with the local network environement.


Quick definition
  • Address: the unique IP number of our computer in a local network
  • Gateway: as we learned in the Private and Public IPs section, any data flowing to/from the Internet will have to pass through the gateway. As the name suggests, the gateway is a machine that acts as a door between our local network and the Internet.
  • Netmask: a network mask is a bitmask used to tell how much of an IP address identifies the network the host is on and how much identifies the host itself.
  • DNS: a Domain Name Server is a machine running a service which virtually translates hard-to-remember IP addresses (such as 83.137.99.39) in easy-to-remember domain names (such as "streambox.org")
Example

Let's assume that we know the gateway IP of the local network: in a typical situation it will be 192.168.1.1, or similar.

The first tree number blocks (192.168.1) define the local network. The last block (.1) defines an unique address. That means, to be able to intercommunicate with the gateway, our computer will need an IP number in the 192.168.1 range but else than .1 (that defines the gateway, of course). Assumed that the number range for every block is 0 to 255, we will choose a number between 192.168.1.2 and 192.168.1.244 for our computer's IP address.

The netmask is normally 255.255.255.0. Only in such a case where gateway IP number blocks that defines local network (the first three ones) are number blocks composed of two numbers (instead of three), such as a gateway IP like 10.0.1.1, than the netmask will be 255.0.0.0, and in this case our computer's IP address will be in a range between 10.0.1.2 and 10.0.1.254

Following the first example, if we are required to define the "network" and the "broadcast" IP numbers, the network IP will be 192.168.1.0 and the broadcast IP will be 192.168.1.255, that is the first and the last possible unique IP addresses on our local network. In fact, the first (.0) and the last (.255) IPs are reserved, that is, we must never use them defining an IP number for a computer.

Let's resume. Assuming we know the gateway IP:

  • gateway IP is 192.168.1.1
  • netmask is 255.255.255.0
  • our computer IP address will be in a range between 192.168.1.2 and 192.168.1.254
  • network IP is 192.168.1.0
  • broadcast IP is 192.168.1.255

In the other case we have seen:

  • gateway IP is 10.0.1.1
  • netmask is 255.0.0.0
  • our computer IP address will be in a range between 10.0.1.2 and 10.0.1.254
  • network IP is 10.0.1.0
  • broadcast IP is 10.0.1.255

And also always remember that every computer must have an unique IP address, so if we choose an IP address that has already been assigned to another machine, our computer will not be able to connect to the network! To prevent such a problem, if you are manually specificating the IP address, prefer numbers in a range between 70 and 99 or similar, because typically already used IPs are between 1/20, 100/120, 150/170 and 200/220.