測試三層交換機ip routing和no switchport命令的區別

wKiom1bLthqh3y4zAACJRoqBpYg125.jpg

PC0

       IP:                 192.168.1.2

       Submark:              255.255.255.0

       Gateway:       192.168.1.1

PC1

       IP:                 192.168.2.2

       Submark:              255.255.255.0

       Gateway:       192.168.2.1   

PC2

       IP:                 192.168.3.2

       Submark:              255.255.255.0

       Gateway:       192.168.3.1

 

配置過程:

Switch>en

Switch#conf t

Enter configuration commands, one per line.  End with CNTL/Z.

 

運行路由協議

Switch(config)#ip routing

端口1由二層轉變爲三層,並

配置IP地址

Switch(config)#int fa0/1

Switch(config-if)#no switchport

Switch(config-if)#

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

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

Switch(config-if)#ip address 192.168.1.1 255.255.255.0

Switch(config-if)#exit

 

端口3由二層轉變爲三層,並配置IP地址

Switch(config)#int fa0/3

Switch(config-if)#no switchport

Switch(config-if)#

%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)#ip address 192.168.3.1 255.255.255.0

Switch(config-if)#no shut

Switch(config-if)#exit

Switch(config)#int fa0/1

Switch(config-if)#no shut

Switch(config-if)#exit

Switch(config)#

 

測試結果:

wKioL1bLt0CymBFzAAI1eDka2ZA708.jpg

 

分析:

普通的可劃vlan的交換機中各vlan之間是不可以通信的,而且只能有一個管理ip,而在三層交換機中每個vlan都可以設置獨立的網關,ip routing這條命令的作用就是運行路由協議,讓每個vlan間實現通信。no switchport命令即打開端口的三層功能。

如上例,fa0/1fa0/3使用no switchport命令開啓了三層功能,由二層端口轉變爲三層端口,fa0/2沒有開啓,還是隻具有二層端口功能。所以PC0PC3可以ping通,而PC0PC2不可以ping通。

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章