Static-Mapping

Test suite to validate DHCP static-mapping functionality.

Static mappings allow assigning fixed IP addresses to specific MAC addresses. Additionally, each static mapping can have its own DHCP options that override the subnet-level options.

Key scenarios verified: - Basic static mapping: MAC → fixed IP - Static mapping with custom NTP server (different from subnet) - Static mapping with custom DNS server (different from subnet) - Option hierarchy: static-mapping options override subnet options - Multiple static mappings with different options

Test DHCP Server Static Mapping

Description

This scenario will check if the static-mapping option works. This option will give a specific lease to the MAC received, configured for the DHCP server. The server will then configure the option with this MAC and the client will then check it has received de IP address.

Scenario

Step 1: Set the following configuration in DUT1 :

set interfaces ethernet eth0 mac '10:00:00:00:00:05'
set system login user admin authentication encrypted-password '$6$GSjsCj8gHLv$/VcqU6FLi6CT2Oxn0MJQ2C2tqnRDrYKNF8HIYWJp68nvXvPdFccDsT04.WtigUONbKYrgKg8d6rEs8PjljMkH0'

Step 2: Modify the following configuration lines in DUT1 :

set interfaces ethernet eth0 address dhcp

Step 3: Set the following configuration in DUT0 :

set interfaces ethernet eth0 address 10.0.0.100/24
set service dhcp-server shared-network dhcp subnet 10.0.0.0/24 static-mapping test ip-address 10.0.0.5
set service dhcp-server shared-network dhcp subnet 10.0.0.0/24 static-mapping test mac-address '10:00:00:00:00:05'
set system login user admin authentication encrypted-password '$6$GSjsCj8gHLv$/VcqU6FLi6CT2Oxn0MJQ2C2tqnRDrYKNF8HIYWJp68nvXvPdFccDsT04.WtigUONbKYrgKg8d6rEs8PjljMkH0'

Step 4: Run command service dhcp-client renew interface eth0 at DUT1 and expect this output:

Show output
Renewing DHCP lease on interface eth0...

Step 5: Run command service dhcp-client renew interface eth0 at DUT1 and expect this output:

Show output
Renewing DHCP lease on interface eth0...

Step 6: Ping IP address 10.0.0.100 from DUT1:

admin@DUT1$ ping 10.0.0.100 count 1 size 56 timeout 1
Show output
PING 10.0.0.100 (10.0.0.100) 56(84) bytes of data.
64 bytes from 10.0.0.100: icmp_seq=1 ttl=64 time=0.472 ms

--- 10.0.0.100 ping statistics ---
1 packets transmitted, 1 received, 0% packet loss, time 0ms
rtt min/avg/max/mdev = 0.472/0.472/0.472/0.000 ms

Step 7: Run command interfaces ethernet eth0 show at DUT1 and check if output contains the following tokens:

10.0.0.5/24
Show output
-----------------------------------------------------------------
Name           IP Address           Admin  Oper  Vrf  Description
-----------------------------------------------------------------
eth0  10.0.0.5/24                   up     up
      fe80::dcad:beff:feef:6c10/64

Step 8: Run command service dhcp-client show leases interface eth0 at DUT1 and check if output contains the following tokens:

10.0.0.5
Show output
Interface:     eth0
IP address:    10.0.0.5
Subnet mask:   255.255.255.0
Routers:
Name-servers:
Domain-name:
NTP servers:
DHCP server:   10.0.0.100
Lease time:    43200
Expiry date:   Fri Mar 06 08:35:55 2026
Reason:        REBOOT

Test Static Mapping with Custom NTP Server

Description

This scenario verifies that a static mapping can have custom NTP server options that override the subnet-level NTP configuration.

Configuration: - Subnet NTP: 10.10.10.1 - Host1 static mapping with NTP: 10.10.10.11

Expected: - Host1 receives custom NTP (10.10.10.11), not subnet NTP - Host1 gets the static IP (192.168.60.50)

Scenario

Step 1: Set the following configuration in DUT0 :

