交换机实验、VLAN创建

2018-7-16

连接路由器

交换机实验、VLAN创建_第1张图片

配置两台PC机的IP地址 处于不同网段

交换机实验、VLAN创建_第2张图片

交换机实验、VLAN创建_第3张图片 

配置路由器

Router>en
Router#
Router#conf t
Router(config)#int fa0/0                       //定义0/0接口
Router(config-if)#ip add 192.168.1.254 255.255.255.0
Router(config-if)#no sh 
Router(config-if)#int fa0/1                    //定义0/1接口
Router(config-if)#ip add 192.168.2.254 255.255.255.0
Router(config-if)#no sh                        //激活接口
Router(config-if)#do wr
Router(config-if)#do show ip rou               //显示所有IP路由
Codes: C - connected, S - static, I - IGRP, R - RIP, M - mobile, B - BGP
       D - EIGRP, EX - EIGRP external, O - OSPF, IA - OSPF inter area
       N1 - OSPF NSSA external type 1, N2 - OSPF NSSA external type 2
       E1 - OSPF external type 1, E2 - OSPF external type 2, E - EGP
       i - IS-IS, L1 - IS-IS level-1, L2 - IS-IS level-2, ia - IS-IS inter area
       * - candidate default, U - per-user static route, o - ODR
       P - periodic downloaded static route

Gateway of last resort is not set

C    192.168.1.0/24 is directly connected, FastEthernet0/0      //路由表
C    192.168.2.0/24 is directly connected, FastEthernet0/1

配置路由器R1 ip:192.168.1.1/24

R1#conf t
R1(config)#int g0/0
R1(config-if)#ip address 192.168.1.1 255.255.255.0
R1(config-if)#no sh
R1(config-if)#do wr
Building configuration...
[OK]

配置路由器R2 IP:192.168.1.2/24

Router>en
Router#conf t
Router(config)#no ip domain lookup 
Router(config)#line console 0
Router(config-line)#no exec-timeout 
Router(config-line)#logg synchronous 
Router(config-line)#exit
Router(config)#do wr
Building configuration...
[OK]
Router(config)#int g0/0
Router(config-if)#ip address 192.168.1.2 255.255.255.0
Router(config-if)#no sh
Router(config-if)#do wr

配置交换机

Switch>en
Switch#conf t
Switch(config)#ho Sw1
Sw1(config)#no ip domain lookup 
Sw1(config)#line c 0
Sw1(config-line)#no exec-timeout 
Sw1(config-line)#logg s
Sw1(config-line)#exit
Sw1(config)#do wr

在R1路由器pingR2路由器

R1#ping 192.168.1.2

Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 192.168.1.2, timeout is 2 seconds:
.!!!!
Success rate is 80 percent (4/5), round-trip min/avg/max = 0/0/0 ms

R1显示ARP报文

R1#show arp 
Protocol  Address          Age (min)  Hardware Addr   Type   Interface
Internet  192.168.1.1             -   00D0.BCCA.5601  ARPA   GigabitEthernet0/0
Internet  192.168.1.2             0   0090.2B30.6C01  ARPA   GigabitEthernet0/0
  • 源IP地址:192.168.1.1
  • 源MAC地址:00D0.BCCA.56501
  • 目的IP地址:192.168.1.2
  • 目的MAC地址:0090.2B30.6C01

R2显示ARP报文

Router#SHOW ARp 
Protocol  Address          Age (min)  Hardware Addr   Type   Interface
Internet  192.168.1.1             4   00D0.BCCA.5601  ARPA   GigabitEthernet0/0
Internet  192.168.1.2             -   0090.2B30.6C01  ARPA   GigabitEthernet0/0

交换机中显示ARP报文

Sw1#show mac-address-table 
          Mac Address Table
-------------------------------------------

Vlan    Mac Address       Type        Ports
----    -----------       --------    -----

   1    0090.2b30.6c01    DYNAMIC     Fa0/2
   1    00d0.bcca.5601    DYNAMIC     Fa0/1

*如果是PC,查看ARP表项: arp -a


C:\Users\Grind>arp -a

接口: 192.168.42.51 --- 0x2
  Internet 地址         物理地址              类型
  192.168.42.129        9e-b0-36-97-f4-71     动态
  192.168.42.255        ff-ff-ff-ff-ff-ff     静态
  224.0.0.22            01-00-5e-00-00-16     静态
  224.0.0.252           01-00-5e-00-00-fc     静态
  255.255.255.255       ff-ff-ff-ff-ff-ff     静态

 搭建三PC连接统一交换机

