How to configure DHCP server on Windows server 2012

Introduction: Dynamic Host Configuration Protocol (DHCP) is usually used in large-scale local area network environments. Its main function is to centralize management, assign IP addresses, and enable hosts in the network environment to dynamically obtain IP addresses, gateway addresses, DNS server addresses, etc. information, thereby increasing the utilization rate of IP addresses.

Before officially configuring the DHCP server, let's first understand DHCP.

1. Advantages of DHCP
1. Dynamic allocation of IP addresses can improve the utilization rate of IP addresses, because IP addresses are dynamically allocated, rather than assigned to a certain client.
2. It can reduce the maintenance workload of the administrator, and the user does not need to care about the concept and configuration of the network address, and binds the IP address and the MAC address, and there is no problem of stealing the IP address.
3. Administrators can centrally specify general and subnet-specific TCP/IP parameters for the entire network, and can define client parameters using reserved addresses.
4. Provide safe and reliable configuration. DHCP avoids configuration errors caused by manually entering the IP address on each computer, and can also prevent IP conflicts caused by computers on the network configured with the same IP address.
5. When the client moves between subnets, the old IP address will be automatically released for reuse. When the client is started again, the DHCP server will automatically reconfigure the TCP/IP protocol attribute information for the client.

2. Working principle of DHCP
DHCP adopts client/server working mode. The DHCP server is used to maintain TCP/IP configuration information and provide IP address configuration to DHCP-enabled clients in the form of leases.

When the DHCP-enabled client starts for the first time and tries to join the network, the following operations are performed:
1. The DHCP client broadcasts a DHCP Discover message on the network to request an IP address from the DHCP server.
2. Each DHCP server will receive the request and respond with a DHCP Offer message, which contains the IP address and configuration information leased to the client.
3. After receiving the DHCP Offer messages sent by all DHCP servers, the client will only select one of the DHCP Offers, and will send a DHCP Request broadcast packet to the network, which will specify the IP address provided by which server to accept.
4. The DHCP server that receives the DHCP Request message will assign the IP address to the client, and send a DHCP Ack message to approve the lease, and other DHCP option information is also included in this message.
5. Once the client receives the reply, it configures its TCP/IP properties with the DHCP option information in the reply and joins the network.

3. The IP scope of the DHCP server
The IP scope of the DHCP server is the scope for assigning IP addresses to clients in a specific subnet, such as 10.10.31.1~10.10.31.254.

The DHCP server uses the IP addresses defined in the scope to assign to DHCP clients. Therefore, we must create scopes in order for the DHCP server to assign IP addresses to DHCP clients.

4. The concept of DHCP relay agent
A DHCP relay agent is a program that can realize processing and forwarding between different subnets and physical network segments.

If the DHCP client and the DHCP server are on the same physical network segment, the client can correctly obtain the dynamically assigned IP address. If they are not on the same physical network segment, a DHCP relay agent is required.

5. The working principle of the DHCP relay agent
1. When the DHCP client starts and performs DHCP initialization, it will broadcast a configuration request message on the local network.
2. If there is a DHCP server in the local network, the DHCP configuration can be performed directly without a DHCP relay agent.
3. If there is no DHCP server in the local network, after receiving the broadcast message, the network device connected to the local network with DHCP relay agent function will process it properly and forward it to the designated DHCP server on other networks.
4. The DHCP server performs corresponding configuration according to the information provided by the DHCP client, and sends the configuration information to the DHCP client through the DHCP relay agent to complete the dynamic configuration of the DHCP client.

After we understand DHCP, now we will officially start configuring the DHCP server. Subsequent operations are performed on the virtual machine.

Here I divide the configuration process we need to complete today into the following 7 small tasks:
1. Project environment settings.
2. Install the DHCP server.
3. Create an IP scope.
4. Configure DHCP scope options.
5. Configure the DHCP client.
6. Configure DHCP reservation.
7. Configure the DHCP relay agent.

First of all, we still need to complete the environment settings of the project. We need at least three virtual machines here, a DHCP client (I use win10 system here, of course, you can also use win7, the same effect) and two running Windows server 2012 The virtual machines of the system, one acts as a DHCP server, and the other acts as a DHCP relay agent.

Because we want to simulate that the client and the DHCP server are not on the same physical network segment, we need to use the network adapter of the LAN segment of the virtual machine here.

We click on the virtual machine (M) in the upper left corner, and then click Settings to enter our virtual machine settings window:
insert image description here

After entering the settings window, click on the network adapter, then click on the LAN section to enter the global LAN section:
insert image description here

After entering the global LAN segment, we click Add, add two LAN segments, and then click OK, so that we have two LAN segments:
insert image description here
insert image description here