set interfaces ethernet eth0 address 192.168.60.1/24
set service dhcp-server shared-network main subnet 192.168.60.0/24 options default-router 192.168.60.1
set service dhcp-server shared-network main subnet 192.168.60.0/24 options dns-server 10.20.20.1
set service dhcp-server shared-network main subnet 192.168.60.0/24 options ntp-server 10.10.10.1
set service dhcp-server shared-network main subnet 192.168.60.0/24 start 192.168.60.100 stop 192.168.60.200
set service dhcp-server shared-network main subnet 192.168.60.0/24 static-mapping host1 ip-address 192.168.60.50
set service dhcp-server shared-network main subnet 192.168.60.0/24 static-mapping host1 mac-address '10:00:00:00:00:11'
set service dhcp-server shared-network main subnet 192.168.60.0/24 static-mapping host1 options ntp-server 172.16.1.11
set system login user admin authentication encrypted-password '$6$GSjsCj8gHLv$/VcqU6FLi6CT2Oxn0MJQ2C2tqnRDrYKNF8HIYWJp68nvXvPdFccDsT04.WtigUONbKYrgKg8d6rEs8PjljMkH0'

Step 2: Set the following configuration in DUT1 :

set interfaces ethernet eth0 mac '10:00:00:00:00:11'
set system login user admin authentication encrypted-password '$6$GSjsCj8gHLv$/VcqU6FLi6CT2Oxn0MJQ2C2tqnRDrYKNF8HIYWJp68nvXvPdFccDsT04.WtigUONbKYrgKg8d6rEs8PjljMkH0'

Step 3: Modify the following configuration lines in DUT1 :

set interfaces ethernet eth0 address dhcp

Step 4: Run command interfaces ethernet eth0 show at DUT1 and check if output contains the following tokens:

192.168.60.50
Show output
-----------------------------------------------------------------
Name           IP Address           Admin  Oper  Vrf  Description
-----------------------------------------------------------------
eth0  192.168.60.50/24              up     up
      fe80::dcad:beff:feef:6c10/64

Step 5: Run command show monitor-db system dhcp interface eth0 ntp-servers at DUT1 and expect this output:

Show output
172.16.1.11

Test Static Mapping with Custom DNS Server

Description

This scenario verifies that a static mapping can have custom DNS server options that override the subnet-level DNS configuration.

Configuration: - Subnet DNS: 10.20.20.1 - Host2 static mapping with DNS: 10.20.20.22

Expected: - Host2 receives custom DNS (10.20.20.22), not subnet DNS - Host2 gets the static IP (192.168.60.51)

Scenario

Step 1: Set the following configuration in DUT0 :

set interfaces ethernet eth0 address 192.168.60.1/24
set service dhcp-server shared-network main subnet 192.168.60.0/24 options default-router 192.168.60.1
set service dhcp-server shared-network main subnet 192.168.60.0/24 options dns-server 10.20.20.1
set service dhcp-server shared-network main subnet 192.168.60.0/24 options ntp-server 10.10.10.1
set service dhcp-server shared-network main subnet 192.168.60.0/24 start 192.168.60.100 stop 192.168.60.200
set service dhcp-server shared-network main subnet 192.168.60.0/24 static-mapping host2 ip-address 192.168.60.51
set service dhcp-server shared-network main subnet 192.168.60.0/24 static-mapping host2 mac-address '10:00:00:00:00:22'
set service dhcp-server shared-network main subnet 192.168.60.0/24 static-mapping host2 options dns-server 172.16.2.22
set system login user admin authentication encrypted-password '$6$GSjsCj8gHLv$/VcqU6FLi6CT2Oxn0MJQ2C2tqnRDrYKNF8HIYWJp68nvXvPdFccDsT04.WtigUONbKYrgKg8d6rEs8PjljMkH0'

Step 2: Set the following configuration in DUT1 :

set interfaces ethernet eth0 mac '10:00:00:00:00:22'
set system login user admin authentication encrypted-password '$6$GSjsCj8gHLv$/VcqU6FLi6CT2Oxn0MJQ2C2tqnRDrYKNF8HIYWJp68nvXvPdFccDsT04.WtigUONbKYrgKg8d6rEs8PjljMkH0'

