DHCP for network services

principle

1. Dynamic Host Configuration Protocol, application layer protocol, using udp ports 67 and 68,
2. Advantages: reduce the work of administrators, avoid errors and avoid ip conflicts. When changing the ip address segment, there is no need to reconfigure each user's ip address and improve ip utilization
3. Allocation method: automatic allocation. Permanently used after being assigned to an ip address
Manual assignment: specifying
Dynamic allocation:
4. Steps
In the first step, the client searches the network for the server discover
In the second part, the server responds to the service offer to the client
In the third part, the client sends a service request request to the target server
In the fourth part, the server provides service ack to the client
5. In the login process, request directly and the dhcp server sends an ack
If it is occupied by others, re discover it
6. Renewal
50%, the client sends a request to renew the contract, and the server sends an ack. If it is not used, it will continue to be used
87.5% didn't respond before
168.254.0.0/16 when this address appears, the dhcp server makes an error

Configure DHCP

Step 1: yum -y install dhcp
Step 2: add a network card, configure the host only mode, and modify the configuration file so that the computer host can ping


Step 3: dhcp configuration
vim /etc/dhcp/dhcpd.conf


Step 4: start and view the dhcp service

Step 5: verify on Windows 10

Bag grabbing tool

Grab bag
Yum -y install wireshark
Filter with bootp

DHCP Relay

8. dhcp relay agent
Relay principle: when the internal network of an enterprise is playing, VLANs are usually divided and broadcast is isolated. Therefore, the vlan function of the three-layer switch needs to be used for relay agent
Dhcp enable
int vlan 10
Dhcp select relay
dhcp relay server IP 192.168.192.100 specify dhcp web address
Int vlan 20
Dhcp select relay
dhcp relay server IP 192.168.192.100 specify dhcp web address

Enter linux
Enter address pool configuration
Dhclient -d ens33 check the dhcp status of this network card

experiment

First step
Configure dhcp server and switch


Layer 3 switch configuration

[sw2]vlan batch 10 20 100
[sw2]int vlan10
[sw2-Vlanif10]ip ad	
[sw2-Vlanif10]ip address 192.168.10.1 24
[sw2-Vlanif10]int vlan20
[sw2-Vlanif20]ip a 192.168.20.1 24
[sw2-Vlanif20]int vlan100
[sw2-Vlanif100]ip a 192.168.100.1 24
[sw2-Vlanif100]int g0/0/1
[sw2-GigabitEthernet0/0/1]p l t 
sw2-GigabitEthernet0/0/1]p t a v a
[sw2-GigabitEthernet0/0/1]q
[sw2]dhcp enable
[sw2]int vlan10
[sw2-Vlanif10]dhcp select relay
[sw2-Vlanif10]int vlan20
[sw2-Vlanif20]dhcp select relay
[sw2-Vlanif20]int vlan100
[sw2-Vlanif100]dhcp select relay
[sw2-Vlanif100]int vlan20	
[sw2-Vlanif20]dhcp relay server-ip 192.168.100.50
[sw2-Vlanif20]int vlan10
[sw2-Vlanif10]dhcp relay server-ip 192.168.100.50

Step 2: enter linux to configure dhcp
vim /etc/dhcp/dhcpd.conf

systemctl restart dhcpd restart configuration file
Step 3: View

fail
Troubleshooting
View linux routing table

A default route is missing, pointing to the set gateway

[root@localhost ~]# route add default gw 192.168.100.1 / / add default route
[root@localhost ~]# route -n
Kernel IP routing table
Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
0.0.0.0         192.168.100.1   0.0.0.0         UG    0      0        0 ens37
0.0.0.0         192.168.17.2    0.0.0.0         UG    100    0        0 ens33
192.168.17.0    0.0.0.0         255.255.255.0   U     100    0        0 ens33
192.168.100.0   0.0.0.0         255.255.255.0   U     101    0        0 ens37
192.168.122.0   0.0.0.0         255.255.255.0   U     0      0        0 virbr0

Add a default route
Check whether the configuration is successful again
pc1

pc2

Keywords: Linux

Added by rowman on Thu, 10 Feb 2022 23:53:48 +0200