Article Directory
1. Understand DNCP service
Benefits of using DHCP:
- Reduce the workload of administrators
- Avoid the possibility of input errors
- Avoid IP address conflicts
- When changing the IP address segment, there is no need to reassign each user's IP address
- Improved utilization of IP addresses
- Convenient client configuration
DHCP distribution method:
- Automatic allocation: permanent use after being allocated an IP address
- Manual allocation: the IP address is specified by the DHCP server administrator
- Dynamic allocation: release the IP after use, for other clients to use
Two, DHCP lease process
Three, DHCP server configuration
Four, DHCP client configuration
Five, DHCP relay principle and configuration
DHCP configuration file
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;
# }
}
Topology configuration
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