Then we select LAN segment 1 and click OK:
insert image description here

Here we have set up the adapter of the DHCP server, and then we need to set the same adapter for the DHCP client as LAN segment 1:
insert image description here

This is the configuration when we don’t need to configure the DHCP relay. It is not the configuration when the DHCP relay is configured later. It needs to be changed! ! !

Here our basic environment settings have been set up, and then we start the second small task: install the DHCP server.

First of all, we still open the server manager on the server side, and then add roles and functions:
insert image description here

Next step:
insert image description here

Next step:
insert image description here

Continue to the next step:
insert image description here

Check the DHCP server:
insert image description here

Add function:
insert image description here

When adding functions, the following interface may appear. This is because we have not configured a fixed IP address for the server. We will set an IP address for the server later. Of course, we must click to continue here:
insert image description here

After adding the function, we still go to the next step, here we also continue to the next step, no need to check any functions:
insert image description here

Continue to the next step:
insert image description here

Finally we click Install:
insert image description here

This way our DHCP server is installed. We didn’t configure the IP address just now, so we configure the IP address now. Here I configure 10.10.31.1:
insert image description here

Now that our DHCP server is also installed, let's move on to the third small task: creating an IP scope.

We select the tool in the server management window, and then click the DHCP option to enter the DHCP window:
insert image description here

After entering the window, we right-click IPV4 in the upper left corner, and then click New Scope to enter the New Scope wizard:
insert image description here

After entering, we click Next:
insert image description here

Then enter the name and description and continue to the next step to set the IP address range:
insert image description here

The IP address range I set here is 10.10.31.1~10.10.31.254, and then we don’t need to touch the following data, and then click Next:
insert image description here

Now we set the address that is not allowed to be used by the client, and leave the IP addresses in 10.10.31.1~10.10.31.20 for the server to use. After we enter it, click Add (you can also set other IP address ranges):
insert image description here

After the addition is complete, we continue to the next step (of course, we can delete it if we make a mistake here):
insert image description here

Then let's set the lease period, which is eight days by default (you can also set it to one day or other time), click Next:
insert image description here

Now enter the configure DHCP option window, we will not configure it here, so we choose No here, I want to configure these options later, and then the next step:
insert image description here

Finally we click Finish:
insert image description here

Here our scope is created:
insert image description here

Then we need to activate the scope, right-click on the scope (10.0.0.0), and click Activate:
insert image description here

Here we have completed the small task of creating an IP scope! ! !

Ok, now let's complete the fourth small task: configure DHCP scope options.

We right-click the scope option in the DHCP window, and then click the configuration option to enter the scope option window:
insert image description here

After entering, we select the 006DNS server check box, and then enter the DNS server address in the IP address edit box. Here is the address of the current server that I entered ------10.10.31.1. After inputting, click Add to add this IP address, and click OK:
insert image description here

The configuration of the scope is relatively simple. Now let’s configure the client, which is also very simple. It is the default option of the computer. Let the adapter automatically obtain the IP address and the DNS server address automatically, and that’s it:
insert image description here

Then let's test whether the setting is successful, open the command prompt window, enter ipconfig, and see if the IP is successfully assigned. I have not assigned it here:
insert image description here

If the allocation is not successful, we can enter ipconfig /release to release the previous IP address, and then execute ipconfig /renew to reapply for the IP address:
insert image description here
insert image description here

Here our IP address has been assigned! ! ! We can also go back to the DHCP server to see information such as the client's IP address, computer name, and lease time.

We click on the address lease in the DHCP window of the server, and we can see:
insert image description here

Our clients have been able to assign IP addresses, don't you feel very proud? Then we now complete the sixth small task: configuring DHCP reservations.

Configuring DHCP reservations can ensure that DHCP clients always use the same IP address. The working principle of DHCP reservation is to bind an IP address in the scope to the MAC address of a certain client (that is, the physical address of our computer), so that the network adapter with this MAC address can get the same IP address every time. IP address.

First, let’s get the MAC address of the DHCP client. We enter ipconfig /all in the command prompt window and press Enter. Our MAC address here is 00-0C-29-80-CD-9C:
insert image description here

After knowing the physical address, we go back to the server, right-click reservations in the DHCP window, and then click New reservation to enter the New reservation window:
insert image description here

Then enter the name, IP address, and MAC address. The description can be written or not, and click Add:
insert image description here

Here our reservation is created:
insert image description here

Let's test it here, our current IP address is 10.10.31.21:
insert image description here

