interface fa 0/3 switchport mode access switchport access vlan 10 //将财务部划入vlan 10 exit interface fa 0/4 switchport mode access switchport access vlan 20 //将人事部划入vlan 20 exit interface fa 0/5 switchport mode access switchport access vlan 30 //将业务部划入 vlan30 exit interface range fa 0/1-2 switchport mode access switchport mode trunk no shutdown Exit confi t inter range fa 0/6-24 //进入一组端口的配置模式 switchport mode access switchport port-security //配置交换机的端口安全功能 switchport port-security maximum 4 //设置最大允许连接数量为4 switchport port-security violation shutdown end config t SW2(注:此Hostname sw2 代码在特权vlan 40 模式下输入) vlan 50
vlan 60 exit interface fa 0/3 switchport mode access switchport access vlan 40 //将工程部划入vlan40 exit interface fa 0/4 switchport mode access switchport access vlan 50 //将策划部划入vlan50 exit interface fa 0/5 switchport mode access switchport access vlan 60 //将技术部划入vlan60 exit interface range fa 0/1-2 switchport mode access switchport mode trunk no shutdown exit inter range fa 0/6-24 //进入一组端口的配置模式 switchport mode access switchport port-security //配置交换机的端口安全功能 switchport port-security maximum 4 //设置最大允许连接数量为4 switchport port-security violation shutdown //配置安全违例的处理方式为shutdown end config t SW3(注:此Hostnme sw3 代码在特权vlan 10 模式下输入) vlan 20
vlan 30 exit interface range fa 0/3-4 //交换机之间配置TRUNK链路 switchport mode access switchport mode trunk no shutdown exit interface aggregateport 1 //创建聚合接口AGI switchport mode access switchport mode trunk //配置AG模式为trunk exit interface range fa 0/1-2 //进入接口0/1和0/2 port-group 1 //配置接口0/1和0/2属于AGI exit spanning-tree //开启生成树协议 spanning-tree mode rstp //指定生成树协议的类型为RSTP interface vlan 10 //配置SVI ip address 172.16.10.1 255.255.255.0 no shutdown exit interface vlan 20 ip address 172.16.20.1 255.255.255.0 no shutdown exit interface vlan 30 ip address 172.16.30.1 255.255.255.0 no shutdown exit interface fa 0/24
no switchport ip address 10.1.1.2 255.255.255.0 no shutdown exit ip route 0.0.0.0 0.0.0.0 10.1.1.1 //配置默认路由 inter range fa 0/5-23 //进入一组端口的配置模式 switchport mode access switchport port-security //配置交换机的端口安全功能 switchport port-security maximum 4 //设置最大允许连接数量为4 switchport port-security violation shutdown //配置安全违例的处理方式为shutdown exit inter vlan 10 standby 2 priority 200 //配置优先级 standby 2 ip 172.16.10.254 //配置vrrp组和虚拟路由器的IP地址 inter vlan 20 standby 2 priority 160 //配置优先级 standby 2 ip 172.16.20.254 //配置vrrp组和虚拟路由器的IP地址 inter vlan 30 standby 2 priority 120 //配置优先级 standby 2 ip 172.16.30.254 //配置vrrp组和虚拟路由器的IP地址 exit config t Hostname sw4 vlan 40 SW4(注:此vlan 50 代码在特权vlan 60 模式下输入) exit interface range fa 0/3-4 switchport mode access