今天我配置的实验有两大快,一是三层交换,二是单臂路由,三层交换主要来替换单臂路由,为什么我还要配呢,一些小公司,上网的人多,但又不想买三层设备,所以就要用到单臂路由.

 
 
 
 
三层交换机配置实例_第1张图片
 
这个拓扑图主要实现以下功能:
 
    配置VTP域,减轻管理员工作量,配置PVST,避免环路的产生,做好DHCP中继,使不同vlanPC能够动态获取IP地址,设置以太网通道,增加数据流量,三层交换机配置路由功能,使不同vlan 之间的通信,
大体配置和思路如下:
 
1IP规划:
 
3550-1 vlan10 :192.168.1.1   255.255.255.0   
3550-1 vlan20 :192.168.2.1   255.255.255.0 
3550-1 vlan30 :192.168.3.1   255.255.255.0   
3550-1 vlan40 :192.168.4.1   255.255.255.0
3550-2 vlan10 :192.168.1.2   255.255.255.0  
3550-2 vlan20 :192.168.2.2   255.255.255.0
3550-2 vlan30 :192.168.3.2   255.255.255.0
3550-2 vlan40 :192.168.4.2   255.255.255.0  
3550-2   f0/7    192.168.5.1   255.255.255.0
R1  f0/1 :192.168.5.2  255.255.255.0        
R1  f0/2 :192.168.6.1 255.255.255.0  
R2  f0/1 :192.168.6.2  255.255.255.0        
R2 f0/2.1 :192.168.7.1  255.255.255.0        
R2 f0/2.2 :192.168.8.1 255.255.255.0
DHCP :192.168.1.3 255.255.255.0 192.168.1.1
PC1:192.168.2.3 255.255.255.0 192.168.2.1 
PC2:192.168.3.3 255.255.255.0 192.168.3.2
PC3:192.168.4.3 255.255.255.0 192.168.4.2 
PC4:192.168.7.2 255.255.255.0 192.168.7.1
PC5:192.168.8.2 255.255.255.0 192.168.8.1
 
2,线缆规划:
 
SW1f0/1端口连接3550-1 f0/1端口f0/2端口连接3550-2 f0/1端口f0/3端口连接DHCP服务器,属于Vlan 1;
SW2f0/1端口连接3550-1 f0/2端口f0/2端口连接3550-2 f0/2端口f0/3端口连接PC1机,属于Vlan 2;
SW3f0/1端口连接3550-1 f0/3端口f0/2端口连接3550-2 f0/3端口f0/3端口连接PC2机,属于Vlan 3;
SW4f0/1端口连接3550-1 f0/4端口f0/2端口连接3550-2 f0/4端口f0/3端口连接PC3机,属于Vlan 4;
3550-1 f0/5 端口连接3550-2 f0/5    3550-1 f0/6 端口连接3550-2 f0/6
3550-2 f0/7 端口连接 R1 f0/1   R1 f0/2端口连接 R2 f0/1   R2 f0/2端口连接 SW5 f0/24
SW5 f0/1 端口连接 PC4     SW5 f0/2 端口连接 PC5
 
3VTP配置:
 
VTP 的域名 VTP 的密码 VTP 的修剪 配置两台3550VTP server 模式 配置其他交换机为client模式
 
4STP 配置:
 
设置3550-1Vlan1-Vlan2 的生成树根网桥   设置3550-2Vlan3-Vlan4 的生成树根网桥
在接入层交换机上配置速端口和上行速链路
 
5,三层交换机的配置:
 
