Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

DHCP relay service (full experiment, can be followed)

2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/02 Report--

DHCP Relay Service Experiment

Before we start, let's take a look at DHCP services.

DHCP is a protocol designed to automatically assign TCP/IP parameters to computers in TCP/IP networks. DHCP avoids errors caused by manually setting IP addresses and address conflicts caused by assigning the same IP address to multiple users. DHCP provides secure, reliable, and simple TCP/IP network setup, reducing the burden of configuring IP addresses.

DHCP Network Structure Diagram

Advantages of DHCP:

Reduce the workload of administrators.

Avoid the possibility of typing errors.

Avoid IP address conflicts.

When the network changes IP address segments, there is no need to reconfigure each user's IP address.

Improved IP address utilization.

Easy client configuration.

DHCP assignment: DHCP provides three IP assignment methods.

1)Automatic allocation: DHCP server assigns a permanent IP address to the host. Once DHCP client successfully leases the IP address from DHCP server for the first time, it can use the address permanently.

2)Dynamic allocation method: DHCP server assigns a IP address with time limit to host, and when the time expires or the host explicitly indicates that the address is abandoned, the address can be used by other hosts.

3)Manual allocation: The IP address of the client is specified by the network administrator, and the DHCP server simply tells the client host the specified IP address.

Lab hardware requirements: VMware Workstation and GNS3 with CentOS 7 and two win10 installations.

Lab Step 1: GNS3 Topological Graph Planning

First go into GNS3 and drag out two routers and three PCs (select host), then configure the two routers.

One is renamed SW1, and the icon is changed to a Layer 3 switch, and a Layer 2 service board is added as a Layer 3 switch.

One is renamed sw2, and the icon is switch, and a layer 2 service board is added as a layer 2 switch.

Change the icon of a PC to sever as DHCP server. The other two remain unchanged.

Then connect the device and display the interface.

DHCP VMnet1 connects to SW2 f1/1 interface.

VMnet2 of win10-1 connects to f1/2 interface of sw2.

VMnet8 of win10-2 connects to f1/3 interface of sw2.

sw2 interface f1/0 connects sw1 interface f1/0.

Divide vlan and plan gateway

Win10-1 corresponds to vlan10: 192.168.10.1;win10-2 corresponds to vlan20: 192.168.20.1;DHCP corresponds to vlan30: 192.168.30.1.

The planning results are shown in the figure below

.

Lab Step 2: Configure the Switch Interface

Configuration of SW2 Layer 2 Switch Interface

enter this sequence of commands

conf t (enter global mode)

vlan 10, 20, 30 (enter vlan mode and create three vlans)

ex (exit vlan mode)

do show vlan-sw b (see vlan configuration results)

int f1/1 (enter sw2f1/1 interface)

sw mo acc

SW ACC VLAN 30 (dividing F1/1 interface to VLAN30)

ex (exit interface)

int f1/2 (enter sw2f1/2 interface)

sw mo acc

sw acc vlan10 (divide interface f1/2 to vlan10)

ex (exit interface)

int f1/3 (enter sw2 interface f1/3)

sw mo acc

sw acc vlan20 (divide interface f1/3 to vlan20)

ex (exit interface)

do show vlan-sw b (see vlan configuration results)

int f1/0 (enter interface f1/0)

sw mo trunk

sw trunk encapsulation dot1q

no ip routing

Configuration of SW1 Layer 3 Switch Interface

enter this sequence of commands

conf t (enter global mode)

vlan 10, 20, 30 (enter vlan mode and create three vlans)

ex (exit vlan mode)

do show vlan-sw b (see vlan creation results)

int f1/0 (enter interface f1/0)

sw mo t (configure trunk link)

sw t en dot (encapsulated dot1q protocol)

do show int f1/0 switchport

int vlan 10 (enter virtual interface vlan10)

ip add 192.168.10.1 255.255.255.0 (configure vlan10 gateway and subnet mask)

no shut (start)

int vlan 20 (enter virtual interface vlan20)

ip add 192.168.20.1 255.255.255.0 (configure vlan20 gateway and subnet mask)

no shut (start)

int vlan 30 (enter virtual interface vlan30)

ip add 192.168.30.1 255.255.255.0 (configure vlan30 gateway and subnet mask)

no shut (start)

show ip int b (view configuration results)

Lab Step 3: Set up the network configuration of the three PCs

First install dhcp service for CentOS 7 in networked state using yum source.

Command: yum install dhcp -y

After installing DHCP, adjust the network adapter connection mode to host mode, and then configure its ENS33 network card.

Command: vim /etc/sysconfig/network-scripts/ifcfg-ens33

After entering the network configuration file, configure the ENS33 network card.

dhcp changed to static (automatic ip assignment changed to manual configuration)

IPADDR=192.168.30.30 (IP address)

NETMASK=255.255.255.0 (subnet mask)

GATEWAY=192.168.30.1 (gateway)

:wq (save and exit)

systemctl restart network

ifconfig (view configuration results)

The following is the configuration of dhcp

cp /usr/share/doc/dhcp-4.2.5/dhcpd.conf.example /etc/dhcp/dhcpd.conf (duplicate/usr/share/doc/dhcp-4.2.5/dhcpd.conf.example to/etc/dhcp/dhcpd.conf)

yes (confirm override)

vim /etc/dhcp/dhcpd.conf (into configuration file)

After entering, find the first subnet to modify

subnet 192.168.10.0 network 255.255.255.0 {

range 192.168.10.128 192.168.10.200;(DHCP automatically assigns address range)

option routers 192.168.10.1;

}

Because we have three vlans in total, we need to match three

4yy p Copy the first configure the second

subnet 192.168.20.0 network 255.255.255.0 {

range 192.168.20.128 192.168.20.200;(DHCP automatically assigns address range)

option routers 192.168.20.1;

}

4yy p Configure the third

subnet 192.168.30.0 network 255.255.255.0 {

range 192.168.30.128 192.168.30.200;(DHCP automatically assigns address range)

option routers 192.168.30.1;

}

:wq (save and exit)

systemctl start dhcpd

systemctl status dhcpd

CentOS 7 configuration completed, the following is the configuration of two win10 network adapters

Win10-1 network adapter mode to VMnet2 host-only mode

Win10-2 network adapter mode to VMnet8 host-only mode

Lab Step 4: Configuring DHCP Relay

We know that normal vlans block broadcasts, but here we need to only let DHCP broadcast packets cross to different vlans and assign them different vlanIPs, so we need to configure dhcp relay services in sw1.

enter this sequence of commands

conf t

int vlan 10

ip helper-address 192.168.30.30

no shut

ex

int vlan 20

ip helper-address 192.168.30.30

no shut

ex

int vlan 30

ip helper-address 192.168.30.30

no shut

ex

Experiment Step 5: Verify the test results

Use two win10 to see if you can get an IP address automatically.

Experimental results: two win10 can get IP address through dhcp relay service and can be interconnected.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report