交换机实验、VLAN创建_第4张图片

Switch#conf t
Enter configuration commands, one per line.  End with CNTL/Z.
Switch(config)#vlan 10
Switch(config-vlan)#name A
Switch(config-vlan)#exit
Switch(config)#vlan 20
Switch(config-vlan)#name B
Switch(config-vlan)#exit
Switch(config)#int fa0/1
Switch(config-if)#sw acc vlan 10
Switch(config-if)#no sh
Switch(config-if)#exit
Switch(config)#int fa0/2
Switch(config-if)#sw acc valn 20
                          ^
% Invalid input detected at '^' marker.
	
Switch(config-if)#sw acc vlan 20
Switch(config-if)#no sh
Switch(config-if)#exit
Switch(config)#int sw vlan 10
                    ^
% Invalid input detected at '^' marker.
	
Switch(config)#int vlan 10
Switch(config-if)#
%LINK-5-CHANGED: Interface Vlan10, changed state to up

%LINEPROTO-5-UPDOWN: Line protocol on Interface Vlan10, changed state to up

Switch(config-if)#int vlan 10
Switch(config-if)#ip ad
Switch(config-if)#ip address 192.168.1.254 255.255.255.0
Switch(config-if)#exit
Switch(config)#int vlan 20
Switch(config-if)#
%LINK-5-CHANGED: Interface Vlan20, changed state to up

%LINEPROTO-5-UPDOWN: Line protocol on Interface Vlan20, changed state to up

Switch(config-if)#ip ad
Switch(config-if)#ip address 192.168.2.254 255.255.255.0
Switch(config-if)#exit
Switch(config)#ip routing
Switch(config)#
%LINK-5-CHANGED: Interface FastEthernet0/3, changed state to up

%LINEPROTO-5-UPDOWN: Line protocol on Interface FastEthernet0/3, changed state to up

Switch(config)#en
% Ambiguous command: "en"
Switch(config)#int fa0/3
Switch(config-if)#sw ac vlan 20
Switch(config-if)#no sh
Switch(config-if)#do wr\
Translating "wr\"...domain server (255.255.255.255) % Name lookup aborted
Switch(config-if)#do wr
Building configuration...
[OK]

 

三台PC互相PING通

*在同一广播域的设备,只需要配置在同一网段中,就可以相互ping通

配置不同的路由地址

交换机实验、VLAN创建_第5张图片交换机实验、VLAN创建_第6张图片

交换机实验、VLAN创建_第7张图片

在PC机ping相同网段与不同网段的主机 

Switch#conf t
Switch(config-vlan)#exit
Switch(config)#vlan 20
Switch(config-vlan)#int range fa0/2,fa0/3
Switch(config-if-range)#sw acc vlan 20
Switch(config-if-range)#exit
Switch(config)#int vlan 10
Switch(config-if)#ip address 192.168.10.254 255.255.255.0
Switch(config-if)#exit
Switch(config)#int vlan 20
Switch(config-if)#ip add 192.168.20.254 255.255.255.0
Switch(config-if)#no sh
Switch(config-if)#do wr
Building configuration...
[OK]
C:\>ping 192.168.20.2

Pinging 192.168.20.2 with 32 bytes of data:

Reply from 192.168.20.2: bytes=32 time<1ms TTL=128
Reply from 192.168.20.2: bytes=32 time=1ms TTL=128
Reply from 192.168.20.2: bytes=32 time<1ms TTL=128
Reply from 192.168.20.2: bytes=32 time<1ms TTL=128

Ping statistics for 192.168.20.2:
    Packets: Sent = 4, Received = 4, Lost = 0 (0% loss),
Approximate round trip times in milli-seconds:
    Minimum = 0ms, Maximum = 1ms, Average = 0ms

C:\>ping 192.168.10.1

Pinging 192.168.10.1 with 32 bytes of data:

Request timed out.
Request timed out.
Request timed out.
Request timed out.

Ping statistics for 192.168.10.1:
    Packets: Sent = 4, Received = 0, Lost = 4 (100% loss),

C:\>ping 192.168.10.1

Pinging 192.168.10.1 with 32 bytes of data:

Reply from 192.168.10.1: bytes=32 time=1ms TTL=127
Reply from 192.168.10.1: bytes=32 time<1ms TTL=127
Reply from 192.168.10.1: bytes=32 time<1ms TTL=127
Reply from 192.168.10.1: bytes=32 time<1ms TTL=127

