我们知道,现在一个物理服务器上,为了节省资源,会安装多个虚拟机,分配给多个客户。不同客户又分属不同的vlan。
1、服务器安装虚拟机后,多个虚拟机分属不同vlan,因此交换机接口需要配置为Trunk模式。
比如虚拟机A,属于VLAN 10,流量从交换机Trunk发出时,会打上VLAN10的tag。
虚拟机B,属于VLAN 20,流量从交换机Trunk发出时,会打上VLAN20的tag。
switchport trunk encapsulation dot1q
switchport mode trunk
2、交换机接口,因为二层生成树,需要经过生Discarding、Learning,才能到达forwarding状态。为了加快网络启动,虽然接口是Trunk模式,但接口的生成树配置为快速模式,这样接口从down--->up,不需要经过等待,直接就进入转发状态。
spanning-tree portfast
3、管理员网段(比如vlan 200),用来直接配置服务器,在交换机接口配置为本征Vlan (native),管理流量从交换机trunk口,发往服务器,流量不会打标(untag)
switchport trunk native vlan 200
4、为了防止服务器<----->交换机,之间被不良分子偷偷加装交换机(可能性不大,因为服务器在机房机柜)窃取流量,因此配置端口安全
switchport port-security violation protect //生成报告
switchport port-security mac-address aabb.cc00.1c00
interface Ethernet1/0
switchport trunk encapsulation dot1q
switchport trunk native vlan 200
switchport mode trunk
switchport port-security violation protect
switchport port-security mac-address aabb.cc00.1c00
duplex auto
spanning-tree portfast