Then we release the IP address first, and then reapply for the IP address. Released twice in total, and reapplied twice to see if the IP addresses of the two applications are both 10.10.31.88, this is the first time:
insert image description here

This is the second time:
insert image description here

The IP addresses are all the same, indicating that our DHCP reservation has been configured successfully.

We have completed the first six small tasks, now we will complete the seventh project, which is our last project today: configure DHCP relay agent.

Now we are going to use another virtual machine with Windows server 2012 system. Our server needs two network adapters. The first adapter is set to LAN segment 1, and the IP address is set to 192.168.88.254. The second adapter is set to LAN segment 2 with an IP address of 192.168.100.254.

We configure the virtual machine just started, still the same upper left corner, click the virtual machine and then click Settings to enter the virtual machine settings, and then we click Add in the lower left corner to enter the Add Hardware Wizard:
insert image description here

Then we click on the network adapter, and then click Finish:
insert image description here

So we have two network adapters:
insert image description here

Now that we have the adapter, let’s set up the network connection method. The first one is set to LAN segment 1, the second one is set to LAN segment 2, and finally we click OK:
insert image description here
insert image description here

Now that the adapters are set up, let's set the IP address. The first adapter (that is, our LAN segment 1 adapter) has an IP address of 192.168.88.254:
insert image description here

The second adapter (aka our LAN segment 2 adapter) has an IP address of 192.168.100.254:
insert image description here

In this way, the basic configuration of the DHCP relay agent server we will use will be fine. Because we want to simulate a DHCP server and a DHCP client that are not on the same network segment, so next we have to change the adapter of the previous DHCP server to LAN segment 2:
insert image description here

Finally, we need to change the IP address of the DHCP server to 192.168.100.1, and the gateway is 192.168.100.254 (that is, the IP address of our DHCP relay server LAN segment 2 adapter):
insert image description here

The environment for this task has been set up, now we are going to officially configure it! ! !

We need to add a new scope, the address pool is 192.168.88.20~192.168.88.200, which is used to assign to DHCP clients in another subnet. I put the picture directly here:
insert image description here
insert image description here
insert image description here
insert image description here
insert image description here
insert image description here

Don't forget to activate after adding it! ! !
insert image description here

Here our new address pool has been created, and then we need to configure the IP address of the router for the created address pool, set it to 192.168.88.254:
insert image description here

In this way, our server-side configuration is fine. Now let’s configure the server of the relay agent, because we need remote access service support to implement the DHCP relay agent function, so we need to install the remote access service first.

We open the server window in the DHCP relay agent server, and then install the remote access function, because everyone should know the installation function, so I will directly put the picture here:
insert image description here
insert image description here
insert image description here
insert image description here
insert image description here
insert image description here

insert image description here
insert image description here
insert image description here
insert image description here
insert image description here

When we have installed it, we click on the tool in the upper right corner, click on routing and remote access:
insert image description here

Right-click on the server name, select Configure and Enable Routing and Remote Access to enter the Routing and Remote Access Server Setup Wizard:
insert image description here

Next step:
insert image description here

Select custom configuration, then the next step:
insert image description here

Now select the LAN route, then the next step:
insert image description here

Finally click Finish:
insert image description here

Then enable the service:
insert image description here

After the service is enabled, the Routing and Remote Access window will pop up. We first click on the local server name, then click on IPV4, right-click on General, and then select New Routing Protocol to enter the New Routing Protocol window:
insert image description here

Select DHCP Relay Agent, confirm:
insert image description here

In this way, we have a DHCP relay agent, and then we right-click on the DHCP relay agent and select New Interface:
insert image description here

We first select Ethernet0, and then confirm:
insert image description here

Default option, then OK:
insert image description here

Then add Ethernet1 (directly put the picture) as the above operation:
insert image description here
insert image description here

The interface is added. Now let’s set the DHCP server address. In the properties of the DHCP relay agent, right-click the DHCP agent, and then click Properties to enter the DHCP agent properties dialog box:
insert image description here

Then enter the address of the DHCP server, add it, and confirm it:
insert image description here

The relay agent is also configured, we should test it now, open the DHCP client, first confirm whether the network adapter is set to LAN segment 1, and whether the IP address is set to obtain automatically:
insert image description here
insert image description here

I have no problem here, and then let's see if the IP address request is successful, and get the IP address before releasing it:
insert image description here

Then request the IP address:
insert image description here

As you can see, our IP address has been requested successfully! ! ! We have also completed the seventh small task. What needs to be reminded here is that in the DHCP relay server, the IP address of the adapter must not be wrongly assigned, otherwise it will not be able to request it! ! !

Guess you like

Origin blog.csdn.net/weixin_43635067/article/details/128176243