注意:中继IP指向的是DHCP服务器

先激活dhcp enable

华为--三层交换机dhcp中继_dhcp·

 

代码:

在SW1中:

#

interface Vlanif10

 ip address 192.168.10.1 255.255.255.0

 dhcp select relay

 dhcp relay server-ip 21.0.0.2

#

interface Vlanif20

 ip address 21.0.0.1 255.255.255.0

#

interface GigabitEthernet0/0/1

 port hybrid pvid vlan 10

 port hybrid untagged vlan 10

#

interface GigabitEthernet0/0/2

 port hybrid pvid vlan 20

 port hybrid untagged vlan 20

#

ip route-static 0.0.0.0 0.0.0.0 21.0.0.2

#

在R1中:

#

interface GigabitEthernet0/0/0

 ip address 21.0.0.2 255.255.255.0

 dhcp select global

#

ip pool dhcp10

 gateway-list 192.168.10.1

 network 192.168.10.0 mask 255.255.255.0

#

ip route-static 0.0.0.0 0.0.0.0 21.0.0.1

#