IP Assignment

Before you start

Objectives: learn when we should use static and when dynamic IP assignment. Learn what is DHCP, how do hosts obtain IP lease, when is APIPA used and what is Alternate IP Configuration.

Prerequisites: you should know what is IPv4 address and what is IPv6 address.

Key terms: DHCP, address, server, host, APIPA, lease, static, alternate, IPv6


Static Assignment

If we’re using the static IP address assignment, we have to visit each host on our network and configure four main parameters. First of all, we have to give each host an IP address, then we have to give each host the appropriate Subnet Mask, then we have to give each host the address of the Default Gateway (Router), and we have to give each host the address of the DNS server. If we work with a very small network of 5 or even 10 hosts, this will work. However, if we have a larger network, this can be a real problem. Every change, such as a new IP address scheme, different subnet masks, different Gateway address, DNS server address change, etc. requires a huge amount of work for network administrators. It’s also inefficient since we have to assign all available addresses for all hosts, regardless of whether they are turned on or not. On the other hand, sometimes we will want to use static assignment, especially when we’re dealing with servers, routers and network printers. We want to assign servers a specific IP address and we don’t want that address to change. We can use static assignment on a network with a very small number of hosts or on networks that don’t change and don’t grow. Static addressing is very susceptible to configuration errors and duplicate IP address configuration errors (two hosts that have been assigned the same IP address). If the network is very large it is really inefficient to manage these addresses statically, so we need to manage them dynamically. For that we can use a DHCP server.

DHCP Server

DHCP stands for Dynamic Host Configuration Protocol. Dynamic assignment ensures that all changes are distributed to all of network hosts the next time they are turned on and they request a new IP address. Another advantage of using dynamic addressing is the fact that it conserves IP addresses. By using DHCP, only those hosts that are turned on and in use actually consume an IP address.

To set up DHCP we have to install the DHCP service on a network server that is never shut down. On the DHCP server we have to configure the IP address information that the DHCP server will give out to network hosts. That’s called a DHCP Scope. DHCP Scope contains things such a range of IP addresses that the DHCP server can give out, the appropriate Subnet Mask, the address of the DNS server and the address of the Gateway. Also, there are bunch of other things that we can distribute with the DHCP server as well. The DHCP server ensures that each client has a unique IP address. The DHCP server can also be configured to not assign specific addresses in the range, or to assign a specific address to a specific host (reservation). DHCP is a TCP/IP protocol. Any client configured to use DHCP can get an IP address from any server configured for DHCP, regardless of operating system.

When we turn on a host which is configured to use DHCP, as it’s booting it sends out a broadcast message called a DHCP Discover broadcast, which goes to every host on the network. The only host that will respond to the DHCP discover broadcast is DHCP server. The DHCP server gets the message, goes through its IP scope, and then sends an offer back called a DHCP Offer message. If there is more than one DHCP server on the network segment, the host gets all DHCP offers from all servers, and then selects the one it wants to accept. Usually it’s the first one that it receives. When the host has decided which offer to accept, it sends a message called DHCP Request message back to the DHCP server that sent that particular offer. Now, this DHCP Request message is a broadcast, which means that it goes out to all the hosts on the network. That way any other DHCP server on the network knows that a host accepted an offer from other DHCP server. Now, after the DHCP server receives a DHCP request message from the host, it sends the DHCP ACK message to the host. DHCP ACK message includes the IP address, the Subnet Mask, the Gateway address, the DNS server address, and any other configuration parameter that we have configured, and which the host can now use. DHCP ACK message also contains an IP address lease. The lease specifies how long the host may use issued IP address. After the lease time expires, it either has to be released or renewed. Periodically and when the client reboots, it contacts the DHCP server to renew the lease on the IP address.

DHCP also has some weaknesses. One of the key one is the fact that it relies on frame-level broadcasts. This is not good since, by default, most Routers are configured not to forward broadcasts. If we have several subnets connected with a Router, we have two options to enable DHCP service on all subnets. One option is to install separate DHCP servers on each network segment. Another option is to configure a Router to forward DHCP broadcast (BootP requests). Most DHCP server packages have some kind of software available that will make that happen. We can also configure a computer for BootP forwarding to request IP information on behalf of other clients. We can use DHCP for large, medium or even small networks.

APIPA

