Class

These scenarios show how to configure different options for classes in DHCP. These options are useful to give different addresses depending on who the clients are.

Test DHCP-Server Class-ID

Description

This scenario shows 2 options for these classes. You can configure the server with classes inside of the corresponding subnet or you can define it outside. If you define the class outside of the subnet, it will work for every subnet corresponding to the shared network. In any other case, it will works only for the corresponding subnet. The server has two classes, the first one is inside of the subnet and has the value testing1 in hexadecimal and the second one is outside and has the value in ascii testing2 (You can use ascii options in case you use an OSDx client and you chose the option vendor-class-identifier to send info). So, 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 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 class test2 class-identifier ascii testing2
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

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

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

10.0.0.5
Show 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:20
           fe80::dcad:beff:feef:6c20/64

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

10.0.0.10
Show 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:21
           fe80::dcad:beff:feef:6c21/64

Test DHCP-Server Class-ID VRF

Description

This scenario tests 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 the leases received are from the corresponding 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 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 class test2-vrf class-identifier ascii testing2
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 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

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

10.0.0.5
Show 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:20
           fe80::dcad:beff:feef:6c20/64

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

10.0.0.10
Show 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:21
           fe80::dcad:beff:feef:6c21/64

Test DHCP-Server Class RegExp

Description

This scenario tests different classes with regular expresions. For this case, the first class will match with identifiers that contain “valid” and has a digit after. So, the client identified with the value “valid” will not match with this class. The other class, will match with identifiers that contain “test” and after this, the identifier could have 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 options one-lease-per-client
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

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

Step 3: Set the following configuration 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.15
Show output
---------------------------------------------------------------------
  Name             IP Address           Admin  Oper  Vrf  Description
---------------------------------------------------------------------
eth0.100  10.0.0.15/24                  up     up
          fe80::dcad:beff:feef:6c20/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.0
Show output
---------------------------------------------------------------------
  Name             IP Address           Admin  Oper  Vrf  Description
---------------------------------------------------------------------
eth0.103  fe80::dcad:beff:feef:6c20/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.0
Show output
---------------------------------------------------------------------
  Name             IP Address           Admin  Oper  Vrf  Description
---------------------------------------------------------------------
eth0.104  fe80::dcad:beff:feef:6c20/64  up     up

Test DHCP-Server Invalid Class-ID

Description

This scenario set a valid configuration, but it will not work properly, because the client set an identifier with the value testing1, and the server set a different identifier, so 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

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

Step 3: Run command interfaces ethernet eth0 show detailed at DUT1 and check if output does not contain the following tokens:

10.0.0.5
Show output
----------------------------------------------------------------------------------------------------------------
Name  Idx           IP Address           Admin  Oper  Link  MTU   Vrf  Upper  Lower    Type        Phys addr
----------------------------------------------------------------------------------------------------------------
eth0  2    fe80::dcad:beff:feef:6c20/64  up     up    up    1500                     ethernet  de:ad:be:ef:6c:20

Test DHCP-Server Invalid Configuration

Description

This scenario set 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 test 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 INVALID start 10.0.0.5 stop 10.0.0.5

Step 2: Run command system journal show | tail 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/24
Show output
Feb 26 18:57:32.547908 osdx OSDxCLI[1563]: 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'.
Feb 26 18:57:32.662648 osdx cfgd[997]: External python command [cfg.dhcp_server check_classes INVALID 10.0.0.0/24 test] finished with status 1
Feb 26 18:57:32.662768 osdx cfgd[997]: Commit validation failed
Feb 26 18:57:32.667597 osdx cfgd[997]: [1563]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
Feb 26 18:57:32.670720 osdx OSDxCLI[1563]: User 'admin' entered an invalid command: 'commit'.
Feb 26 18:57:32.711635 osdx OSDxCLI[1563]: User 'admin' left the configuration menu.

Test DHCP-Server Base-Mac

Description

This scenario configures a class corresponding with 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:20

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 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 class test1 class-identifier hex 01:de:ad:be:ef:6c:20

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

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

10.0.0.5
Show 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:20
           fe80::dcad:beff:feef:6c20/64