Répertoire d'articles
1. Comprendre le service DNCP
Avantages de l'utilisation de DHCP:
- Réduisez la charge de travail des administrateurs
- Évitez la possibilité d'erreurs de saisie
- Évitez les conflits d'adresses IP
- Lors de la modification du segment d'adresse IP, il n'est pas nécessaire de réaffecter l'adresse IP de chaque utilisateur
- Meilleure utilisation des adresses IP
- Configuration client pratique
Méthode de distribution DHCP:
- Attribution automatique: utilisation permanente après l'attribution d'une adresse IP
- Allocation manuelle: l'adresse IP est spécifiée par l'administrateur du serveur DHCP
- Allocation dynamique: libérez l'adresse IP après utilisation, pour que d'autres clients l'utilisent
Deux, processus de bail DHCP
Trois, configuration du serveur DHCP
Quatre, configuration du client DHCP
Cinq, principe et configuration du relais DHCP
Fichier de configuration DHCP
vi /etc/dhcp/dhcp.conf
ddns-update-style none;
subnet 192.168.100.0 netmask 255.255.255.0 {
range 192.168.100.100 192.168.100.200;
option routers 192.168.100.1;
option subnet-mask 255.255.255.0;
option domain-name "www.bdqn.com";
option domain-name-servers 114.114.114.114 8.8.8.8;
option broadcast-address 192.168.100.255;
default-lease-time 21600;
max-lease-time 43200;
host prtsvr {
hardware ethernet 00:0C:29:BC:CF:2F; ###第二台客户机的MAC地址
fixed-address 192.168.100.66;
}
}
#ddns-update-style none;
subnet 192.168.10.0 netmask 255.255.255.0 {
range 192.168.10.100 192.168.10.200;
option routers 192.168.10.1;
option subnet-mask 255.255.255.0;
option domain-name "www.bdqn1.com";
#option domain-name-servers 114.114.114.114 8.8.8.8;
#option broadcast-address 192.168.100.255;
default-lease-time 21600;
max-lease-time 43200;
#host prtsvr {
#hardware ethernet 00:0C:29:BC:CF:2F; ###第二台客户机的MAC地址
#fixed-address 192.168.100.66;
# }
}
#ddns-update-style none;
subnet 192.168.20.0 netmask 255.255.255.0 {
range 192.168.20.100 192.168.20.200;
option routers 192.168.20.1;
option subnet-mask 255.255.255.0;
option domain-name "www.bdqn2.com";
#option domain-name-servers 114.114.114.114 8.8.8.8;
#option broadcast-address 192.168.100.255;
default-lease-time 21600;
max-lease-time 43200;
#host prtsvr {
#hardware ethernet 00:0C:29:BC:CF:2F; ###第二台客户机的MAC地址
#fixed-address 192.168.100.66;
# }
}
Configuration de la topologie
SW2
<Huawei>system-view
Enter system view, return user view with Ctrl+Z.
[Huawei]sysname SW2
[SW2]v b 10 20 30
Info: This operation may take a few seconds. Please wait for a moment...done.
[SW2]int e0/0/1
[SW2-Ethernet0/0/1]p l a
[SW2-Ethernet0/0/1]p d v 10
[SW2-Ethernet0/0/1]un sh
Info: Interface Ethernet0/0/1 is not shutdown.
[SW2-Ethernet0/0/1]int e0/0/2
[SW2-Ethernet0/0/2]p l a
[SW2-Ethernet0/0/2]p d v 20
[SW2-Ethernet0/0/2]un sh
Info: Interface Ethernet0/0/2 is not shutdown.
[SW2-Ethernet0/0/2]int e0/0/3
[SW2-Ethernet0/0/3]p l a
[SW2-Ethernet0/0/3]p d v 30
[SW2-Ethernet0/0/3]un sh
Info: Interface Ethernet0/0/3 is not shutdown.
[SW2-Ethernet0/0/3]int g0/0/1
[SW2-GigabitEthernet0/0/1]p l a
[SW2-GigabitEthernet0/0/1]p l t
[SW2-GigabitEthernet0/0/1]p t a v a
[SW2-GigabitEthernet0/0/1]un sh
Info: Interface GigabitEthernet0/0/1 is not shutdown.
[SW2-GigabitEthernet0/0/1]q
[SW2]
RSW1
<Huawei>system-view
Enter system view, return user view with Ctrl+Z.
[Huawei]sysname RWS1
[RWS1]dhcp enable
Info: The operation may take a few seconds. Please wait for a moment.done.
[RWS1]v b 10 20 30
Info: This operation may take a few seconds. Please wait for a moment...done.
[RWS1]int g0/0/1
[RWS1-GigabitEthernet0/0/1]p l t
[RWS1-GigabitEthernet0/0/1]p t a v a
[RWS1-GigabitEthernet0/0/1]un sh
Info: Interface GigabitEthernet0/0/1 is not shutdown.
[RWS1-GigabitEthernet0/0/1]q
[RWS1]int Vlanif 10
[RWS1-Vlanif10]ip add 192.168.10.1 24
[RWS1-Vlanif10]dhcp select relay
[RWS1-Vlanif10]dhcp relay server-ip 192.168.100.10
[RWS1-Vlanif10]q
[RWS1]int Vlanif 20
[RWS1-Vlanif20]ip add 192.168.20.1 24
[RWS1-Vlanif20]dhcp select relay
[RWS1-Vlanif20]dhcp relay server-ip 192.168.100.10
[RWS1-Vlanif20]q
[RWS1]int Vlanif 30
[RWS1-Vlanif30]ip add 192.168.100.1 24
[RWS1-Vlanif30]q
[RWS1]ping 192.168.100.10
PING 192.168.100.10: 56 data bytes, press CTRL_C to break
Reply from 192.168.100.10: bytes=56 Sequence=1 ttl=64 time=50 ms
Reply from 192.168.100.10: bytes=56 Sequence=2 ttl=64 time=50 ms
Reply from 192.168.100.10: bytes=56 Sequence=3 ttl=64 time=50 ms
Reply from 192.168.100.10: bytes=56 Sequence=4 ttl=64 time=60 ms
--- 192.168.100.10 ping statistics ---
4 packet(s) transmitted
4 packet(s) received
0.00% packet loss
round-trip min/avg/max = 50/52/60 ms
[RWS1]ping 192.168.100.10
PING 192.168.100.10: 56 data bytes, press CTRL_C to break
Reply from 192.168.100.10: bytes=56 Sequence=1 ttl=64 time=110 ms
Reply from 192.168.100.10: bytes=56 Sequence=2 ttl=64 time=70 ms
Reply from 192.168.100.10: bytes=56 Sequence=3 ttl=64 time=60 ms
Reply from 192.168.100.10: bytes=56 Sequence=4 ttl=64 time=50 ms
Reply from 192.168.100.10: bytes=56 Sequence=5 ttl=64 time=50 ms
--- 192.168.100.10 ping statistics ---
5 packet(s) transmitted
5 packet(s) received
0.00% packet loss
round-trip min/avg/max = 50/68/110 ms