三层交换机设置:
Switch#
Switch#configure terminal Switch(config)#ip routing Switch(config)#vlan 10Switch(config-vlan)#vlan 20Switch(config-vlan)#vlan 30Switch(config-vlan)#exitSwitch(config)#interface vlan 10Switch(config-if)#ip address 192.168.1.254 255.255.255.0Switch(config-if)#no shutdown Switch(config-if)#exitSwitch(config)#interface vlan 20Switch(config-if)#ip address 192.168.2.254 255.255.255.0Switch(config-if)#no shutdown Switch(config-if)#exitSwitch(config)#interface fastEthernet 0/1Switch(config-if)#no shutdown Switch(config-if)#switchport trunk encapsulation dot1q Switch(config-if)#switchport mode trunkSwitch(config-if)#exit
Switch(config)#router rip Switch(config-router)#version 2Switch(config-router)#no auto-summary Switch(config-router)#network 192.168.1.0Switch(config-router)#network 192.168.2.0Switch(config-router)#network 192.168.4.0Switch(config-router)#exitSwitch(config)#interface fastEthernet 0/2Switch(config-if)#no switchport Switch(config-if)#ip address 192.168.4.1 255.255.255.0Switch(config-if)#no shutdown Switch(config-if)#exitSwitch(config)#ip dhcp pool vlan10Switch(dhcp-config)#network 192.168.1.0 255.255.255.0Switch(dhcp-config)#default-router 192.168.1.254Switch(dhcp-config)#dns-server 202.102.128.68Switch(dhcp-config)#exitSwitch(config)#ip dhcp pool vlan20Switch(dhcp-config)#network 192.168.2.0 255.255.255.0Switch(dhcp-config)#default-router 192.168.2.254Switch(dhcp-config)#dns-server 202.102.128.68Switch(dhcp-config)#交换机1设置:
Switch>ena
Switch#configure terminal Switch(config)#interface fastEthernet 0/3Switch(config-if)#switchport mode trunk Switch(config-if)#exitSwitch(config)#vlan 10Switch(config-vlan)#vlan 20Switch(config-vlan)#exitSwitch(config)#interface f0/1Switch(config-if)#switchport access vlan 10Switch(config-if)#exitSwitch(config)#interface f0/2Switch(config-if)#switchport access vlan 20pc0自动获取vlan10的地址,pc1自动获取vlan20的地址路由器设置:
Router>ena
Router#configure tRouter(config)#interface fastEthernet 0/0Router(config-if)#ip address 192.168.4.2 255.255.255.0Router(config-if)#no shutdownRouter(config-if)#exit
Router(config)#interface fastEthernet 0/1
Router(config-if)#ip address 192.168.3.254 255.255.255.0Router(config-if)#no shutdownRouter(config-if)#exit
Router(config)#router rip Router(config-router)#version 2Router(config-router)#no auto-summary Router(config-router)#network 192.168.3.0Router(config-router)#network 192.168.4.0Router(config-router)#endRouter#configure terminal Router(config)#ip dhcp pool vlan30Router(dhcp-config)#network 192.168.3.0 255.255.255.0Router(dhcp-config)#default-router 192.168.3.254Router(dhcp-config)#dns-server 202.102.128.68pc2自动获取vlan30ip地址。