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

[large-scale Zhenxiang site] DHCP relay service experiment (full operation, you can follow! )

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

Share

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

This time we are conducting experiments on DHCP relay service.

Lab environment: Software preparation GNS3, CRT, and VMware virtual machines with CentOS 7 and WIN10 installed as mentioned in my previous article

First, we enter the GNS3 interface, click the router icon on the left, drag two routers to the topology operation area, click the PC icon, select HOST, drag three PCs to the topology operation area, and configure the two routers (change the icon to switch, change the device name to sw2/sw3, add a layer 2 service board, and set the disk space to 128Mb).

The GNS3 topology graph requires:

1. Three hosts:

One was renamed DHCP and its icon was changed to sever server.

The default configuration of the other two devices remains unchanged, and the device names are changed to win10-1 and win10-2 respectively.

2. Two routers:

Change the name of one SW2, change the icon to switch, modify the configuration to add a layer 2 service board, and set the disk space of the switch to 128Mb.

One is renamed sw3, the icon is changed to a Layer 3 switch, the configuration is modified to add a Layer 2 service board, and the disk space of the switch is set to 128Mb.

The following is the way to connect:

1. DHCP VMnet1 to SW2 f1/1

2. VMnet2 of win10-1 to f1/2 of SW2

3. VMnet8 of win10-2 to f1/3 of SW2

f1/0 of SW2 to f1/0 of SW3

After the connection is complete, all ports are displayed

Next we want to divide the VLAN:

Win10-1 is vlan10.

Win10-2 for VLAN20

DHCP is vlan100.

Edit the gateway settings on the side:

1、win10-1:192.168.10.1/24

2、win10-2:192.168.20.1/24

3、DHCP:192.168.100.1/24

Details are as follows:

We know that normal vlan blocks broadcast, but here we need to only let DHCP broadcast packets cross, go to different vlan, assign them different vlanIP, so here we need to DHCP relay settings on the gateway, next we first turn on all devices:

Let's go back to VMware virtual machines and set up the network adapters for the three hosts:

1. CentOS 7: Install dhcp service software package using yum repository online

Input: yum install dhcp -y (no interactive install mode)

Set up the ENS33 network card after installation

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

Input: /dhcp (change dhcp to static here)

Press: Big G to Last Line

Press: o to go down and insert

Input: IPADDR=192.168.100.100 (IP), press o to go down

Enter NETMASK=255.255.255.0 (subnet mask), press o to go down

Input: GATEWAY=192.168.100.1 (gateway)

Press Esc to exit insert mode

Input: wq (save exit)

The operation and results are as follows:

Next is the DHCP configuration process:

Input: cp /usr/share/doc/dhcp-4.2.5/dhcpd.conf.example /etc/dhcp/dhcpd.conf

Input: yes (confirm override)

Enter: vim /etc/dhcp/dhcp.conf (configuration file into DHCP)

Find: the first subnet (modify, we have a total of three vlan needs to do three)

Change to subnet 192.168.10.0 netmask 255.255.255.0

Downstream input: range 192.168.10.128 192.168.10.200;

Go to the following input: option routers 192.168.10.1;

Note: The ";" sign behind the address and gateway here must not be less, this is a fixed format

Press "4yy" at the first line subnet to copy the four lines

Press p to paste the copied content one line below the braces (copy and paste twice in succession)

Subnet 192.168.20.0 netmask 255.255.255.0

Downstream input: range 192.168.20.128 192.168.20.200;

Go to the following input: option routers 192.168.20.1

Third place; read subnet 192.168.100.0 netmask 255.255.255.0

Downstream input: range 192.168.100.128 192.168.100.200;

Go to the following input: option routers 192.168.100.1

Input: wq (save exit)

Input: systemctl start dhcpd

Enter: systemctl status dhcpd

At this time, it displays: active (active status, indicating that the service is successfully started)

The operation and results are as follows:

Then set the network adapter to custom vmnet1 host-only mode,

Win10-2: Set the network adapter to custom vmnet2 host-only mode

Win10-1: Set the network adapter to custom vmnet8 host-only mode

Then go back to GNS3 and double-click to open SW2 (Layer 2 switching) configuration port:

sw2

Input: conf t

Input: vlan 10, 20, 100

Input: ex

Input: do show vlan-sw b (view vlan)

Input: int f1/1

Input: sw mo acc

Input: sw acc vlan 100

Input: ex

Input: int f1/2

Input: sw mo acc

Input: sw acc vlan 10

Input: ex

Input: int f1/3

Input: sw mo acc

Input: sw acc vlan 20

Input: ex

Input: int f1/0

Input: sw mo trunk (set Trunk mode)

Input: sw trunk encapsulation dot1 q

Input: ex

Input: no ip routing

The operation and results are as follows:

Double-click to open SW3 (Layer 3 Switch) Configuration Port and Trunk:

Reminder: Because this device is a Layer 3 switch, it is used for routing conversion, so the routing function does not need to be turned off here.

sw3

Input: conf t

Input: vlan 10, 20, 100

Input: ex

Input: do show vlan-sw b (view vlan)

Input: int f1/0

Input: sw mo trunk

Input: sw t en dot

Input: ex

Input: do show int f1/0 switchport (you can see that the mode is Trunk)

Input: int vlan 10 (into virtual interface)

Input: ip add 192.168.10.1 255.255.255.0

Input: no shut

Input: ex

Input: int vlan 20 (into virtual interface)

Input: ip add 192.168.20.1 255.255.255.0

Input: no shut

Input: ex

Input: int vlan 100 (into virtual interface)

Input: ip add 192.168.100.1 255.255.255.0

Input: no shut

Input: end

Input: show ip int b

The operation and results are as follows:

DHCP relay is then configured in gateway interface sw3, since only gateways control isolation and release of broadcasts.

sw3

Input: conf t

Input: int vlan 10

Input: ip helper-address 192.168.100.100

Input: no shut

Input: ex

Input: int vlan 20

Input: ip helper-address 192.168.100.100

Input: no shut

Input: ex

Input: int vlan 100

Input: ip helper-address 192.168.100.100

Input: no shut

Input: ex

The operation and results are as follows:

The next step is to verify whether each host can obtain the IP address of the corresponding network segment:

Enter win10-1:

Enter the network adapter first and set IPv4 to auto-fetch status.

Open cmd command with administrator privileges

Input: ipconfig /release (release IP address pool)

Input: ipconfig /renew (get new IP address)

The new IP address obtained is: 192.168.10.128

Go back to Win10-2.

Or go to the network adapter first and set IPv4 to auto-fetch state

Open cmd command

Input: ipconfig /release (release IP address pool)

Input: ipconfig /renew (get new IP address)

The new IP address obtained is: 192.168.20.128

We can test whether the two hosts can communicate with the 192.168.100.100 segment with ping command

Enter: ping 192.168.100.100

At this time, four packets should be successfully sent, indicating that the whole network is interconnected.

The above is the DHCP relay service experiment of the whole process, the whole operation, we can follow, thank you for watching!

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