在其中一台交换机上划分Vlan;   在三层交换机上配置各个VlanIP地址,
配置两台三层交换机之间的以太网通道(EthernetChannel
配置3550-2交换机的路由接口         在三层交换机上配置RIP协议
 
6,路由器的配置
 
配置路由器接口的IP地址      配置路由器的RIP协议
R2上配置单臂路由        
 
7,配置SW5
 
 SW5上划分Vlan   PC4PC5添加进去
 
好了,规划完了,下面我们开始命令行配置吧:
 
3550-1的配置如下:
 
配置交换机的三层路由功能 
 
3550-1#config terminal
3550-1#ip routing                           // 启用三层路由功能
配置VTP域:
3550-1>enable
3550-1#config terminal
3550-1#vtp domain benet               // 创建VTP
3550-1#vtp password 123              // VTP域的密码
3550-1#vtp pruning                        // 起用VTP修剪
3550-1#vtp mode server                // 配置交换机为vtp server模式
3550-1#exit                                   // 返回下一级
配置VLAN
3550-1#vlan database                                 // 进入vlan数据库
3550-1#vlan 10 name vlan10            // 创建vlan 10
3550-1#vlan 20 name vlan20            // 创建vlan 20 
3550-1#vlan 30 name vlan30            // 创建vlan 30
3550-1#vlan 40 name vlan40            // 创建vlan 40
3550-1#exit
配置vlan IP地址:
3550-1#config terminal                                   
3550-1#interface vlan10                           
3550-1#ip address 192.168.1.1 255.255.255.0      
3550-1#exit
3550-1#interface vlan20
3550-1#ip address 192.168.2.1 255.255.255.0
3550-1#exit
3550-1#interface vlan30
3550-1#ip address 192.168.3.1 255.255.255.0
3550-1#exit
3550-1#interface vlan40
3550-1#ip address 192.168.4.1 255.255.255.0
3550-1#exit
配置RIP协议:
3550-1#config terminal
3550-1#ip routing
3550-1#router rip
3550-1#network 192.168.1.0
3550-1#network 192.168.2.0
3550-1#network 192.168.3.0
3550-1#network 192.168.4.0
配置PVST:
3550-1#spanning-tree vlan vlan10 root primary     //配置vlan10的根网桥
3550-1#spanning-tree vlan vlan20 root primary     //配置vlan20的根网桥
3550-1#spanning-tree vlan vlan30 root secondary
3550-1#spanning-tree vlan vlan40 root secondary
3550-1#interface range fastEthernet 0/5 – 6         //进入一定端口    
3550-1#channel-group 1 mode on           //配置以太网通道
配置DHCP中继:
3550-1#interface vlan vlan10
3550-1#ip helper-address 192.168.1.3
3550-1#interface vlan vlan20
3550-1#ip helper-address 192.168.1.3
 
3550-2的配置如下:
 
配置交换机的三层路由功能 
3550-2#config terminal
3550-2#ip routing                             
配置VTP域:
 
3550-2>enable
3550-2#config terminal                             
3550-2#vtp domain benet                
3550-2#vtp password 123              
3550-2#vtp pruning                        
3550-2#vtp mode server               
3550-2#exit                                
配置vlan IP地址:
3550-2#config terminal                                
3550-2#interface vlan10                  
3550-2#ip address 192.168.1.2 255.255.255.0      
3550-2#exit
3550-2#interface vlan20
3550-2#ip address 192.168.2.2 255.255.255.0
3550-2#exit
3550-2#interface vlan30
3550-2#ip address 192.168.3.2 255.255.255.0
3550-2#exit
3550-2#interface vlan40
3550-2#ip address 192.168.4.2 255.255.255.0
3550-2#interface f0/7
3550-2#no switchport
3550-2#ip address 192.168.5.1 255.255.255.0
3550-2#no shotdown
3550-2#exit
配置RIP协议:
3550-2#config terminal
3550-2#router rip
3550-1#network 192.168.1.0
3550-1#network 192.168.2.0
3550-1#network 192.168.3.0
3550-1#network 192.168.4.0
3550-1#network 192.168.5.0
配置PVST:
3550-2#spanning-tree vlan vlan30 root primary    
3550-2#spanning-tree vlan vlan40 root primary
3550-2#spanning-tree vlan vlan10 root secondary
3550-2#spanning-tree vlan vlan20 root secondary
    
3550-2#interface range fastEthernet 0/5 – 6          
3550-2#channel-group 1 mode on       
配置DHCP中继:
3550-2#interface vlan vlan30
3550-2#ip helper-address 192.168.1.3
3550-2#interface vlan vlan40
3550-2#ip helper-address 192.168.1.3
 
 
配置交换机:
 
Sw1#config terminal
Sw1#vtp domain benet
Sw1#vtp password 123
Sw1#vtp mode client
Sw1#vtp pruning
Sw1#interface f0/1
Sw1#switchport mode trunk
Sw1#exit
Sw1#interface f0/2
Sw1#switchport mode trunk
Sw1#exit
Sw1#interface f0/3
Sw1#switchport access vlan 10
Sw1#spanning-tree portfast         //端口速链路
Sw1#exit
Sw1#spanning-tree uplinkfast         //上行速端口
 
Sw2#config terminal
Sw2#vtp domain benet
Sw2#vtp password 123
Sw2#vtp mode client
Sw1#vtp pruning
Sw2#interface f0/1
Sw2#switchport mode trunk
Sw2#exit
Sw2#interface f0/2
Sw2#switchport mode trunk
Sw2#exit
Sw2#interface f0/3
Sw2#switchport access vlan 20
Sw2#spanning-tree portfast      
Sw2#exit
Sw2#spanning-tree uplinkfast      
 
Sw3#config terminal
Sw3#vtp domain benet
Sw3#vtp password 123
Sw3#vtp mode client
Sw1#vtp pruning
Sw3#interface f0/1
Sw3#switchport mode trunk
Sw3#exit
Sw3#interface f0/2
Sw3#switchport mode trunk
Sw3#exit
Sw3#interface f0/3
Sw3#switchport access vlan 30
Sw3#spanning-tree portfast      
Sw3#exit
Sw3#spanning-tree uplinkfast      
 
Sw4#config terminal
Sw4#vtp domain benet
Sw4#vtp password 123
Sw4#vtp mode client
Sw1#vtp pruning
Sw4#interface f0/1
Sw4#switchport mode trunk
Sw4#exit
Sw4#interface f0/2
Sw4#switchport mode trunk
Sw4#exit
Sw4#interface f0/3
Sw4#switchport access vlan 40
Sw4#spanning-tree portfast      
Sw4#exit
Sw4#spanning-tree uplinkfast      
 
Sw5 >enable
Sw5#config terminal
Sw5#interface f0/24
Sw5#switchport mode trunk
Sw5#end
Sw5#vlan database
Sw5#vlan 10 valn10
Sw5#vlan 20 valn20
Sw5#exit
Sw5#config terminal
Sw5#interface f0/1
Sw5#switchport access vlan10
Sw5#interface f0/2
Sw5#switchport access vlan20
 
路由器的配置:
 
R1>enable
R1#config terminal
R1#interface f0/1
R1#ip address 192.168.5.2 255.255.255.0
R1#no shotdown
R1#interface f0/2
R1#ip address 192.168.6.1 255.255.255.0
R1#no shotdown
R1#exit
R1#router rip
R1#network 192.168.5.0
R1#router rip
R1#network 192.168.6.0
 
R2>enable
R2#config terminal
R2#interface f0/1
R2#ip address 192.168.6.2 255.255.255.0
R1#no shotdown
R1#exit
R1#interface f0/2
R1#no shotdown
R1#exit
R2#interface f0/2.1
R2#ip address 192.168.7.1 255.255.255.0
R2#encapsolution dot1 10
R2#interface f0/2.2
R2#ip address 192.168.8.1 255.255.255.0
R2#encapsolution dot1 20
R2#exit
R2#router rip
R2#network 192.168.6.0
R2#router rip
R2#network 192.168.7.0
R2#router rip
R2#network 192.168.8.0
 
PC4: IP: 192.168.7.2  mask:255.255.255.0  default-gateway:192.168.7.1
PC5: IP: 192.168.8.2  mask:255.255.255.0  default-gateway:192.168.8.1
 
实验验收:
 
在PC1/PC2/PC3/上动态获取DHCP服务器的地址资源
在PC4/PC5上ping PC1/PC2/PC3/和DHCP服务器
 
排错事使用的命令:
 
show run                          //查看所有的配置
 
show cdp entry *             //查看cisco端口连接的设备
 
show ip router                 //查看本地路由表
 
show ip interface brief      //查看端口的详细信息
 
show vlan brief                //查看vlan的详细信息
 
show vtp status               //查看VTP配置信息
 
show ip cef                     //查看FIB表
 
show adjacency detail     //查看邻接关系表