APIPA or Automatic Private IP Addressing is a feature that’s built into Microsoft Windows Operating Systems. Its purpose is to enable the operating system to automatically assign itself an IP address in the event that a DHCP server is down, or is no longer reachable. When the hosts first boot up, they send out a request for a DHCP address. If they can’t reach the DHCP server, APIPA automatically assigns the host an IP address in the range of 169.254.0.0 to 169.254.255.254 (Subnet Mask is 255.255.0.0). This range of IP addresses has been specifically reserved for APIPA. When the host picks an address out of this range, it sends out an ARP on the network segment to check if any other host is already using that IP address. If the response is negative it assigns itself using that chosen IP address.

The goal behind APIPA is to provide a fail over system in case that DHCP server goes down. In theory, APIPA works. All hosts on the network, because the DHCP server is down should automatically assign themselves an address in the APIPA range, which should theoretically allow them to continue communicating. In reality it causes some problems. In real life, if the DHCP server goes down, some hosts will use APIPA address, but some hosts will still have an address from the DHCP server. That way some hosts will be able to communicate only with some hosts (hosts on the same network). For example, hosts which use APIPA will be able to communicate, and hosts which still have an IP address from the DHCP servers will be able to communicate, but hosts with APIPA and hosts with DHCP servers will not be able to communicate. Remember, when troubleshooting, if we see an IP address starting with 169, APIPA was used because the DHCP server wasn’t available. The host only configures the IP address and mask. It does not assign itself the Default Gateway and DNS server addresses. For this reason, APIPA can only be used on a single subnet. APIPA can be used on small networks that don’t use DNS servers or have connectivity outside of the local subnet (like Internet).

Alternate IP Configuration

If Alternate IP Configuration is set, it is used in the case when a DHCP server cannot be contacted. In that case, the static configuration values from Alternate IP Configuration are used. Remember that when we configure an alternate IP address, APIPA is no longer used. For, example we can use an alternate configuration if we have a computer (such as a laptop) that connects to two networks: one with a DHCP server and another without a DHCP server. We can also use it if we want to properly configure the computer in case the DHCP server is unavailable.

IPv6 Address Assignment

IPv6 address and all other information can be statically assigned to host. We differentiate Static Full assignment and Static Partial assignment. In Static Full assignment we set the entire 128 bit IPv6 address (and other information). In Static Partial assignment we only statically assign the prefix of the IPv6 address, while the interface ID uses the modified EUI-64 format which is derived from the MAC address of the interface.

When it comes to automatic configuration of IPv6, it can be done in two ways: stateful or stateless autoconfiguration. Stateful addressing is done by using a DHCP server. IPv6 uses the updated version of DHCP which is often referred to as DHCPv6. DHCPv6 server will provide the IP address, default gateway and other information like the DNS server IP address. This is similar to IPv4 DHCP addressing.

On the other hand, stateless addresses are assigned automatically by the client. In this case the device will use its MAC (hardware) address to create the host portion of the IPv6 address. The network portion of the IPv6 address (network prefix) and Default Gateway is derived from messages sent from IPv6 routers. Routers use Neighbor Discovery (ND) protocol for autoconfiguration. Clients will send “Router solicitation (RS)” messages to the router to request the router to respond. The router will then send “Router advertisement (RA)” message back to the client to inform it about the IPv6 subnet prefix and the default gateway address. Note that ND protocol does not provide the client with DNS server information or other information besides the IP address and the default gateway. If we want to provide that information as well, we have to use a DHCPv6 server in Stateless mode. Stateless DHCPv6 will only provide the DNS server IP address to the clients, and that’s it. Other information is configured by using stateless autoconfiguration. Note that stateless addresses are not maintained in any type of record.

Examples

We have separate articles which describe where and how to configure TCP/IP settings in XP, and how to configure TCP/IP in Vista.

Remember

When managing IP addresses on IP network, we basically have two options. We can either statically assign IP addresses, or we can use DHCP to automate the process. A DHCP server is a special server configured to pass out IP address and other IP configuration information to network clients.The assignment is called a lease, and includes a lease time that identifies how long the client can use the IP address. APIPA is a feature that’s built into Windows Operating Systems that enable the operating system to assign itself an IP address in the event that a DHCP server is unreachable. When Alternate IP Configuration is used, APIPA is disabled.