Ping statistics for 192.168.10.1:
    Packets: Sent = 4, Received = 4, Lost = 0 (0% loss),
Approximate round trip times in milli-seconds:
    Minimum = 0ms, Maximum = 1ms, Average = 0ms

 

 

 

 


创建VLAN

搭建网络

交换机实验、VLAN创建_第8张图片

 

创建VLAN


Switch>en
Switch#conf t
Enter configuration commands, one per line.  End with CNTL/Z.
Switch(config)#ho SW1
SW1(config)#no ip domain lookup 
SW1(config)#line c 0
SW1(config-line)#no exec-timeout 
SW1(config-line)#logging synchronous 
SW1(config-line)#do wr
Building configuration...
[OK]
SW1(config-line)#exit
SW1(config)#vlan 10
SW1(config-vlan)#name A
SW1(config-vlan)#exit
SW1(config)#int range fastEthernet0/1, fastEthernet 0/4
SW1(config-if-range)#switchport access vlan 10 //将接口加入VLAN10
//原则:一个接口只能加入1个VLAN,不能加入多个VLAN
SW1(config-if-range)#switchport mode access //接口模式的定义为访问模式
//如果交换机接口下连接的是终端,那么这个接口默认为ACCESS模式
SW1(config-if-range)#exit
SW1(config)#int range fa0/3
SW1(config-if-range)#sw access vlan 10
SW1(config-if-range)#exit
SW1(config-if)#exit
SW1(config)#vlan 20                //创建VLAN20
SW1(config-vlan)#name B 
SW1(config-vlan)#exit
SW1(config)#int f0/2               //设置fa0/2接口
SW1(config-if)#sw mod ac           //switchport mode access
SW1(config-if)#sw ac vlan 20       //switchport access vlan
SW1(config-if)#exit
SW1(config)#do wr 
Building configuration...
[OK]
SW1(config)#do show vlan b          //显示所有VLAN信息

VLAN Name                             Status    Ports
---- -------------------------------- --------- -------------------------------
1    default                          active    Fa0/5, Fa0/6, Fa0/7, Fa0/8
                                                Fa0/9, Fa0/10, Fa0/11, Fa0/12
                                                Fa0/13, Fa0/14, Fa0/15, Fa0/16
                                                Fa0/17, Fa0/18, Fa0/19, Fa0/20
                                                Fa0/21, Fa0/22, Fa0/23, Fa0/24
                                                Gig0/1, Gig0/2
10   A                                active    Fa0/1, Fa0/3, Fa0/4
20   B                                active    Fa0/2
1002 fddi-default                     active    
1003 token-ring-default               active    
1004 fddinet-default                  active    
1005 trnet-default                    active    
SW1(config)#

 

VLAN创建的方法

  1. 全局配置模式下(推荐):
  2. VLAN配置模式下:
  3. 接口加入VLAN时:
  4. 特权模式下(不推荐):
  5. *不能创建VLAN

 

VLAN保存位置

 

以太网接口加组:多个接口有相同配置

工作方式

流量过滤选择响应的接口 

sw trunk allowed vlan XXXX 


 交换机实验、VLAN创建_第9张图片

交换机实验、VLAN创建_第10张图片交换机实验、VLAN创建_第11张图片

C:\>ping 192.168.10.1
Pinging 192.168.10.1 with 32 bytes of data:
Request timed out.
Reply from 192.168.10.1: bytes=32 time=1ms TTL=127
Reply from 192.168.10.1: bytes=32 time<1ms TTL=127
Reply from 192.168.10.1: bytes=32 time=2ms TTL=127
Ping statistics for 192.168.10.1:
    Packets: Sent = 4, Received = 3, Lost = 1 (25% loss),
Approximate round trip times in milli-seconds:
    Minimum = 0ms, Maximum = 2ms, Average = 1ms

 交换机配置

SW_TWO(config)#ho SW_TWO
SW_TWO(config)#int fa0/2
SW_TWO(config-if)#sw mo ac
SW_TWO(config-if)#sw ac vlan 10
SW_TWO(config-if)#exit
SW_TWO(config)#int f0/3
SW_TWO(config-if)#sw mo ac
SW_TWO(config-if)#sw ac vlan 20
SW_TWO(config-if)#int fa0/1
SW_TWO(config-if)#sw mo tr
SW_TWO(config-if)#do wr

 三层交换机配置