Step 3: Modify the following configuration lines in DUT1 :

set interfaces ethernet eth0 address dhcp

Step 4: Run command interfaces ethernet eth0 show at DUT1 and check if output contains the following tokens:

192.168.60.51
Show output
-----------------------------------------------------------------
Name           IP Address           Admin  Oper  Vrf  Description
-----------------------------------------------------------------
eth0  192.168.60.51/24              up     up
      fe80::dcad:beff:feef:6c10/64

Step 5: Run command show monitor-db system dhcp interface eth0 dns-servers at DUT1 and expect this output:

Show output
172.16.2.22

Test Multiple Static Mappings with Different Options

Description

This scenario verifies that multiple static mappings can coexist, each with their own custom options.

Configuration: - Subnet options: NTP 10.10.10.1, DNS 10.20.20.1 - Host1: Custom NTP 10.10.10.11 (inherits subnet DNS) - Host2: Custom DNS 10.20.20.22 (inherits subnet NTP)

Expected: - Host1 gets custom NTP but subnet DNS - Host2 gets custom DNS but subnet NTP

Scenario

Step 1: Set the following configuration in DUT0 :

set interfaces ethernet eth0 address 192.168.60.1/24
set service dhcp-server shared-network main subnet 192.168.60.0/24 options default-router 192.168.60.1
set service dhcp-server shared-network main subnet 192.168.60.0/24 options dns-server 10.20.20.1
set service dhcp-server shared-network main subnet 192.168.60.0/24 options ntp-server 10.10.10.1
set service dhcp-server shared-network main subnet 192.168.60.0/24 start 192.168.60.100 stop 192.168.60.200
set service dhcp-server shared-network main subnet 192.168.60.0/24 static-mapping host1 ip-address 192.168.60.50
set service dhcp-server shared-network main subnet 192.168.60.0/24 static-mapping host1 mac-address '10:00:00:00:00:11'
set service dhcp-server shared-network main subnet 192.168.60.0/24 static-mapping host1 options ntp-server 172.16.1.11
set service dhcp-server shared-network main subnet 192.168.60.0/24 static-mapping host2 ip-address 192.168.60.51
set service dhcp-server shared-network main subnet 192.168.60.0/24 static-mapping host2 mac-address '10:00:00:00:00:22'
set service dhcp-server shared-network main subnet 192.168.60.0/24 static-mapping host2 options dns-server 172.16.2.22
set system login user admin authentication encrypted-password '$6$GSjsCj8gHLv$/VcqU6FLi6CT2Oxn0MJQ2C2tqnRDrYKNF8HIYWJp68nvXvPdFccDsT04.WtigUONbKYrgKg8d6rEs8PjljMkH0'

Step 2: Set the following configuration in DUT1 :

set interfaces ethernet eth0 mac '10:00:00:00:00:11'
set system login user admin authentication encrypted-password '$6$GSjsCj8gHLv$/VcqU6FLi6CT2Oxn0MJQ2C2tqnRDrYKNF8HIYWJp68nvXvPdFccDsT04.WtigUONbKYrgKg8d6rEs8PjljMkH0'

Step 3: Modify the following configuration lines in DUT1 :

set interfaces ethernet eth0 address dhcp

Step 4: Run command interfaces ethernet eth0 show at DUT1 and check if output contains the following tokens:

192.168.60.50
Show output
-----------------------------------------------------------------
Name           IP Address           Admin  Oper  Vrf  Description
-----------------------------------------------------------------
eth0  192.168.60.50/24              up     up
      fe80::dcad:beff:feef:6c10/64

Step 5: Run command show monitor-db system dhcp interface eth0 ntp-servers at DUT1 and expect this output:

Show output
172.16.1.11

Step 6: Run command show monitor-db system dhcp interface eth0 dns-servers at DUT1 and expect this output:

Show output
10.20.20.1

Step 7: Modify the following configuration lines in DUT1 :

delete interfaces ethernet eth0 address

Step 8: Modify the following configuration lines in DUT1 :

