交换机trunk和access

交换机端口工作模式简介

端口类型 工作模式
Access类型 端口只能属于1个VLAN,一般用于连接计算机的端口
Trunk类型 端口可以允许多个VLAN通过,可以接收和发送多个VLAN的报文,一般用于交换机之间连接的端口
Hybrid类型 端口可以允许多个VLAN通过,可以接收和发送多个VLAN的报文,可以用于交换机之间连接,也可以用于连接用户的计算机

注:

  • Hybrid端口和Trunk端口在接收数据时,处理方法是一样的,唯一不同之处在于发送数据时:Hybrid端口可以允许多个VLAN的报文发送时不打标签,而Trunk端口只允许缺省VLAN的报文发送时不打标签。也就是说,Trunk端口报文发送一般都要打标,而Hybrid可以允许多个VLAN不打标。
  • 三种类型的端口可以共存在一台以太网交换机上,但Trunk端口和Hybrid端口之间不能直接切换,只能先设为Access端口,再设置为其他类型端口。例如:Trunk端口不能直接被设置为Hybrid端口,只能先设为Access端口,再设置为Hybrid端口。

各种模式接收和发送数据

交换机trunk和access_第1张图片

华为交换机简单操作命令

  1. 通过ssh进入
  2. 进入系统system
  3. 操作具体的端口
    配access模式、VLAN
[~CNPEK-POD23-CE68-A-01]interface 10GE1/0/7
[~CNPEK-POD23-CE68-A-01-10GE1/0/7]undo port link-type
[*CNPEK-POD23-CE68-A-01-10GE1/0/7]undo port default vlan
[*CNPEK-POD23-CE68-A-01-10GE1/0/7]undo qos car inbound
[*CNPEK-POD23-CE68-A-01-10GE1/0/7]undo qos lr outbound
[*CNPEK-POD23-CE68-A-01-10GE1/0/7]undo shutdown
[*CNPEK-POD23-CE68-A-01-10GE1/0/7]q
[*CNPEK-POD23-CE68-A-01]interface 10GE1/0/7
[*CNPEK-POD23-CE68-A-01-10GE1/0/7]port link-type access
[*CNPEK-POD23-CE68-A-01-10GE1/0/7]port default vlan 1799
[*CNPEK-POD23-CE68-A-01-10GE1/0/7]q
[*CNPEK-POD23-CE68-A-01]commit
[~CNPEK-POD23-CE68-A-01]q

配access模式、VLAN

[~POD23-luojinshu-CE68-01]interface 10GE1/0/2
[~POD23-luojinshu-CE68-01-10GE1/0/2]undo port link-type
[*POD23-luojinshu-CE68-01-10GE1/0/2]undo port default vlan
[*POD23-luojinshu-CE68-01-10GE1/0/2]undo qos car inbound
[*POD23-luojinshu-CE68-01-10GE1/0/2]undo qos lr outbound
[*POD23-luojinshu-CE68-01-10GE1/0/2]undo shutdown
[*POD23-luojinshu-CE68-01-10GE1/0/2]q
[*POD23-luojinshu-CE68-01]interface 10GE2/0/2
[*POD23-luojinshu-CE68-01-10GE2/0/2]undo port link-type
[*POD23-luojinshu-CE68-01-10GE2/0/2]undo port default vlan
[*POD23-luojinshu-CE68-01-10GE2/0/2]undo qos car inbound
[*POD23-luojinshu-CE68-01-10GE2/0/2]undo qos lr outbound
[*POD23-luojinshu-CE68-01-10GE2/0/2]undo shutdown
[*POD23-luojinshu-CE68-01-10GE2/0/2]q
[*POD23-luojinshu-CE68-01]qos car EMB-4-10000 cir 10240000 kbps
[*POD23-luojinshu-CE68-01]commit
[~POD23-luojinshu-CE68-01]interface 10GE1/0/2
[~POD23-luojinshu-CE68-01-10GE1/0/2]port link-type trunk
[*POD23-luojinshu-CE68-01-10GE1/0/2]port trunk allow-pass vlan 2086 3014
[*POD23-luojinshu-CE68-01-10GE1/0/2]qos car inbound EMB-4-10000
[*POD23-luojinshu-CE68-01-10GE1/0/2]qos lr cir 10240000 kbps cbs 524288 kbytes outbound
[*POD23-luojinshu-CE68-01-10GE1/0/2]undo shutdown
[*POD23-luojinshu-CE68-01-10GE1/0/2]q
[*POD23-luojinshu-CE68-01]interface 10GE2/0/2
[*POD23-luojinshu-CE68-01-10GE2/0/2]port link-type trunk
[*POD23-luojinshu-CE68-01-10GE2/0/2]port trunk allow-pass vlan 2086 3014
[*POD23-luojinshu-CE68-01-10GE2/0/2]qos car inbound EMB-4-10000
[*POD23-luojinshu-CE68-01-10GE2/0/2]qos lr cir 10240000 kbps cbs 524288 kbytes outbound
[*POD23-luojinshu-CE68-01-10GE2/0/2]undo shutdown
[*POD23-luojinshu-CE68-01-10GE2/0/2]q
[*POD23-luojinshu-CE68-01]commit
[~POD23-luojinshu-CE68-01]q


