全局模式下show run显示如下配置:
--------------------------------------------------全局模式---------------------------------------------------------
路由器:cisco 2620XM 配置interface FastEthernet0/0
no ip address
duplex auto
speed auto
!
interface FastEthernet0/0.2
encapsulation dot1Q 2
ip address 192.168.1.1 255.255.255.0
!
interface FastEthernet0/0.3
encapsulation dot1Q 3
ip address 192.168.2.1 255.255.255.0
!
交换机:cisco 2960-24T配置
hostname Switch
!
!
ip dhcp excluded-address 192.168.1.1 192.168.1.2
ip dhcp excluded-address 192.168.2.1 192.168.2.2
!
ip dhcp pool vlan2
network 192.168.1.0 255.255.255.0
default-router 192.168.1.1
ip dhcp pool vlan3
network 192.168.2.0 255.255.255.0
default-router 192.168.2.1
!
!
spanning-tree mode pvst
!
interface FastEthernet0/1
switchport mode trunk
!
interface FastEthernet0/2
switchport access vlan 2
switchport mode access
!
interface FastEthernet0/3
switchport access vlan 3
switchport mode access
--------------------------------------------------详细步骤---------------------------------------------------------
SW1(config)#int vlan 2
SW1(config-if)#ip add 192.168.1.2 255.255.255.0
SW1(config-if)#exit
Sw1(config)#int vlan 3
Sw1(config-if)#ip add 192.168.2.2 255.255.255.0
Sw1(config-if)#exit
Switch(dhcp-config)#network 192.168.1.0 255.255.255.0 (指定vlan2地址池)
Switch(dhcp-config)#default-router 192.168.1.1 (指定vlan2默认路由)
Switch(dhcp-config)#exit
Switch(config)#ip dhcp pool vlan3 (开启地址池并命名vlan3)
Switch(dhcp-config)#network 192.168.2.0 255.255.255.0 (开启vlan3地址池)
Switch(dhcp-config)#default-router 192.168.2.1 (指定vlan3默认路由)
Switch(dhcp-config)#exit
Switch(config)#ip dhcp excluded-address 192.168.1.1 192.168.1.2
Switch(config)#ip dhcp excluded-address 192.168.2.1 192.168.2.2
Switch(config)#exit
来源:CSDN
作者:行yutian空
链接:https://blog.csdn.net/ChenYuJin1314520/article/details/51244272