Example for Configuring a DHCP Server to Assign IP Addresses to Users with the Same MAC Address in Different VLANs for Login
This section provides an example for configuring a DHCP server (with no relay agent configured) to assign IP addresses to Ethernet users with the same MAC addresses in different VLANs.
Networking Requirements
IP addresses of different network segments need to be applied for VoIP and IPTV services deployed on different user planes. DHCP clients that support these services use one MAC address to apply for IP addresses of different network segments and differentiate services based on VLAN IDs. This requires the DHCP server to assign IP addresses to users with the same MAC address in different VLANs.
On the network shown in Figure 1, the DHCP server is configured to dynamically assign IP addresses to DHCP clients. When receiving a user packet in which the VLAN ID is 100, the DHCP server selects the address pool huawei1 to assign an IP address to the user based on the gateway address 10.10.10.1/24. When receiving a user packet in which the VLAN ID is 200, the DHCP server selects the address pool huawei2 to assign an IP address to the user based on the gateway address 10.10.20.1/24.
The DHCP server can only assign IP addresses from different address pools to users with the same MAC address in different VLANs.
Configuration Roadmap
The configuration roadmap is as follows:
Configure an IP address for the interface through which users go online.
Configure gateway addresses and address segments for address pools.
Configure Layer 3 sub-interfaces.
Data Preparation
To complete the configuration, you need the following data:
IP address of the interface through which users go online
Gateway addresses
Numbers and ranges of address segments
Procedure
- Configure an IP address for the interface through which
users go online.
<HUAWEI> system-view [~HUAWEI] sysname DHCP Server [*HUAWEI] commit [~DHCP Server] interface gigabitethernet 0/1/1 [~DHCP Server-GigabitEthernet0/1/1] ip address 10.1.1.1 255.255.255.0 [*DHCP Server-GigabitEthernet0/1/1] commit [~DHCP Server-GigabitEthernet0/1/1] quit
- Configure gateway addresses and address segments for address
pools.
# Configure an address pool huawei1.
[~DHCP Server] dhcp enable [*DHCP Server] ip pool huawei1 server [*DHCP Server-ip-pool-huawei1] gateway 10.10.10.1 255.255.255.0 [*DHCP Server-ip-pool-huawei1] section 0 10.10.10.20 10.10.10.30 [*DHCP Server-ip-pool-huawei1] commit [~DHCP Server-ip-pool-huawei1] quit
# Configure an address pool huawei2.
[~DHCP Server] ip pool huawei2 server [*DHCP Server-ip-pool-huawei2] gateway 10.10.20.1 255.255.255.0 [*DHCP Server-ip-pool-huawei2] section 0 10.10.20.20 10.10.20.30 [*DHCP Server-ip-pool-huawei2] commit [~DHCP Server-ip-pool-huawei2] quit
- Configure a Layer 3 sub-interface (taking the Dot1q termination
sub-interface as an example).
[~DHCP Server] interface gigabitethernet 0/1/1.1 [*DHCP Server-GigabitEthernet0/1/1.1] ip address 10.10.10.1 255.255.255.0 [*DHCP Server-GigabitEthernet0/1/1.1] encapsulation dot1q-termination [*DHCP Server-GigabitEthernet0/1/1.1] dot1q termination vid 100 [*DHCP Server-GigabitEthernet0/1/1.1] commit [~DHCP Server-GigabitEthernet0/1/1.1] quit [~DHCP Server] interface gigabitethernet 0/1/1.2 [*DHCP Server-GigabitEthernet0/1/1.2] ip address 10.10.20.1 255.255.255.0 [*DHCP Server-GigabitEthernet0/1/1.2] encapsulation dot1q-termination [*DHCP Server-GigabitEthernet0/1/1.2] dot1q termination vid 200 [*DHCP Server-GigabitEthernet0/1/1.2] commit [~DHCP Server-GigabitEthernet0/1/1.2] quit
- Verify the configuration.
# Run the display ip pool command on the DHCP server to check the configurations of IP address pools.
[~DHCP Server] display ip pool name huawei1 Pool-Name : huawei1 Pool-No : 2 Pool-constant-index: - Lease : 3 Days 0 Hours 0 Minutes NetBios Type : N-Node Auto recycle : 30 Option 3 : Enable DNS-Suffix : - Dom-Search-List0: - Dom-Search-List1: - Dom-Search-List2: - Dom-Search-List3: - Option-Code 125 : enterprise-code : 2011, string: - Position : Server Status : Unlocked RUI-Flag : - Attribute : Private Gateway : 10.10.10.1 Mask : 255.255.255.0 Vpn instance : -- Unnumbered gateway: - Profile-Name : - Server-Name : - Total Idle : 11 Have Dhcp IP : 1 Timeouts : 0 Timeout Count : 0 Sub Option Count : 0 Option Count : 0 Force-reply Count: 0 Codes: CFLCT(conflicted) --------------------------------------------------------------------------------------- ID start end total used idle CFLCT disable reserved static-bind --------------------------------------------------------------------------------------- 0 10.10.10.20 10.10.10.30 11 0 11 0 0 0 0 --------------------------------------------------------------------------------------- [~DHCP Server] display ip pool name huawei2 Pool-Name : huawei2 Pool-No : 3 Pool-constant-index: - Lease : 3 Days 0 Hours 0 Minutes NetBios Type : N-Node Auto recycle : 30 Option 3 : Enable DNS-Suffix : - Dom-Search-List0: - Dom-Search-List1: - Dom-Search-List2: - Dom-Search-List3: - Option-Code 125 : enterprise-code : 2011, string: - Position : Server Status : Unlocked RUI-Flag : - Attribute : Private Gateway : 10.10.20.1 Mask : 255.255.255.0 Vpn instance : -- Unnumbered gateway: - Profile-Name : - Server-Name : - Total Idle : 11 Have Dhcp IP : 1 Timeouts : 0 Timeout Count : 0 Sub Option Count : 0 Option Count : 0 Force-reply Count: 0 Codes: CFLCT(conflicted) --------------------------------------------------------------------------------------- ID start end total used idle CFLCT disable reserved static-bind --------------------------------------------------------------------------------------- 0 10.10.20.20 10.10.20.30 11 0 11 0 0 0 0 ---------------------------------------------------------------------------------------
Configuration Files
DHCP server configuration file
# sysname DHCP Server # dhcp enable # ip pool huawei1 server gateway 10.10.10.1 255.255.255.0 section 0 10.10.10.20 10.10.10.30 # ip pool huawei2 server gateway 10.10.20.1 255.255.255.0 section 0 10.10.20.20 10.10.20.30 # interface GigabitEthernet0/1/1 ip address 10.1.1.1 255.255.255.0 # interface GigabitEthernet0/1/1.1 ip address 10.10.10.1 255.255.255.0 encapsulation dot1q-termination dot1q termination vid 100 # interface GigabitEthernet0/1/1.2 ip address 10.10.20.1 255.255.255.0 encapsulation dot1q-termination dot1q termination vid 200 # return