It is imperative that, when planning your network, you know which IP addresses can be given out to a host. Once you have identified the network address and broadcast address on a network, you can issue an IP address that sits between them to a host device.
Therefore, the first IP address you can issue to a host is the one immediately following the network address. The last IP address you can issue to a host is the one immediately before the broadcast address.
An IP address can either be assigned manually by an administrator or dynamically through Dynamic Host Configuration Protocol (DHCP). We will talk about DHCP in more detail in Chapter 14, Network Services.
Manually assigning an IP address to a Windows computer involves adjusting the IPv4 properties of the NIC itself. Since a device can have more than one NIC, ensure you are configuring the right one. Let's walk through configuring an IP address manually:
- From Control Panel, select Network and Internet:
- Then, select Network and Sharing Center:
- Select Change adapter settings on the left:
- This will present you with adapters you have installed on your device. Note that, on my laptop, I have Bluetooth, a wired connection, and a Wi-Fi connection:
- Right-click on the adapter you want to configure and choose Properties:
- Then, either double-click on Internet Protocol Version 4 (TCP/IPv4) or select it and choose Properties:
- By default, your adapter will be set to obtain an IP address automatically. Note that not only is it getting the IP address automatically but it will also be given a default gateway and DNS settings automatically:
- If you prefer, you can configure the adapter so that it has manual DNS settings:
- You may have noticed that, while you were obtaining an IP address, there was an Alternate Configuration tab. Clicking on it provides us with the option shown in the following screenshot:
This tab details what the computer should do if it cannot obtain an IP address automatically. By default, it will be provided with an Automatic Private IP Addressing (APIPA) address, which always starts with 169.254.x.x. However, you can choose the User configured option to provide it with a static IP address. The latter option is ideal if you use your computer in multiple locations, and in one of those locations you don't have the ability to obtain an IP address automatically. For example, at work, you may want to get an IP address automatically, but at home, you may want a static address.
- If you want to have a static address, select Use the following IP address and enter the required details. Note when doing this that, once you enter the IP address, the subnet mask field auto-populates with a classful subnet mask. Remember to change this as appropriate. Also, the option to obtain DNS server details automatically is no longer available. On selecting this option the Alternate Configuration tab will disappear instantly:
- Fill in the remainder of the details as appropriate. Note that there is an Validate settings upon exit option. This checks whether your settings are correct and will provide an error message if they're not:
- By clicking on the Advanced... button, you are provided with granular control. From here, you can add additional IP addresses and default gateways, and configure a routing metric value:
- Clicking on the DNS tab allows us to configure additional DNS settings, including configuring the order DNS servers are queried in. We will discuss DNS in more detail in Chapter 14, Network Services:
- Clicking on the WINS tab will provide us with the option to configure the Windows Internet Name Service (WINS) settings. Again, this will be discussed in more detail in Chapter 14, Network Services:
- Once you have configured the IP address either automatically or statically and clicked on OK, your computer will send out an ARP request, querying if anyone has that IP address already.
Sometimes, you may find that you have problems with the IP address that's been issued by DHCP. You can ask your computer to either release the IP address or renew the IP address from the command line using ipconfig /release and ipconfig /renew, respectively. Release gives up the IP address and doesn't attempt to get a new IP address; renew also releases the IP address but attempts to obtain an IP address again.
I sometimes find using renew actually fails, but there is no indication if it has failed when it releases the IP address or when it obtains the new IP address. With that in mind, I tend to run release first and then run renew. Yes, I am releasing twice, but I know that if the first command fails, the problem is likely to be on my device. I just want to reiterate that the two commands are for DHCP addresses only. If you have a static IP address, they will not work.