把交換機的F0/1~F0/3定義爲一個3層SVI接口,IP地址爲192.168.1.1/24。把F0/10定義爲一個3層路由口,IP地址爲192.168.2.1/24。
配置交換機:
Switch>enable Switch#configure terminal ! 創建一個和SVI對應的VLAN Switch(config)#vlan 2 Switch(config-vlan)#name VLAN2 Switch(config-vlan)#exit ! 把F0/1~F0/3指派給VLAN2 Switch(config)#interface f0/1 Switch(config-if)#switchport access vlan 2 Switch(config-if)#interface f0/2 Switch(config-if)#switchport access vlan 2 Switch(config-if)#interface f0/3 Switch(config-if)#switchport access vlan 2 ! 爲VLAN2配置IP地址,使它成爲一個3層SVI接口 Switch(config-if)#interface vlan 2 Switch(config-if)#ip address 192.168.1.1 255.255.255.0 Switch(config-if)#no shutdown ! 把F0/10配置爲3層路由口 Switch(config-if)#interface f0/10 Switch(config-if)#no switchport Switch(config-if)#ip address 192.168.2.1 255.255.255.0 Switch(config-if)#exit ! 啓用IP路由 Switch(config)#ip routing Switch(config)#exit ! 查看配置結果 Switch#show vlan Switch#show running-config Switch#show ip route ! 保存配置 Switch#copy running-config startup-config |
說明:
SVI是一種和VLAN相對應的3層口,你只需要給VLAN配置一個IP地址就成了SVI接口。
SVI是一種由多個物理接口組成的3層口,用它們連接的計算機構成一個網段,比如圖中的PC1、PC2、PC3與SVI在同一個網段中,彼此可以共享資源。
在實際應用中,SVI多用做交換機的管理接口,你也可以通過SVI使處於不同網段的VLAN可以通信。
效果驗證:
PC1、PC2、PC3彼此間可以通信,也能通過“網上鄰居”共享文件。它們和PC4可以通信,但不能通過“網上鄰居”共享文件。