您好,欢迎来电子发烧友网! ,新用户?[免费注册]

您的位置:电子发烧友网>电子百科>网络>网络交换机>

三层交换机配置实例详解

2018年03月06日 10:45 网络整理 作者: 用户评论(0

在校园网、城域教育网中,从骨干网、城域网骨干、汇聚层都有三层交换机的用武之地,尤其是核心骨干网一定要用三层交换机,否则整个网络成千上万台的计算机都在一个子网中,不仅毫无安全可言,也会因为无法分割广播域而无法隔离广播风暴。如果采用传统的路由器,虽然可以隔离广播,但是性能又得不到保障。而三层交换机的性能非常高,既有三层路由的功能,又具有二层交换的网络速度。二层交换是基于MAC寻址,三层交换则是转发基于第三层地址的业务流;除了必要的路由决定过程外,大部分数据转发过程由二层交换处理,提高了数据包转发的效率。三层交换机通过使用硬件交换机构实现了IP的路由功能,其优化的路由软件使得路由过程效率提高,解决了传统路由器软件路由的速度问题。因此可以说,三层交换机具有“路由器的功能、交换机的性能”。

另外,连接子网少不了三层交换换。同一网络上的计算机如果超过一定数量(通常在200台左右,视通信协议而定),就很可能会因为网络上大量的广播而导致网络传输效率低下。为了避免在大型交换机上进行广播所引起的广播风暴,可将其进一步划分为多个虚拟网(VLAN)。但是这样做将导致一个问题:VLAN之间的通信必须通过路由器来实现。但是传统路由器也难以胜任VLAN之间的通信任务,因为相对于局域网的网络流量来说,传统的普通路由器的路由能力太弱。 而且千兆级路由器的价格也是非常难以接受的。如果使用三层交换机上的千兆端口或百兆端口连接不同的子网或VLAN,就在保持性能的前提下,经济地解决了子网划分之后子网之间必须依赖路由器进行通信的问题,因此三层交换机是连接子网的理想设备。

三层交换机详细配置实例

一:二层交换机的配置:

在三个二层交换机上分别划出两VLAN,并将二层交换机上与三层交换或路由器上的接线设置为trunk接口

二:三层交换机的配置:

1:首先在三层交换上划出两个VLAN,并进入VLAN为其配置IP,此IP将作为与他相连PC的网关。

2:将与二层交换机相连的线同样设置为trunk接线,并将三层交换与路由器连接的线设置为路由接口(no switchsport)

3:将路由器和下面的交换机进行单臂路由的配置 实验最终结果:拓扑图下各个PC均能相互通信

三层交换机配置实例

交换机的配置命令:

SW 0:

Switch》 Switch》en Switch#conf

Configuring from terminal, memory, or network [terminal]? Enter configuration commands, one per line. End with CNTL/Z. Switch(config)#vlan 2 Switch(config-vlan)#exit Switch(config)#int f0/2

Switch(config-if)#switchport access vlan 2 Switch(config-if)#no shut Switch(config-if)#int f0/3

Switch(config-if)#switchport mode trunk

%LINEPROTO-5-UPDOWN: Line protocol on Interface FastEthernet0/3, changed state to down

%LINEPROTO-5-UPDOWN: Line protocol on Interface FastEthernet0/3, changed state to up

Switch(config-if)#exit Switch(config)#

SW 1:

Switch》en Switch#conf

Configuring from terminal, memory, or network [terminal]? Enter configuration commands, one per line. End with CNTL/Z. Switch(config)#int f0/2

Switch(config-if)#switchport access vlan 2 % Access VLAN does not exist. Creating vlan 2 Switch(config-if)#no shut Switch(config-if)#exit Switch(config)#int f0/3

Switch(config-if)#switchport mode trunk

%LINEPROTO-5-UPDOWN: Line protocol on Interface FastEthernet0/3, changed state to down

%LINEPROTO-5-UPDOWN: Line protocol on Interface FastEthernet0/3, changed state to up

Switch(config-if)#

SW 2:

Switch》en

Switch#conf

Configuring from terminal, memory, or network [terminal]? Enter configuration commands, one per line. End with CNTL/Z.

Switch(config)#int f0/2

Switch(config-if)#switchport access vlan 2 % Access VLAN does not exist. Creating vlan 2 Switch(config-if)#exit

Switch(config)#int f0/3

Switch(config-if)#switchport mode trunk Switch(config-if)#

三层交换的配置命令:

Switch》en Switch#conf

Configuring from terminal, memory, or network [terminal]? Enter configuration commands, one per line. End with CNTL/Z. Switch(config)#int f0/1

Switch(config-if)#switchport mode trunk

%LINEPROTO-5-UPDOWN: Line protocol on Interface FastEthernet0/2, changed state to down

Switch(config-if)#exit Switch(config)#int f0/2

Switch(config-if)#switchport mode trunk Switch(config-if)#exit Switch(config)#vlan 2 Switch(config-vlan)#exit Switch(config)#int vlan 1 Switch(config-if)#no shut

%LINK-5-CHANGED: Interface Vlan1, changed state to up

%LINEPROTO-5-UPDOWN: Line protocol on Interface Vlan1, changed state to up Switch(config-if)#ip address 192.168.1.168 255.255.255.0 Switch(config-if)#exit Switch(config)#int vlan 2

%LINK-5-CHANGED: Interface Vlan2, changed state to up

%LINEPROTO-5-UPDOWN: Line protocol on Interface Vlan2, changed state to upSwitch(config-if)#ip add

Switch(config-if)#ip address 192.168.2.168 255.255.255.0 Switch(config-if)#

%LINK-5-CHANGED: Interface FastEthernet0/3, changed state to up

%LINEPROTO-5-UPDOWN: Line protocol on Interface FastEthernet0/3, changed state to up

Switch(config-if)#exit Switch(config)#int f0/3

Switch(config-if)#no switchport

%LINEPROTO-5-UPDOWN: Line protocol on Interface FastEthernet0/3, changed state to down

%LINEPROTO-5-UPDOWN: Line protocol on Interface FastEthernet0/3, changed state to upSwitch(config-if)#

Switch(config-if)#ip address 192.168.10.1 255.255.255.0 Switch(config-if)#no shut Switch(config-if)#exit Switch(config)#ip routing Switch(config-if)#exit

Switch(config)#ip route 0.0.0.0 0.0.0.0 192.168.10.2 Switch(config)# 路由器的配置:

Router》en Router#conf

Configuring from terminal, memory, or network [terminal]? Enter configuration commands, one per line. End with CNTL/Z. Router(config)#int f0/0 Router(config-if)#no shut

%LINK-5-CHANGED: Interface FastEthernet0/0, changed state to up Router(config-if)#exit Router(config)#int f0/1 Router(config-if)#no shut

%LINK-5-CHANGED: Interface FastEthernet0/1, changed state to up

%LINEPROTO-5-UPDOWN: Line protocol on Interface FastEthernet0/1, changed state to up

Router(config-if)#exit Router(config)#int f0/0 Router(config-if)#no shut Router(config-if)#exit Router(config)#int f0/0.1

Router(config-subif)#encapsulation dot1Q 1

Router(config-subif)#ip address 192.168.3.168 255.255.255.0 Router(config-subif)#exit Router(config)#int f0/0.2

Router(config-subif)#encapsulation dot1Q 2 Router(config-subif)#ip add

Router(config-subif)#ip address 192.168.4.168 255.255.255.0 Router(config-subif)#exit

Router(config)#ip route 0.0.0.0 0.0.0.0 192.168.10.1 Router(config)#exit

%SYS-5-CONFIG_I: Configured from console by console Router#conf

Configuring from terminal, memory, or network [terminal]? Enter configuration commands, one per line. End with CNTL/Z.

Router(config)#int f0/1

Router(config-if)#ip add

Router(config-if)#ip address 192.168.10.2 255.255.255.0

Router(config-if)#

非常好我支持^.^

(143) 44%

不好我反对

(182) 56%

( 发表人:李倩 )

      发表评论

      用户评论
      评价:好评中评差评

      发表评论,获取积分! 请遵守相关规定!