您好,歡迎來(lái)電子發(fā)燒友網(wǎng)! ,新用戶?[免費(fèi)注冊(cè)]

您的位置:電子發(fā)燒友網(wǎng)>電子百科>網(wǎng)絡(luò)>網(wǎng)絡(luò)交換機(jī)>

三層交換機(jī)配置實(shí)例詳解

2018年03月06日 10:45 網(wǎng)絡(luò)整理 作者: 用戶評(píng)論(0
關(guān)鍵字:三層交換機(jī)(9512)

在校園網(wǎng)、城域教育網(wǎng)中,從骨干網(wǎng)、城域網(wǎng)骨干、匯聚層都有三層交換機(jī)的用武之地,尤其是核心骨干網(wǎng)一定要用三層交換機(jī),否則整個(gè)網(wǎng)絡(luò)成千上萬(wàn)臺(tái)的計(jì)算機(jī)都在一個(gè)子網(wǎng)中,不僅毫無(wú)安全可言,也會(huì)因?yàn)闊o(wú)法分割廣播域而無(wú)法隔離廣播風(fēng)暴。如果采用傳統(tǒng)的路由器,雖然可以隔離廣播,但是性能又得不到保障。而三層交換機(jī)的性能非常高,既有三層路由的功能,又具有二層交換的網(wǎng)絡(luò)速度。二層交換是基于MAC尋址,三層交換則是轉(zhuǎn)發(fā)基于第三層地址的業(yè)務(wù)流;除了必要的路由決定過(guò)程外,大部分?jǐn)?shù)據(jù)轉(zhuǎn)發(fā)過(guò)程由二層交換處理,提高了數(shù)據(jù)包轉(zhuǎn)發(fā)的效率。三層交換機(jī)通過(guò)使用硬件交換機(jī)構(gòu)實(shí)現(xiàn)了IP的路由功能,其優(yōu)化的路由軟件使得路由過(guò)程效率提高,解決了傳統(tǒng)路由器軟件路由的速度問(wèn)題。因此可以說(shuō),三層交換機(jī)具有“路由器的功能、交換機(jī)的性能”。

另外,連接子網(wǎng)少不了三層交換換。同一網(wǎng)絡(luò)上的計(jì)算機(jī)如果超過(guò)一定數(shù)量(通常在200臺(tái)左右,視通信協(xié)議而定),就很可能會(huì)因?yàn)榫W(wǎng)絡(luò)上大量的廣播而導(dǎo)致網(wǎng)絡(luò)傳輸效率低下。為了避免在大型交換機(jī)上進(jìn)行廣播所引起的廣播風(fēng)暴,可將其進(jìn)一步劃分為多個(gè)虛擬網(wǎng)(VLAN)。但是這樣做將導(dǎo)致一個(gè)問(wèn)題:VLAN之間的通信必須通過(guò)路由器來(lái)實(shí)現(xiàn)。但是傳統(tǒng)路由器也難以勝任VLAN之間的通信任務(wù),因?yàn)橄鄬?duì)于局域網(wǎng)的網(wǎng)絡(luò)流量來(lái)說(shuō),傳統(tǒng)的普通路由器的路由能力太弱。 而且千兆級(jí)路由器的價(jià)格也是非常難以接受的。如果使用三層交換機(jī)上的千兆端口或百兆端口連接不同的子網(wǎng)或VLAN,就在保持性能的前提下,經(jīng)濟(jì)地解決了子網(wǎng)劃分之后子網(wǎng)之間必須依賴路由器進(jìn)行通信的問(wèn)題,因此三層交換機(jī)是連接子網(wǎng)的理想設(shè)備。

三層交換機(jī)詳細(xì)配置實(shí)例

一:二層交換機(jī)的配置:

在三個(gè)二層交換機(jī)上分別劃出兩VLAN,并將二層交換機(jī)上與三層交換或路由器上的接線設(shè)置為trunk接口

二:三層交換機(jī)的配置:

1:首先在三層交換上劃出兩個(gè)VLAN,并進(jìn)入VLAN為其配置IP,此IP將作為與他相連PC的網(wǎng)關(guān)。

2:將與二層交換機(jī)相連的線同樣設(shè)置為trunk接線,并將三層交換與路由器連接的線設(shè)置為路由接口(no switchsport)

3:將路由器和下面的交換機(jī)進(jìn)行單臂路由的配置 實(shí)驗(yàn)最終結(jié)果:拓?fù)鋱D下各個(gè)PC均能相互通信

三層交換機(jī)配置實(shí)例

交換機(jī)的配置命令:

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%

不好我反對(duì)

(182) 56%

( 發(fā)表人:李倩 )

      發(fā)表評(píng)論

      用戶評(píng)論
      評(píng)價(jià):好評(píng)中評(píng)差評(píng)

      發(fā)表評(píng)論,獲取積分! 請(qǐng)遵守相關(guān)規(guī)定!

      ?