set interfaces ethernet eth0 mac '10:00:00:00:00:22'

Step 9: Modify the following configuration lines in DUT1 :

set interfaces ethernet eth0 address dhcp

Step 10: Run command interfaces ethernet eth0 show at DUT1 and check if output contains the following tokens:

192.168.60.51
Show output
-----------------------------------------------------------------
Name           IP Address           Admin  Oper  Vrf  Description
-----------------------------------------------------------------
eth0  192.168.60.51/24              up     up
      fe80::dcad:beff:feef:6c10/64

Step 11: Run command show monitor-db system dhcp interface eth0 ntp-servers at DUT1 and expect this output:

Show output
10.10.10.1

Step 12: Run command show monitor-db system dhcp interface eth0 dns-servers at DUT1 and expect this output:

Show output
172.16.2.22

Test Option Hierarchy Static Mapping Overrides Subnet

Description

This scenario explicitly tests that static mapping options have higher priority than subnet-level options.

This is an important ISC DHCP behavior: options defined in a host declaration override options from the containing subnet.

Test verifies that when both subnet and static-mapping define the same option (ntp-server), the static-mapping value wins.

Scenario

Step 1: Set the following configuration in DUT0 :

set interfaces ethernet eth0 address 192.168.60.1/24
set service dhcp-server shared-network main subnet 192.168.60.0/24 options default-router 192.168.60.1
set service dhcp-server shared-network main subnet 192.168.60.0/24 options dns-server 10.20.20.1
set service dhcp-server shared-network main subnet 192.168.60.0/24 options ntp-server 10.10.10.1
set service dhcp-server shared-network main subnet 192.168.60.0/24 start 192.168.60.100 stop 192.168.60.200
set service dhcp-server shared-network main subnet 192.168.60.0/24 static-mapping host1 ip-address 192.168.60.50
set service dhcp-server shared-network main subnet 192.168.60.0/24 static-mapping host1 mac-address '10:00:00:00:00:11'
set service dhcp-server shared-network main subnet 192.168.60.0/24 static-mapping host1 options ntp-server 172.16.1.11
set system login user admin authentication encrypted-password '$6$GSjsCj8gHLv$/VcqU6FLi6CT2Oxn0MJQ2C2tqnRDrYKNF8HIYWJp68nvXvPdFccDsT04.WtigUONbKYrgKg8d6rEs8PjljMkH0'

Step 2: Set the following configuration in DUT1 :

set interfaces ethernet eth0 address dhcp
set system login user admin authentication encrypted-password '$6$GSjsCj8gHLv$/VcqU6FLi6CT2Oxn0MJQ2C2tqnRDrYKNF8HIYWJp68nvXvPdFccDsT04.WtigUONbKYrgKg8d6rEs8PjljMkH0'

Step 3: Run command interfaces ethernet eth0 show at DUT1 and check if output contains the following tokens:

192.168.60.
Show output
-----------------------------------------------------------------
Name           IP Address           Admin  Oper  Vrf  Description
-----------------------------------------------------------------
eth0  192.168.60.100/24             up     up
      fe80::dcad:beff:feef:6c10/64

Step 4: Run command show monitor-db system dhcp interface eth0 ntp-servers at DUT1 and expect this output:

Show output
10.10.10.1

Step 5: Modify the following configuration lines in DUT1 :

delete interfaces

Step 6: Modify the following configuration lines in DUT1 :

set interfaces ethernet eth0 mac '10:00:00:00:00:11'

Step 7: Modify the following configuration lines in DUT1 :

set interfaces ethernet eth0 address dhcp

Step 8: Run command interfaces ethernet eth0 show at DUT1 and check if output contains the following tokens:

192.168.60.50
Show output
-----------------------------------------------------------------
Name           IP Address           Admin  Oper  Vrf  Description
-----------------------------------------------------------------
eth0  192.168.60.50/24              up     up
      fe80::dcad:beff:feef:6c10/64

Step 9: Run command show monitor-db system dhcp interface eth0 ntp-servers at DUT1 and expect this output:

Show output
172.16.1.11