网络拓扑结构如下图所示:
3560配置:
Switch>enable
Switch#config terminal
Switch(config)#hostname 3560
3560(config)#enable secret glable
3560(config)#line vty 0 15
3560(config-line)#password telnet
3560(config-line)#login
3560(config-line)#exit
3560(config)#exit
3560#vlan database
3560(vlan)#vtp domain full
3560(vlan)#vtp server
3560(vlan)#exit
3560#config terminal
3560(config)#vlan 2
3560(config-vlan)#vlan 3
3560(config-vlan)#vlan 4
3560(config-vlan)#interface f0/1
3560(config-if)#switchport trunk allowed vlan all
3560(config-if)#switchport trunk encapsulation dot1q
3560(config-if)#switchport mode trunk
3560(config-if)#interface f0/2
3560(config-if)#switchport trunk allowed vlan all
3560(config-if)#switchport trunk encapsulation dot1q
3560(config-if)#switchport mode trunk
3560(config-if)#interface vlan 2
3560(config-if)#ip address 192.168.1.254 255.255.255.0
3560(config-if)#no shutdown
3560(config-if)#interface vlan 3
3560(config-if)#ip address 192.168.2.254 255.255.255.0
3560(config-if)#no shutdown
3560(config-if)#interface vlan 4
3560(config-if)#ip address 192.168.3.254 255.255.255.0
3560(config-if)#no shutdown
3560(config-if)#exit
3560(config)#exit
3560#write
2960A配置:
Switch>
Switch>enalbe
Switch#config terminal
Enter configuration commands, one per line. End with CNTL/Z.
Switch(config)#hostname Market
Market(config)#enable secret 12345
Market(config)#line vty 0 15
Market(config-line)#password telnet
Market(config-line)#login
Market(config-line)#exit
Market(config)#exit
Market#vlan
Market#vlan database
Market(vlan)#vtp domain full
Market(vlan)#vtp client
Market(vlan)#exit
Market#config terminal
Market(config)#interface f0/1
Market(config-if)#switchport mode trunk
Market(config-if)#switchport trunk allowed vlan all
Market(config-if)#interface range f0/2-24
Market(config-if-range)#switchport access vlan 2
Market(config-if-range)#exit
Market(config)#exit
Market#write
2960B配置:
Switch>enable
Switch#config terminal
Switch(config)#hostname pro
pro(config)#enable secret 1234
pro(config)#line vty 0 15
pro(config-line)#password telnet
pro(config-line)#login
pro(config-line)#exit
pro(config)#exit
pro#vlan database
pro(vlan)#vtp domain full
pro(vlan)#vtp client
pro(vlan)#exit
pro(config)#int f0/1
pro(config-if)#switchport mode trunk
pro(config-if)#switchport trunk allowed vlan all
pro(config-if)#int f0/2
pro(config-if)#switchport access vlan 3
pro(config-if)#int f0/20
pro(config-if)#switchport access vlan 4
pro(config-if)#exit
pro(config)#exit
pro#write
配置电脑0
IP:192.168.1.1
子网掩码:255.255.255.0
网关:192.168.1.254
配置电脑1
IP:192.168.2.1
子网掩码:255.255.255.0
网关:192.168.2.254
配置电脑2
IP:192.168.3.1
子网掩码:255.255.255.0
网关:192.168.3.254
电脑之间两两互ping,收包正常,网络搭建完成。