实验名称:交换机作为DHCP 实验目的:PC1与PC2不同网段互通 实验拓扑

配置思路: 1.在二层交换机设置vlan10 20,与PC的端口对应为access 与三层交换机对应端口为trunk 2.在二层交换机设置DHCP配置,设置vlan 1 的ip与三层交换机为同一网段互通,并设置三层交换机对应端口的ip为网关,与三层交换机的对应端口为trunk 3.在三层交换机设置虚拟网关vlan 10 20,并设置vlan 1为二层的vlan 1 的网关,设置vlan 10 20 的中继

配置命令: 二层交换机 Switch>en Switch#configure terminal Enter configuration commands, one per line. End with CNTL/Z. Switch(config)#vlan 10 Switch(config-vlan)#vlan 20 Switch(config-vlan)#exi Switch(config)#int f0/1 Switch(config-if)#no shu Switch(config-if)#sw mo a Switch(config-if)#sw a v 10 Switch(config-if)#exit Switch(config)#int f0/2 Switch(config-if)#sw mo a Switch(config-if)#sw a v 20 Switch(config-if)#exit Switch(config)#int f0/3 Switch(config-if)#sw mo tr Switch(config-if)#exit Switch(config)#int vlan 1 %LINK-5-CHANGED: Interface Vlan1, changed state to up %LINEPROTO-5-UPDOWN: Line protocol on Interface Vlan1, changed state to up ip add 10.10.1.1 255.255.255.0 Switch(config-if)#exit Switch(config)#ip default-gateway 10.10.1.2 Switch(config)#service dhcp Switch(config)#ip dhcp pool a Switch(dhcp-config)#network 192.168.10.0 255.255.255.0 Switch(dhcp-config)#default-router 192.168.10.1 Switch(dhcp-config)#dns-server 8.8.8.8 Switch(dhcp-config)#exit Switch(dhcp-config)#network 192.168.20.0 255.255.255.0 Switch(dhcp-config)#default-router 192.168.20.1 Switch(dhcp-config)#dns-server 8.8.8.8 Switch(dhcp-config)#exit Switch(config)#

多层交换机 Switch>en Switch#configure t Enter configuration commands, one per line. End with CNTL/Z. Switch(config)#int f0/3 Switch(config-if)#switchport trunk encapsulation dot1q Switch(config-if)#switchport mode trunk Switch(config-if)#ex Switch(config)#int vlan 1 Switch(config-if)#no shu Switch(config-if)#exit Switch(config)#ip routing Switch(config)#int vlan 10 Switch(config-if)#ip address 192.168.10.1 255.255.255.0 Switch(config-if)#exit Switch(config)#int vlan 20 Switch(config-if)#ip address 192.168.20.1 255.255.255.0 Switch(config-if)#exit Switch(config)#service dhcp Switch(config)#int vlan 10 Switch(config-if)#ip helper-address 10.10.1.1 Switch(config-if)#exit Switch(config)#int vlan 20 Switch(config-if)#ip helper-address 10.10.1.1