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 2 class options. You can configure the server so that classes are inside or outside the corresponding subnet. If you define the class outside of the subnet, it will work for every subnet that is part of the shared network. Otherwise, it will only work for the corresponding subnet. The server has two classes: the first one is inside of the subnet and has testing1 as an hexadecimal value, and the second one is outside the subnet and uses ascii value testing2. You can use the ascii option if you are an OSDx client and choose the vendor-class-identifier option to send info. This scenario will check that the IP addresses received are from the right class.
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 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 command interfaces ethernet eth0 show detailed at DUT1 and check if 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 command interfaces ethernet eth1 show detailed at DUT1 and check if 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 checks that everything works properly if you use VRF instead of regular interfaces. This scenario configures 2 classes (one inside the shared network and another inside the subnet) and checks that the leases received correspond to each class.
Scenario
Step 1: Set the following configuration in DUT0 :
set interfaces ethernet eth0 address 10.0.0.1/24 set interfaces ethernet eth0 vrf VRF0 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 command interfaces ethernet eth0 show detailed at DUT1 and check if 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 command interfaces ethernet eth1 show detailed at DUT1 and check if 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 different classes with regular expresions. In this case, the first class will match identifiers that contain the term “valid” followed by a digit. As a result, the client identified as “valid” will not match this class. The other class will match identifiers that contain the word “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 command interfaces ethernet eth0 vif 100 show at DUT1 and check if 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 command interfaces ethernet eth0 vif 101 show | grep eth0.101 at DUT1 and check if 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 command interfaces ethernet eth0 vif 102 show | grep eth0.102 at DUT1 and check if 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 command interfaces ethernet eth0 vif 103 show at DUT1 and check if 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 command interfaces ethernet eth0 vif 104 show at DUT1 and check if 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 sets a valid configuration, but will not work properly because the client has set an identifier using the testing1 value and the server has set a different identifier. As a result, the client will not get 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 command interfaces ethernet eth0 show detailed at DUT1 and check if 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 sets an invalid configuration because there is no match between the classes configured.
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 command system journal show | tail -n 50 at DUT0 and check if 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
Mar 23 09:04:21.315454 osdx systemd-journald[2086]: Runtime Journal (/run/log/journal/6b3b4e4818aa404284bc644df40f6904) is 1.8M, max 13.8M, 11.9M free. Mar 23 09:04:21.318865 osdx systemd-journald[2086]: Received client request to rotate journal, rotating. Mar 23 09:04:21.318930 osdx systemd-journald[2086]: Vacuuming done, freed 0B of archived journals from /run/log/journal/6b3b4e4818aa404284bc644df40f6904. Mar 23 09:04:21.325880 osdx OSDxCLI[14779]: User 'admin' executed a new command: 'system journal clear'. Mar 23 09:04:21.584984 osdx OSDxCLI[14779]: User 'admin' executed a new command: 'system coredump delete all'. Mar 23 09:04:21.804801 osdx OSDxCLI[14779]: User 'admin' entered the configuration menu. Mar 23 09:04:21.886225 osdx OSDxCLI[14779]: User 'admin' added a new cfg line: 'set interfaces ethernet eth0 address 10.0.0.1/24'. Mar 23 09:04:21.959804 osdx OSDxCLI[14779]: 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'. Mar 23 09:04:22.055019 osdx OSDxCLI[14779]: 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'. Mar 23 09:04:22.121175 osdx OSDxCLI[14779]: User 'admin' added a new cfg line: 'show working'. Mar 23 09:04:22.221170 osdx ubnt-cfgd[46724]: inactive Mar 23 09:04:22.239104 osdx cfgd[1828]: External python command [cfg.dhcp_server check_classes INVALID 10.0.0.0/24 test] finished with status 1 Mar 23 09:04:22.240183 osdx cfgd[1828]: Commit validation failed Mar 23 09:04:22.241993 osdx cfgd[1828]: [14779]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 Mar 23 09:04:22.242804 osdx OSDxCLI[14779]: User 'admin' entered an invalid command: 'commit '. Mar 23 09:04:22.267261 osdx OSDxCLI[14779]: User 'admin' left the configuration menu.
Test DHCP-Server Base-Mac
Description
This scenario configures a class that matches the value of the base-mac sent by the client and checks that the client receives the corresponding lease.
Scenario
Step 1: Run command show monitor-db system info hardware base-mac at DUT1 and expect this 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 command interfaces ethernet eth0 show detailed at DUT1 and check if 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