Switch>en
Switch#en
Switch#conf t
Enter configuration commands, one per line.  End with CNTL/Z.
Switch(config)#ho SW-THREE
SW-THREE(config)#int fa0/1
SW-THREE(config-if)#sw tr en dot
SW-THREE(config-if)#exit
SW-THREE(config)#int vlan 10
SW-THREE(config-if)#ip add 192.168.10.254 255.255.255.0
SW-THREE(config-if)#no sh
SW-THREE(config-if)#do wr
Building configuration...
[OK]
SW-THREE(config-if)#exit 
SW-THREE(config)#int vlan 20
SW-THREE(config-if)#ip add 192.168.20.254 255.255.255.0
SW-THREE(config-if)#no sh
SW-THREE(config-if)#
%LINK-5-CHANGED: Interface FastEthernet0/1, changed state to down

%LINEPROTO-5-UPDOWN: Line protocol on Interface FastEthernet0/1, changed state to down

%LINK-5-CHANGED: Interface FastEthernet0/1, changed state to up

%LINEPROTO-5-UPDOWN: Line protocol on Interface FastEthernet0/1, changed state to up

SW-THREE(config-if)#
SW-THREE(config-if)#do show vlan 

VLAN Name                             Status    Ports
---- -------------------------------- --------- -------------------------------
1    default                          active    Fa0/2, Fa0/3, Fa0/4, Fa0/5
                                                Fa0/6, Fa0/7, Fa0/8, Fa0/9
                                                Fa0/10, Fa0/11, Fa0/12, Fa0/13
                                                Fa0/14, Fa0/15, Fa0/16, Fa0/17
                                                Fa0/18, Fa0/19, Fa0/20, Fa0/21
                                                Fa0/22, Fa0/23, Fa0/24, Gig0/1
                                                Gig0/2
1002 fddi-default                     active    
1003 token-ring-default               active    
1004 fddinet-default                  active    
1005 trnet-default                    active    

VLAN Type  SAID       MTU   Parent RingNo BridgeNo Stp  BrdgMode Trans1 Trans2
---- ----- ---------- ----- ------ ------ -------- ---- -------- ------ ------
1    enet  100001     1500  -      -      -        -    -        0      0
1002 fddi  101002     1500  -      -      -        -    -        0      0   
1003 tr    101003     1500  -      -      -        -    -        0      0   
1004 fdnet 101004     1500  -      -      -        ieee -        0      0   
1005 trnet 101005     1500  -      -      -        ibm  -        0      0   

VLAN Type  SAID       MTU   Parent RingNo BridgeNo Stp  BrdgMode Trans1 Trans2
---- ----- ---------- ----- ------ ------ -------- ---- -------- ------ ------

Remote SPAN VLANs
------------------------------------------------------------------------------

Primary Secondary Type              Ports
------- --------- ----------------- ------------------------------------------
SW-THREE(config-if)#exit
SW-THREE(config)#
SW-THREE(config)#int fa0/1
SW-THREE(config-if)#sw mo tr
SW-THREE(config-if)#sw mo trunk 
SW-THREE(config-if)#sh

SW-THREE(config-if)#
%LINK-5-CHANGED: Interface FastEthernet0/1, changed state to administratively down

%LINEPROTO-5-UPDOWN: Line protocol on Interface FastEthernet0/1, changed state to down

SW-THREE(config-if)#no sh

SW-THREE(config-if)#
%LINK-5-CHANGED: Interface FastEthernet0/1, changed state to up

%LINEPROTO-5-UPDOWN: Line protocol on Interface FastEthernet0/1, changed state to up

SW-THREE(config-if)#ip routing
SW-THREE(config)#
SW-THREE(config)#do show vlan b

VLAN Name                             Status    Ports
---- -------------------------------- --------- -------------------------------
1    default                          active    Fa0/2, Fa0/3, Fa0/4, Fa0/5
                                                Fa0/6, Fa0/7, Fa0/8, Fa0/9
                                                Fa0/10, Fa0/11, Fa0/12, Fa0/13
                                                Fa0/14, Fa0/15, Fa0/16, Fa0/17
                                                Fa0/18, Fa0/19, Fa0/20, Fa0/21
                                                Fa0/22, Fa0/23, Fa0/24, Gig0/1
                                                Gig0/2
1002 fddi-default                     active    
1003 token-ring-default               active    
1004 fddinet-default                  active    
1005 trnet-default                    active    
SW-THREE(config)#vlan 10
SW-THREE(config-vlan)#
%LINK-5-CHANGED: Interface Vlan10, changed state to up

%LINEPROTO-5-UPDOWN: Line protocol on Interface Vlan10, changed state to up

