最近,在使用Boson NetSim v7.02配置实验时,老是出现莫名其妙的问题,明明配置正确,却死活都ping不通,只好使用cisco 专用的Packeg Tracer来验证了,毕竟手头上没有cisco 3560的设备。
一、拓扑图如下:
在3560上分四个VLAN:10、20、30、80,其中VLAN80用于服务器,可供各个VLAN访问,2950暂做傻瓜交换机用。
二、要求各VLAN间可互访,在3560上主要配置如下:
SW3560#show run
Building configuration...
Current configuration : 1499 bytes
!
version 12.2
no service timestamps log datetime msec
no service timestamps debug datetime msec
no service password-encryption
!
hostname SW3560
!
ip routing((必须启用路由功能,否则三层交换机的功能也就等价于二层交换机))
!
no ip domain-lookup
!
interface FastEthernet0/1
switchport access vlan 80
switchport mode access
!
interface FastEthernet0/2
switchport access vlan 10
switchport mode access
!
interface FastEthernet0/3
switchport access vlan 20
switchport mode access
!
interface FastEthernet0/4
switchport access vlan 30
switchport mode access
!
interface FastEthernet0/5
!
。。。。。。
interface FastEthernet0/24
!
interface GigabitEthernet0/1
!
interface GigabitEthernet0/2
!
interface Vlan1
no ip address
shutdown
!
interface Vlan10
ip address 192.168.10.1 255.255.255.0
!
interface Vlan20
ip address 192.168.20.1 255.255.255.0
!
interface Vlan30
ip address 192.168.30.1 255.255.255.0
!
interface Vlan80
ip address 192.168.80.1 255.255.255.0
!
ip classless
!
End
三、要求各VLAN间不可互访,只能访问VLAN80内的服务器,通过ACL来实现,访问规则需绑定在SVI(见下文解释)接口上。3560上配置如下:
SW3560#show run
Building configuration...
Current configuration : 1664 bytes
!
version 12.2
no service timestamps log datetime msec
no service timestamps debug datetime msec
no service password-encryption
!
hostname SW3560
!
ip routing
!
no ip domain-lookup
!
interface FastEthernet0/1
switchport access vlan 80
switchport mode access
!
interface FastEthernet0/2
switchport access vlan 10
switchport mode access
!
interface FastEthernet0/3
switchport access vlan 20
switchport mode access
!
interface FastEthernet0/4
switchport access vlan 30
switchport mode access
!
interface FastEthernet0/5
!
。。。。。。
interface FastEthernet0/24
!
interface GigabitEthernet0/1
!
interface GigabitEthernet0/2
!
interface Vlan1
no ip address
shutdown
!
interface Vlan10
ip address 192.168.10.1 255.255.255.0
ip access-group 110 in
!
interface Vlan20
ip address 192.168.20.1 255.255.255.0
ip access-group 110 in
!
interface Vlan30
ip address 192.168.30.1 255.255.255.0
ip access-group 110 in
!
interface Vlan80
ip address 192.168.80.1 255.255.255.0
!
ip classless
!
access-list 110 permit ip any host 192.168.80.2(注:只允许任意主机访问FTP Serv 192.168.80.2)
access-list 110 deny ip any any(注:拒绝任意主机访问任意主机)
!
end
四、各PC设置如上图所示,网关均为3560上设置的各自VLAN的IP地址。
五、配置SVI(switch virtual interface)接口
三层交换机的物理接口既可以配置为2层接口,也可以配置为三层接口,除了交换机物理接口外,交换机还可以将某个VLAN配置为3层接口,称为SVI
(switch virtual interface)接口,将VLAN配置为3层接口的作用在于为VLAN内的流量与外部流量提供3层路由转发功能,该VLAN内所有的流量都应该在同网段,而该VLAN的主机网关都应该指向SVI接口地址。此时的SVI接口,其实也等同于路由器的接口,但是SVI接口也只有在状态都为UP的时候,才能提供路由功能,一个状态为down的SVI接口是不能发送数据包的。要将SVI接口激活并且变成UP状态,必须将一个活动的物理接口划入该VLAN,当某VLAN中没有活动物理接口时,该VLAN的SVI接口永远将处于down状态而不能转发数据。需要大家注意的是,一个Trunk接口允许某个VLAN通过,就表示该Trunk接口属于该VLAN,也就是说某个VLAN被一个活动的Trunk接口允许通过时,那么就说明该VLAN中存在活动的物理接口,因此,该VLAN的SVI接口可以变成UP状态,也就可以转发数据包。
(1)创建SVI接口,并配置IP地址
Switch(config)#vlan 2
Switch(config-vlan)#exit
Switch(config)#int vlan 2
Switch(config-if)#ip add 2.2.2.2 255.255.255.0
说明:创建SVI接口时,必须保证该VLAN已经在交换机上存在。
结论:在模拟器上启不启用ip routing各VLAN间均可实现通信,但在实际操作中,必须启用ip routing,否则三层交换机的功能也就等价于二层交换机)。引用一个网友的话:“据我的实际操作结论:如果在三层交换机上创建了多个vlan,而vlan ip作为主机的网关,要使不同vlan在本交换机上直接通讯,就要执行ip routing命令,不然的话vlan之间无法通讯。在执行ip routing之前没有执行no ip routing。”