交换机Access模式和Trunk模式配置演示

一.Access配置

1.创建VLAN

2.设置为接口模式,将接口划入不同VLAN

3.测试

二.Trunk配置

1.  接口VLAN配置

2.设置允许VLAN流量通过,可写all

3.测试


一.Access配置

交换机Access模式和Trunk模式配置演示_第1张图片

实现VLAN10 和 VLAN20之间通信隔离

1.创建VLAN

[s1]vlan 10
[s1]vlan 20

[s1]vlan batch 10 20    #创建多个不连续VLAN
[s1]vlan batch 10 to 20    #创建多个连续VLAN

2.设置为接口模式,将接口划入不同VLAN

E0/0/1和E0/0/2两个接口已经分别汇入VLAN10和VLAN20

[s1]interface Ethernet0/0/1
[s1-Ethernet0/0/1]port link-type access 
[s1-Ethernet0/0/1]port default vlan 10
[s1]interface Ethernet0/0/2
[s1-Ethernet0/0/2]port link-type access 
[s1-Ethernet0/0/2]port default vlan 20
[s1]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;
--------------------------------------------------------------------------------

VID  Type    Ports                                                          
--------------------------------------------------------------------------------
1    common  UT:Eth0/0/3(D)     Eth0/0/4(D)     Eth0/0/5(D)     Eth0/0/6(D)     
                Eth0/0/7(D)     Eth0/0/8(D)     Eth0/0/9(D)     Eth0/0/10(D)    
                Eth0/0/11(D)    Eth0/0/12(D)    Eth0/0/13(D)    Eth0/0/14(D)    
                Eth0/0/15(D)    Eth0/0/16(D)    Eth0/0/17(D)    Eth0/0/18(D)    
                Eth0/0/19(D)    Eth0/0/20(D)    Eth0/0/21(D)    Eth0/0/22(D)    

10   common  UT:Eth0/0/1(U)                                         

20   common  UT:Eth0/0/2(U)                                       


VID  Status  Property      MAC-LRN Statistics Description      
--------------------------------------------------------------------------------

1    enable  default       enable  disable    VLAN 0001                         
10   enable  default       enable  disable    VLAN 0010                         
20   enable  default       enable  disable    VLAN 0020        

3.测试

PC>ping 192.168.2.138

Ping 192.168.2.138: 32 data bytes, Press Ctrl_C to break
From 192.168.2.135: Destination host unreachable
From 192.168.2.135: Destination host unreachable
From 192.168.2.135: Destination host unreachable
From 192.168.2.135: Destination host unreachable
From 192.168.2.135: Destination host unreachable

--- 192.168.2.138 ping statistics ---
  5 packet(s) transmitted
  0 packet(s) received
  100.00% packet loss

二.Trunk配置

交换机Access模式和Trunk模式配置演示_第2张图片

VLAN10通信对端VLAN10,VLAN20通信对端VLAN20 

1.  接口VLAN配置

先按照access模式将两个交换机的E0/0/1和E0/0/2设置为access并分别加入VLAN10和VLAN20,将E0/0/3设置为trunk

[s1-Ethernet0/0/3]port link-type trunk
[s2-Ethernet0/0/3]port link-type trunk

2.设置允许VLAN流量通过,可写all

[s1-Ethernet0/0/3]port trunk allow-pass vlan 10 20
[s2-Ethernet0/0/3]port trunk allow-pass vlan 10 20

3.测试

PC1pingPC3,PC2pingPC4

PC>ping 192.168.2.138

Ping 192.168.2.138: 32 data bytes, Press Ctrl_C to break
From 192.168.2.138: bytes=32 seq=1 ttl=128 time=62 ms
From 192.168.2.138: bytes=32 seq=2 ttl=128 time=63 ms
From 192.168.2.138: bytes=32 seq=3 ttl=128 time=63 ms
From 192.168.2.138: bytes=32 seq=4 ttl=128 time=62 ms
From 192.168.2.138: bytes=32 seq=5 ttl=128 time=78 ms

--- 192.168.2.138 ping statistics ---
  5 packet(s) transmitted
  5 packet(s) received
  0.00% packet loss
  round-trip min/avg/max = 62/65/78 ms
PC>ping 192.168.6.138

Ping 192.168.6.138: 32 data bytes, Press Ctrl_C to break
From 192.168.6.138: bytes=32 seq=1 ttl=128 time=78 ms
From 192.168.6.138: bytes=32 seq=2 ttl=128 time=62 ms
From 192.168.6.138: bytes=32 seq=3 ttl=128 time=62 ms
From 192.168.6.138: bytes=32 seq=4 ttl=128 time=62 ms
From 192.168.6.138: bytes=32 seq=5 ttl=128 time=78 ms

--- 192.168.6.138 ping statistics ---
  5 packet(s) transmitted
  5 packet(s) received
  0.00% packet loss
  round-trip min/avg/max = 62/68/78 ms

你可能感兴趣的:(HW网络,#,交换,网络,VLAN,交换机,Access,Trunk)