SW-THREE(config-vlan)#name A
SW-THREE(config-vlan)#EXIT
SW-THREE(config)#vlan 20
SW-THREE(config-vlan)#
%LINK-5-CHANGED: Interface Vlan20, changed state to up

%LINEPROTO-5-UPDOWN: Line protocol on Interface Vlan20, changed state to up

SW-THREE(config-vlan)#name B
SW-THREE(config-vlan)#int vlan 100
SW-THREE(config-if)#ip add
SW-THREE(config-if)#ip address 192.168.10.254 255.255.255.0
% 192.168.10.0 overlaps with Vlan10
SW-THREE(config-if)#int vlan 10
SW-THREE(config-if)#ip address 192.168.10.254 255.255.255.0
SW-THREE(config-if)#int vlan 20
SW-THREE(config-if)#ip add 192.168.20.254 255.255.255.0
SW-THREE(config-if)#no sh

 交换机实验、VLAN创建_第12张图片

 配置

 在二层交换机中设置好VLAN后不需要对VLAN的IP地址进行配置,在三层交换机中存在物理接口与逻辑接口可以对VLAN进行地址的配置进行通信.

Switch>en
Switch#conf t
Enter configuration commands, one per line.  End with CNTL/Z.
Switch(config)#
Switch(config)#int fa0/2
Switch(config-if)#exit
Switch(config)#vlan 10
Switch(config-vlan)#exit
Switch(config)#vlan 20
Switch(config-vlan)#int vlan 20
Switch(config-if)#
%LINK-5-CHANGED: Interface Vlan20, changed state to up

%LINEPROTO-5-UPDOWN: Line protocol on Interface Vlan20, changed state to up

Switch(config-if)#int fa0/1
Switch(config-if)#sw ac vlan 20
Switch(config-if)#int fa0/2
Switch(config-if)#sw ac vlan 10
Switch(config-if)#do w
%CDP-4-NATIVE_VLAN_MISMATCH: Native VLAN mismatch discovered on FastEthernet0/2 (10), with Switch FastEthernet0/1 (1).
                   ^
% Invalid input detected at '^' marker.
	
Switch(config-if)#do wr
Building configuration...
[OK]
Switch(config-if)#
Switch(config-if)#int fa0/3
Switch(config-if)#sw mo tr
Switch(config-if)#sw mo trunk 
Command rejected: An interface whose trunk encapsulation is "Auto" can not be configured to "trunk" mode.
Switch(config-if)#
%CDP-4-NATIVE_VLAN_MISMATCH: Native VLAN mismatch discovered on FastEthernet0/2 (10), with Switch FastEthernet0/1 (1).

Switch(config-if)#int vlan 
%CDP-4-NATIVE_VLAN_MISMATCH: Native VLAN mismatch discovered on FastEthernet0/2 (10), with Switch FastEthernet0/1 (1).

                   ^
% Invalid input detected at '^' marker.
	
Switch(config-if)#int fa0/3
Switch(config-if)#sw mo tr
Switch(config-if)#sw mo trunk 
Command rejected: An interface whose trunk encapsulation is "Auto" can not be configured to "trunk" mode.
Switch(config-if)#
Switch(config-if)#
%CDP-4-NATIVE_VLAN_MISMATCH: Native VLAN mismatch discovered on FastEthernet0/2 (10), with Switch FastEthernet0/1 (1).

Switch(config-if)#int vlan 20
Switch(config-if)#i pad
Switch(config-if)#ip a
Switch(config-if)#ip ad
Switch(config-if)#ip address 192.168.20.254 255.255.255.0
Switch(config-if)#do wr
Building configuration...
[OK]
Switch(config-if)#int v
%CDP-4-NATIVE_VLAN_MISMATCH: Native VLAN mismatch discovered on FastEthernet0/2 (10), with Switch FastEthernet0/1 (1).

% Ambiguous command: "int v"
Switch(config)#int fa0/2
Switch(config-if)#sw ac vlan 10
Switch(config-if)#sw mo tr
Switch(config-if)#sw mo trunk 
Command rejected: An interface whose trunk encapsulation is "Auto" can not be configured to "trunk" mode.
Switch(config-if)#
%CDP-4-NATIVE_VLAN_MISMATCH: Native VLAN mismatch discovered on FastEthernet0/2 (10), with Switch FastEthernet0/1 (1).

%CDP-4-NATIVE_VLAN_MISMATCH: Native VLAN mismatch discovered on FastEthernet0/2 (10), with Switch FastEthernet0/1 (1).

