Class
These scenarios show how to configure different class options in DHCP. These options are useful to provide different addresses, depending on who the clients are.
Test DHCP-Server Class-ID
Description
This scenario shows two ways to define classes on the server: inside a subnet or outside it, within the shared network. Classes defined outside a subnet apply to every subnet in the shared network, while classes defined inside a subnet apply only to that subnet. The server defines two classes: one inside the subnet with a hexadecimal identifier, and another outside the subnet with an ASCII identifier. The ASCII option is useful for OSDx clients that send information through the vendor-class-identifier option. The test verifies that clients receive addresses from the class matching their identifier.
Scenario
Step 1: Set the following configuration in DUT0 :
set interfaces bridge br0 address 10.0.0.1/24 set interfaces ethernet eth0 bridge-group bridge br0 set interfaces ethernet eth1 bridge-group bridge br0 set service dhcp-server shared-network test class test2 class-identifier ascii testing2 set service dhcp-server shared-network test subnet 10.0.0.0/24 class test1 class-identifier hex '00:74:65:73:74:69:6e:67:31' set service dhcp-server shared-network test subnet 10.0.0.0/24 class test1 start 10.0.0.5 stop 10.0.0.5 set service dhcp-server shared-network test subnet 10.0.0.0/24 class test2 start 10.0.0.10 stop 10.0.0.10 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 interfaces ethernet eth0 dhcp client send dhcp-client-identifier string testing1 set interfaces ethernet eth1 address dhcp set interfaces ethernet eth1 dhcp client send vendor-class-identifier string testing2 set system login user admin authentication encrypted-password '$6$GSjsCj8gHLv$/VcqU6FLi6CT2Oxn0MJQ2C2tqnRDrYKNF8HIYWJp68nvXvPdFccDsT04.WtigUONbKYrgKg8d6rEs8PjljMkH0'
Step 3: Run the command interfaces ethernet eth0 show detailed on DUT1 and check whether the output contains the following tokens:
10.0.0.5Show output
---------------------------------------------------------------------------------------------------------------- Name Idx IP Address Admin Oper Link MTU Vrf Upper Lower Type Phys addr ---------------------------------------------------------------------------------------------------------------- eth0 2 10.0.0.5/24 up up up 1500 ethernet de:ad:be:ef:6c:10 fe80::dcad:beff:feef:6c10/64
Step 4: Run the command interfaces ethernet eth1 show detailed on DUT1 and check whether the output contains the following tokens:
10.0.0.10Show output
---------------------------------------------------------------------------------------------------------------- Name Idx IP Address Admin Oper Link MTU Vrf Upper Lower Type Phys addr ---------------------------------------------------------------------------------------------------------------- eth1 3 10.0.0.10/24 up up up 1500 ethernet de:ad:be:ef:6c:11 fe80::dcad:beff:feef:6c11/64
Test DHCP-Server Class-ID VRF
Description
This scenario verifies that class matching works correctly when the server is bound to a VRF instead of regular interfaces. It configures two classes, one inside the shared network and another inside the subnet, and checks that each client receives a lease from the class matching its identifier.
Scenario
Step 1: Set the following configuration in DUT0 :
set interfaces bridge br0 address 10.0.0.1/24 set interfaces bridge br0 vrf VRF0 set interfaces ethernet eth0 bridge-group bridge br0 set interfaces ethernet eth1 bridge-group bridge br0 set service dhcp-server shared-network test class test2-vrf class-identifier ascii testing2 set service dhcp-server shared-network test local-vrf VRF0 set service dhcp-server shared-network test subnet 10.0.0.0/24 class test1-vrf class-identifier hex '00:74:65:73:74:69:6e:67:31' set service dhcp-server shared-network test subnet 10.0.0.0/24 class test1-vrf start 10.0.0.5 stop 10.0.0.5 set service dhcp-server shared-network test subnet 10.0.0.0/24 class test2-vrf start 10.0.0.10 stop 10.0.0.10 set system login user admin authentication encrypted-password '$6$GSjsCj8gHLv$/VcqU6FLi6CT2Oxn0MJQ2C2tqnRDrYKNF8HIYWJp68nvXvPdFccDsT04.WtigUONbKYrgKg8d6rEs8PjljMkH0' set system vrf VRF0
Step 2: Set the following configuration in DUT1 :
set interfaces ethernet eth0 address dhcp set interfaces ethernet eth0 dhcp client send dhcp-client-identifier string testing1 set interfaces ethernet eth1 address dhcp set interfaces ethernet eth1 dhcp client send vendor-class-identifier string testing2 set system login user admin authentication encrypted-password '$6$GSjsCj8gHLv$/VcqU6FLi6CT2Oxn0MJQ2C2tqnRDrYKNF8HIYWJp68nvXvPdFccDsT04.WtigUONbKYrgKg8d6rEs8PjljMkH0'
Step 3: Run the command interfaces ethernet eth0 show detailed on DUT1 and check whether the output contains the following tokens:
10.0.0.5Show output
---------------------------------------------------------------------------------------------------------------- Name Idx IP Address Admin Oper Link MTU Vrf Upper Lower Type Phys addr ---------------------------------------------------------------------------------------------------------------- eth0 2 10.0.0.5/24 up up up 1500 ethernet de:ad:be:ef:6c:10 fe80::dcad:beff:feef:6c10/64
Step 4: Run the command interfaces ethernet eth1 show detailed on DUT1 and check whether the output contains the following tokens:
10.0.0.10Show output
---------------------------------------------------------------------------------------------------------------- Name Idx IP Address Admin Oper Link MTU Vrf Upper Lower Type Phys addr ---------------------------------------------------------------------------------------------------------------- eth1 3 10.0.0.10/24 up up up 1500 ethernet de:ad:be:ef:6c:11 fe80::dcad:beff:feef:6c11/64
Test DHCP-Server Class RegExp
Description
This scenario tests classes defined with regular expressions. The first class matches identifiers containing “valid” followed by a digit, so a client identified as “valid” (without a digit) does not match. The second class matches identifiers containing “test” followed by any characters.
Scenario
Step 1: Set the following configuration in DUT0 :
set interfaces ethernet eth0 vif 100 address 10.0.0.1/24 set interfaces ethernet eth0 vif 101 address 10.0.0.2/24 set interfaces ethernet eth0 vif 102 address 10.0.0.3/24 set interfaces ethernet eth0 vif 103 address 10.0.0.4/24 set interfaces ethernet eth0 vif 104 address 10.0.0.5/24 set service dhcp-server shared-network test class test1 class-identifier reg 'valid[0-9]' set service dhcp-server shared-network test class test2 class-identifier reg 'test.*' set service dhcp-server shared-network test subnet 10.0.0.0/24 class test1 start 10.0.0.10 stop 10.0.0.14 set service dhcp-server shared-network test subnet 10.0.0.0/24 class test2 start 10.0.0.15 stop 10.0.0.15 set service dhcp-server shared-network test subnet 10.0.0.0/24 options one-lease-per-client set system login user admin authentication encrypted-password '$6$GSjsCj8gHLv$/VcqU6FLi6CT2Oxn0MJQ2C2tqnRDrYKNF8HIYWJp68nvXvPdFccDsT04.WtigUONbKYrgKg8d6rEs8PjljMkH0'
Step 2: Set the following configuration in DUT1 :
set interfaces ethernet eth0 vif 100 mac '10:00:00:00:00:01' set interfaces ethernet eth0 vif 101 mac '10:00:00:00:00:02' set interfaces ethernet eth0 vif 102 mac '10:00:00:00:00:03' set interfaces ethernet eth0 vif 103 mac '10:00:00:00:00:04' set interfaces ethernet eth0 vif 104 mac '10:00:00:00:00:05' 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 vif 100 address dhcp set interfaces ethernet eth0 vif 100 dhcp client send vendor-class-identifier string testing100valid set interfaces ethernet eth0 vif 101 address dhcp set interfaces ethernet eth0 vif 101 dhcp client send vendor-class-identifier string valid1 set interfaces ethernet eth0 vif 102 address dhcp set interfaces ethernet eth0 vif 102 dhcp client send vendor-class-identifier string valid9 set interfaces ethernet eth0 vif 103 address dhcp set interfaces ethernet eth0 vif 103 dhcp client send vendor-class-identifier string valid set interfaces ethernet eth0 vif 104 address dhcp set interfaces ethernet eth0 vif 104 dhcp client send vendor-class-identifier string invalid
Step 4: Run the command interfaces ethernet eth0 vif 100 show on DUT1 and check whether the output contains the following tokens:
10.0.0.15Show output
--------------------------------------------------------------------- Name IP Address Admin Oper Vrf Description --------------------------------------------------------------------- eth0.100 10.0.0.15/24 up up fe80::dcad:beff:feef:6c10/64
Step 5: Run the command interfaces ethernet eth0 vif 101 show | grep eth0.101 on DUT1 and check whether the output matches the following regular expressions:
\s*eth0\.10[0-4]\s*10.0.0.1[0-4]\/24\s*up\s*up\s*Show output
eth0.101 10.0.0.11/24 up up
Step 6: Run the command interfaces ethernet eth0 vif 102 show | grep eth0.102 on DUT1 and check whether the output matches the following regular expressions:
\s*eth0\.10[0-4]\s*10.0.0.1[0-4]\/24\s*up\s*up\s*Show output
eth0.102 10.0.0.10/24 up up
Step 7: Run the command interfaces ethernet eth0 vif 103 show on DUT1 and check whether the output does not contain the following tokens:
10.0.0Show output
--------------------------------------------------------------------- Name IP Address Admin Oper Vrf Description --------------------------------------------------------------------- eth0.103 fe80::dcad:beff:feef:6c10/64 up up
Step 8: Run the command interfaces ethernet eth0 vif 104 show on DUT1 and check whether the output does not contain the following tokens:
10.0.0Show output
--------------------------------------------------------------------- Name IP Address Admin Oper Vrf Description --------------------------------------------------------------------- eth0.104 fe80::dcad:beff:feef:6c10/64 up up
Test DHCP-Server Invalid Class-ID
Description
This scenario verifies that a client whose identifier does not match any class identifier configured on the server fails to obtain a lease.
Scenario
Step 1: Set the following configuration in DUT0 :
set interfaces ethernet eth0 address 10.0.0.1/24 set service dhcp-server shared-network test subnet 10.0.0.0/24 class test1 class-identifier hex '00:ff:ff:ff:ff:ff:ff:ff' set service dhcp-server shared-network test subnet 10.0.0.0/24 class test1 start 10.0.0.5 stop 10.0.0.5 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 interfaces ethernet eth0 dhcp client send dhcp-client-identifier string testing1 set interfaces ethernet eth1 address dhcp set interfaces ethernet eth1 dhcp client send vendor-class-identifier string testing2 set system login user admin authentication encrypted-password '$6$GSjsCj8gHLv$/VcqU6FLi6CT2Oxn0MJQ2C2tqnRDrYKNF8HIYWJp68nvXvPdFccDsT04.WtigUONbKYrgKg8d6rEs8PjljMkH0'
Step 3: Run the command interfaces ethernet eth0 show detailed on DUT1 and check whether the output does not contain the following tokens:
10.0.0.5Show output
---------------------------------------------------------------------------------------------------------------- Name Idx IP Address Admin Oper Link MTU Vrf Upper Lower Type Phys addr ---------------------------------------------------------------------------------------------------------------- eth0 2 fe80::dcad:beff:feef:6c10/64 up up up 1500 ethernet de:ad:be:ef:6c:10
Test DHCP-Server Invalid Configuration
Description
This scenario verifies that the server rejects a configuration where a subnet references a class that does not exist.
Scenario
Step 1: Expect a failure in the following command:
Set the following configuration in DUT0 :
set interfaces ethernet eth0 address 10.0.0.1/24 set service dhcp-server shared-network test subnet 10.0.0.0/24 class INVALID start 10.0.0.5 stop 10.0.0.5 set service dhcp-server shared-network test subnet 10.0.0.0/24 class test class-identifier hex '00:ff:ff:ff:ff:ff:ff:ff' set system login user admin authentication encrypted-password '$6$GSjsCj8gHLv$/VcqU6FLi6CT2Oxn0MJQ2C2tqnRDrYKNF8HIYWJp68nvXvPdFccDsT04.WtigUONbKYrgKg8d6rEs8PjljMkH0'
Step 2: Run the command system journal show | tail -n 50 on DUT0 and check whether the output contains the following tokens:
The input class INVALID does not match any class created in the shared network test or subnet 10.0.0.0/24Show output
May 19 17:50:32.307304 osdx systemd-journald[505760]: Runtime Journal (/run/log/journal/d1b141b298644f3ea5560bad25bf4943) is 1.9M, max 13.8M, 11.9M free. May 19 17:50:32.308383 osdx systemd-journald[505760]: Received client request to rotate journal, rotating. May 19 17:50:32.308428 osdx systemd-journald[505760]: Vacuuming done, freed 0B of archived journals from /run/log/journal/d1b141b298644f3ea5560bad25bf4943. May 19 17:50:32.319559 osdx OSDxCLI[673163]: User 'admin' executed a new command: 'system journal clear'. May 19 17:50:32.514198 osdx OSDxCLI[673163]: User 'admin' executed a new command: 'system coredump delete all'. May 19 17:50:32.714582 osdx OSDxCLI[673163]: User 'admin' entered the configuration menu. May 19 17:50:32.790977 osdx OSDxCLI[673163]: User 'admin' added a new cfg line: 'set interfaces eth0 address 10.0.0.1/24'. May 19 17:50:32.865350 osdx OSDxCLI[673163]: User 'admin' added a new cfg line: 'set service dhcp-server shared-network test subnet 10.0.0.0/24 class test class-identifier hex 00:ff:ff:ff:ff:ff:ff:ff'. May 19 17:50:32.916613 osdx OSDxCLI[673163]: User 'admin' added a new cfg line: 'set service dhcp-server shared-network test subnet 10.0.0.0/24 class INVALID start 10.0.0.5 stop 10.0.0.5'. May 19 17:50:33.015095 osdx OSDxCLI[673163]: User 'admin' added a new cfg line: 'show working'. May 19 17:50:33.073310 osdx ubnt-cfgd[716821]: inactive May 19 17:50:33.089286 osdx cfgd[1918]: External python command [cfg.dhcp_server check_classes INVALID 10.0.0.0/24 test] finished with status 1 May 19 17:50:33.090267 osdx cfgd[1918]: Commit validation failed May 19 17:50:33.090294 osdx cfgd[1918]: [673163]Command output: [ service dhcp-server shared-network test subnet 10.0.0.0/24 class INVALID start 10.0.0.5 stop 10.0.0.5 ] The input class INVALID does not match any class created in the shared network test or subnet 10.0.0.0/24. Commit validation failed May 19 17:50:33.090916 osdx OSDxCLI[673163]: User 'admin' entered an invalid command: 'commit '. May 19 17:50:33.123695 osdx OSDxCLI[673163]: User 'admin' left the configuration menu.
Test DHCP-Server Base-Mac
Description
This scenario configures a class that matches the client’s base-mac value and verifies that the client receives the corresponding lease.
Scenario
Step 1: Run the command show monitor-db system info hardware base-mac on DUT1 and expect the following output:
Show output
de:ad:be:ef:6c:10
Step 2: Set the following configuration in DUT0 :
set interfaces ethernet eth0 address 10.0.0.1/24 set service dhcp-server shared-network test class test1 class-identifier hex '01:de:ad:be:ef:6c:10' set service dhcp-server shared-network test subnet 10.0.0.0/24 class test1 start 10.0.0.5 stop 10.0.0.5 set system login user admin authentication encrypted-password '$6$GSjsCj8gHLv$/VcqU6FLi6CT2Oxn0MJQ2C2tqnRDrYKNF8HIYWJp68nvXvPdFccDsT04.WtigUONbKYrgKg8d6rEs8PjljMkH0'
Step 3: Set the following configuration in DUT1 :
set interfaces ethernet eth0 address dhcp set interfaces ethernet eth0 dhcp client send dhcp-client-identifier base-mac set system login user admin authentication encrypted-password '$6$GSjsCj8gHLv$/VcqU6FLi6CT2Oxn0MJQ2C2tqnRDrYKNF8HIYWJp68nvXvPdFccDsT04.WtigUONbKYrgKg8d6rEs8PjljMkH0'
Step 4: Run the command interfaces ethernet eth0 show detailed on DUT1 and check whether the output contains the following tokens:
10.0.0.5Show output
---------------------------------------------------------------------------------------------------------------- Name Idx IP Address Admin Oper Link MTU Vrf Upper Lower Type Phys addr ---------------------------------------------------------------------------------------------------------------- eth0 2 10.0.0.5/24 up up up 1500 ethernet de:ad:be:ef:6c:10 fe80::dcad:beff:feef:6c10/64