三层交换机配置实例

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

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

你可能感兴趣的:(交换机配置实例)