设置限速:

  1. 创建限速模板
qos car EMB-4-10000 cir 10240000 kbps
  1. 给端口设置限速
#先清除端口的配置
interface 10GE1/0/2
undo port link-type
undo port default vlan
undo qos car inbound
undo qos lr outbound
undo shutdown
q
#配置端口模式、vlan、限速
interface 10GE1/0/2
port link-type trunk
port trunk allow-pass vlan 2086 3014
qos car inbound EMB-4-10000
qos lr cir 10240000 kbps cbs 524288 kbytes 
undo shutdown
q
commit
  1. 创建vlan
[~HUAWEI]vlan 20
[*HUAWEI-vlan20]q
[*HUAWEI]commit

[~HUAWEI]vlan batch 10 to 12(创建vlan 10 11 12)

[~HUAWEI]display vlan
The total number of vlans is : 3
--------------------------------------------------------------------------------
U: Up;         D: Down;         TG: Tagged;         UT: Untagged;
MP: Vlan-mapping;               ST: Vlan-stacking;
#: ProtocolTransparent-vlan;    *: Management-vlan;
MAC-LRN: MAC-address learning;  STAT: Statistic;
BC: Broadcast; MC: Multicast;   UC: Unknown-unicast;
FWD: Forward;  DSD: Discard;
--------------------------------------------------------------------------------

VID          Ports
--------------------------------------------------------------------------------
   1         UT:100GE1/1/1(D)   100GE1/1/2(D)   25GE1/1/2(D)    25GE1/1/3(D)
                25GE1/1/4(D)    25GE1/1/6(D)    25GE1/1/7(D)    25GE1/1/8(D)
                25GE1/1/9(D)    25GE1/1/10(D)   25GE1/1/11(D)   25GE1/1/12(D)
                25GE1/1/13(D)   25GE1/1/14(D)   25GE1/1/15(D)   25GE1/1/16(D)
                25GE1/1/17(D)   25GE1/1/18(D)   25GE1/1/19(D)   25GE1/1/20(D)
                25GE1/1/21(D)   25GE1/1/22(D)   25GE1/1/23(D)   25GE1/1/24(D)
  10         UT:25GE1/1/1(D)    25GE1/1/5(D)
  20

VID  Type     Status  Property  MAC-LRN STAT    BC  MC  UC  Description
--------------------------------------------------------------------------------
   1 common   enable  default   enable  disable FWD FWD FWD VLAN 0001
  10 common   enable  default   enable  disable FWD FWD FWD VLAN 0010
  20 common   enable  default   enable  disable FWD FWD FWD VLAN 0020

  1. 查看端口配置
display current-configuration
!Software Version V200R002C50SPC800
!Last configuration was updated at 2019-08-22 17:38:04+00:00 by sshadmin
!Last configuration was saved at 2019-08-22 17:38:10+00:00 by sshadmin
#
sysname HUAWEI
#
device board 1 board-type CE8860-4C-EI
#
device card 1/1 card-type CE88-D24S2CQ
#
drop-profile default
#
dcb pfc
#
dcb ets-profile default
#
vlan batch 10
#
telnet server disable
telnet ipv6 server disable
#
diffserv domain default
#
  ---- More ----

system-view
Enter system view, return user view with return command.
[~HUAWEI]interface 25GE1/1/1
[~HUAWEI-25GE1/1/1]disp
[~HUAWEI-25GE1/1/1]display this
#
interface 25GE1/1/1
 port default vlan 10
#
return

你可能感兴趣的:(switch)