Switch#conf t
Switch(config)#no ip domain-lookup
Switch#vlan database
Switch(vlan)#vlan 2
Switch(vlan)#vlan 3
Switch(config)#int vlan 2
Switch(config-if)#ip address 192.168.2.1 255.255.255.0
Switch(config-if)#no shutdown
Switch(config)#int vlan 3
Switch(config-if)#ip address 192.168.3.1 255.255.255.0
Switch(config-if)#no shutdown
Switch(config)#interface fastEthernet 0/24
Switch(config-if)#switchport trunk encapsulation dot1q --思科配置trunk封装ISL 或 802.1Q 或自动协商
Switch(config-if)#switchport mode trunk
Switch(config)#ip dhcp pool vlan2
Switch(dhcp-config)#network 192.168.2.0 192.168.2.255
Switch(dhcp-config)#default-router 192.168.2.1
Switch(config)#ip dhcp pool vlan3
Switch(dhcp-config)#network 192.168.3.0 192.168.3.255
Switch(dhcp-config)#default-router 192.168.3.1
Switch(config)#ip dhcp excluded-address 192.168.2.1 192.168.2.10
Switch(config)#ip dhcp excluded-address 192.168.3.1 192.168.3.10
设置排斥地址为192.168.2.1至192.168.2.10的ip地址不分配给客户端
两层
Switch(config)#interface fastEthernet 0/24
Switch(config-if)#switchport mode trunk
Switch#vlan database
Switch(vlan)#vlan 2
Switch(vlan)#vlan 3
Switch(config)#int range fastEthernet 0/1-5
Switch(config-if-range)#switchport access vlan 2
Switch(config)#int range fastEthernet 0/6-10
Switch(config-if-range)#switchport access vlan 3
转载于:https://blog.51cto.com/howardhuang/1662777