欢迎您访问 最编程 本站为您分享编程语言代码,编程技术文章!
您现在的位置是: 首页

使用 Cisco Packer Trace 的第 3 层交换机 + 路由器共享上网功能

最编程 2024-03-19 07:59:20
...
Switch# conf t 
Enter configuration commands, one per line.  End with CNTL/Z. 
Switch(config)# vlan 2    创建VLAN2 
Switch(config-vlan)# exi 
Switch(config)# vlan 3    创建VLAN3 
Switch(config-vlan)# exi 
Switch(config)# vlan 4    创建VLAN4 
Switch(config-vlan)# exit 
Switch(config)# int fa0/1     将我们的fa0/1添加到VLAN2中 
Switch(config-if)# sw mo ac 
Switch(config-if)# sw ac vlan 2 
Switch(config-if)# exit 
Switch(config)# int fa0/2    将我们的FA0/2添加到VLAN3中 
Switch(config-if)# sw mo ac 
Switch(config-if)# sw ac vlan 3 
Switch(config-if)# exit 
Switch(config)# int fa0/3    将我们的FA0/3添加到VLAN4中 
Switch(config-if)# sw mo ac 
Switch(config-if)# sw ac vlan 4 
Switch(config-if)# exit 
Switch(config)# int vlan 2     给我们的VLAN2添加一个IP地址,用于不同网段之间互相访问 
Switch(config-if)# ip add 192.168.1.1 255.255.255.0 
Switch(config-if)# exit 
Switch(config)# int vlan 3     给我们的VLAN3添加一个IP地址     
Switch(config-if)# ip add 192.168.2.1 255.255.255.0 
Switch(config-if)# exit 
Switch(config)# int vlan 4     给我们的VLAN4添加一个IP地址 
Switch(config-if)# ip add 192.168.3.1 255.255.255.0 
Switch(config-if)# no shut 
Switch(config-if)# exit 
以下几行是用给给我们不同的VLAN内的主机自动分配我们的IP地址。 
Switch(config)# ip dhcp pool VLAN2 
Switch(dhcp-config)# network 192.168.1.0 255.255.255.0 
Switch(dhcp-config)# default-router 192.168.1.1 
Switch(dhcp-config)# exit 
Switch(config)# ip dhcp pool VLAN3 
Switch(dhcp-config)# network 192.168.2.0 255.255.255.0 
Switch(dhcp-config)# default-router 192.168.2.1 
Switch(dhcp-config)# exit 
Switch(config)#