%CDP-4-NATIVE_VLAN_MISMATCH: Native VLAN mismatch discovered on FastEthernet0/2 (10), with Switch FastEthernet0/1 (1).

%CDP-4-NATIVE_VLAN_MISMATCH: Native VLAN mismatch discovered on FastEthernet0/2 (10), with Switch FastEthernet0/1 (1).

%CDP-4-NATIVE_VLAN_MISMATCH: Native VLAN mismatch discovered on FastEthernet0/2 (10), with Switch FastEthernet0/1 (1).

Switch(config-if)#
Switch(config-if)#
%CDP-4-NATIVE_VLAN_MISMATCH: Native VLAN mismatch discovered on FastEthernet0/2 (10), with Switch FastEthernet0/1 (1).

%CDP-4-NATIVE_VLAN_MISMATCH: Native VLAN mismatch discovered on FastEthernet0/2 (10), with Switch FastEthernet0/1 (1).

%CDP-4-NATIVE_VLAN_MISMATCH: Native VLAN mismatch discovered on FastEthernet0/2 (10), with Switch FastEthernet0/1 (1).

%CDP-4-NATIVE_VLAN_MISMATCH: Native VLAN mismatch discovered on FastEthernet0/2 (10), with Switch FastEthernet0/1 (1).

%CDP-4-NATIVE_VLAN_MISMATCH: Native VLAN mismatch discovered on FastEthernet0/2 (10), with Switch FastEthernet0/1 (1).

Switch(config-if)#exit
Switch(config)#
Switch(config)#int fa0/3
Switch(config-if)#sw mo tr
Command rejected: An interface whose trunk encapsulation is "Auto" can not be configured to "trunk" mode.
Switch(config-if)#
%CDP-4-NATIVE_VLAN_MISMATCH: Native VLAN mismatch discovered on FastEthernet0/2 (10), with Switch FastEthernet0/1 (1).

Switch(config-if)#
Switch(config-if)#sw tr en
Switch(config-if)#sw tr encapsulation do
Switch(config-if)#sw tr encapsulation dot1q 
Switch(config-if)#sw mo tr

 

Switch>en
Switch#conf t
Enter configuration commands, one per line.  End with CNTL/Z.
Switch(config)#int range fa0/2,fa0/3
Switch(config-if-range)#sw ac vlan 100
% Access VLAN does not exist. Creating vlan 100
Switch(config-if-range)#sw ac vlan 10
% Access VLAN does not exist. Creating vlan 10
Switch(config-if-range)#exit
Switch(config)#int fa0/1
Switch(config-if)#sw mo tr

Switch(config-if)#
%LINEPROTO-5-UPDOWN: Line protocol on Interface FastEthernet0/1, changed state to down

%LINEPROTO-5-UPDOWN: Line protocol on Interface FastEthernet0/1, changed state to up

Switch(config-if)#vlan 10
Switch(config-vlan)#int vlan 1
Switch(config-if)#int vlan 10
Switch(config-if)#
%LINK-5-CHANGED: Interface Vlan10, changed state to up

%LINEPROTO-5-UPDOWN: Line protocol on Interface Vlan10, changed state to up

Switch(config-if)#ip ad
Switch(config-if)#ip address 192.168.10.254 255.255.255.0
Switch(config-if)#do wr

 


 

交换机默认配置下是一个完整的广播域、二层域、局域网

所有接口均默认放在VLAN1(本征VLAN)

交换机即插即用,所有业务流量均放在VLAN1下

为了合理的使用交换机的接口,适应目前多业务环境,VLAN技术得以广泛应用

 

VLAN virtual local area network

底层虚拟化,交换机接口的虚拟化

通过VLAN的方式将特定的端口划分进某一台虚拟交换机

此时只有同一VLAN接口可以直连互通,不同VLAN的接口被逻辑隔离

 

交换机接口的工作模式:

  1. access access模式承接单一特定VLAN的流量

通常和主机,服务器终端相连的交换机接口会配置access模式

access模式的数据帧在交换机之间转发时不需要修改任何帧格式。

vlan XXX

switchport mode access

switchport access vlan XXX

 

    2.trunk trunk模式可以承接多个VLAN流量 主干链路

通常和交换机互联的接口会配置trunk模式,多vlan需要通过trunk模式的数据帧,在从trunk口出的时候会被重新封装802.1q 并且打上VLAN的标签

逻辑上区分不同VLAN的流量

switchport trunk encapsulation dot1q

switch mode trunk

你可能感兴趣的:(learning)