vlan 划分试验

vlan 试验

 

 

 图片

 

今天,我们做一个关于交换的试验。非常简单,VLAN的划分。虽然很简单,但是它反应了valn的划分,很有针对性。我们不去划那些一个试验都可以包含NANP甚至部分IE的试验,那样的拓扑图一看头都大了……   我没有贬低那些拓扑意思,只是说那样的拓扑还不适合我们这些初学者。

 

 

 

 

我们的试验环境是DynamipsGUI v2.7SecureCRT 5.1,另加两台PC(一台是我的本机(PC2),另一台是Vmware虚拟机)PC1)。废话就不多说了,来看我们的拓扑图做试验吧!!

 

我们在SW1上划分两个vlan分别把PC1 PC2划分给这两个vlan 。然后再测试PC1 PC2的连通性。

 

我们首先为PC1PC2配置IP地址:

PC1—IP:192.168.0.103/24

PC2—IP:192.168.0.109/24

现在我们已经启动了交换机,启动SecureCRT 5.1进入交换机的配置模式。

启动F0/0端口

SW1(config)#interface fastEthernet 0/0

SW1(config-if)#no shutdown

SW1(config-if)#exit

SW1(config)#end

SW1#show interfaces fastEthernet 0/0

FastEthernet0/0 is up, line protocol is up

启动F0/10端口

SW1(config)#interface fastEthernet 0/10

SW1(config-if)#no shutdown

SW1(config-if)#exit

SW1(config)#end

SW1#show interfaces fastEthernet 0/10

FastEthernet0/10 is up, line protocol is up

 

现在PC1PC2相互是通ping通的。下面就要划分两个VLAN,把两台PC分别加入两个VLAN后就不能 ping通了。

SW1#vlan database

SW1(vlan)#vlan 10 name pc1

VLAN 10 added:

    Name: pc1

SW1(vlan)#vlan 20 name pc2

VLAN 20 added:

    Name: pc2

SW1(vlan)#exit

APPLY completed.

Exiting....

SW1#show vlan-switch

VLAN   Name             Status    Ports

10       pc1               active   

20       pc2               active   

 

已经设置好了两个VLAN并确认了它的状态。然后我们就把两个端口分别加入这两个VLAN

F0/0端口加入vlan10

SW1(config)#interface fastEthernet 0/0

SW1(config-if)#switch access vlan 10

F0/10端口加入vlan20

SW1(config)#interface fastEthernet 0/10

SW1(config-if)#switch access vlan 20

确认加入状态:

VLAN   Name             Status    Ports

10       pc1               active    Fa0/0

20       pc2               active    Fa0/10

 

 

至此试验做完了。我们再用两台PC相互ping是不会通的了。

 

 

 

 

 

 

 

完整的代码:

代码开始:

Router>en

Router#config t

Enter configuration commands, one per line.  End with CNTL/Z.

Router(config)#hostname SW1

SW1(config)#interface fastEthernet 0/0

SW1(config-if)#no shutdown

SW1(config-if)#exit

SW1(config)#interface fastEthernet 0/10

SW1(config-if)#no shutdown

SW1(config-if)#exit

SW1(config)#end

SW1#

*Mar  1 00:01:58.119: %SYS-5-CONFIG_I: Configured from console by console

SW1#show interfaces fastEthernet 0/0

FastEthernet0/0 is up, line protocol is up

  Hardware is Fast Ethernet, address is cc00.0fac.f000 (bia cc00.0fac.f000)

  MTU 1500 bytes, BW 100000 Kbit, DLY 100 usec,

     reliability 255/255, txload 1/255, rxload 1/255

  Encapsulation ARPA, loopback not set

  Keepalive set (10 sec)

  Full-duplex, 100Mb/s

  ARP type: ARPA, ARP Timeout 04:00:00

  Last input never, output never, output hang never

  Last clearing of "show interface" counters never

  Input queue: 0/75/0/0 (size/max/drops/flushes); Total output drops: 0

  Queueing strategy: fifo

  Output queue: 0/40 (size/max)

  5 minute input rate 0 bits/sec, 0 packets/sec

  5 minute output rate 0 bits/sec, 0 packets/sec

     0 packets input, 0 bytes, 0 no buffer

     Received 0 broadcasts, 0 runts, 0 giants, 0 throttles

     0 input errors, 0 CRC, 0 frame, 0 overrun, 0 ignored

     0 input packets with dribble condition detected

     0 packets output, 0 bytes, 0 underruns

     0 output errors, 0 collisions, 2 interface resets

     0 babbles, 0 late collision, 0 deferred

     0 lost carrier, 0 no carrier

     0 output buffer failures, 0 output buffers swapped out

SW1#show interfaces fastEthernet 0/10

FastEthernet0/10 is up, line protocol is up

  Hardware is Fast Ethernet, address is cc00.0fac.f 00a (bia cc00.0fac.f 00a)

  MTU 1500 bytes, BW 100000 Kbit, DLY 100 usec,

     reliability 255/255, txload 1/255, rxload 1/255

  Encapsulation ARPA, loopback not set

  Keepalive set (10 sec)

  Full-duplex, 100Mb/s

  ARP type: ARPA, ARP Timeout 04:00:00

  Last input never, output never, output hang never

  Last clearing of "show interface" counters never

  Input queue: 0/75/0/0 (size/max/drops/flushes); Total output drops: 0

  Queueing strategy: fifo

  Output queue: 0/40 (size/max)

  5 minute input rate 0 bits/sec, 0 packets/sec

  5 minute output rate 0 bits/sec, 0 packets/sec

     0 packets input, 0 bytes, 0 no buffer

     Received 0 broadcasts, 0 runts, 0 giants, 0 throttles

     0 input errors, 0 CRC, 0 frame, 0 overrun, 0 ignored

     0 input packets with dribble condition detected

     0 packets output, 0 bytes, 0 underruns

     0 output errors, 0 collisions, 2 interface resets

     0 babbles, 0 late collision, 0 deferred

     0 lost carrier, 0 no carrier

     0 output buffer failures, 0 output buffers swapped out

SW1#

SW1#vlan ?

  database  Configure VLAN database

 

SW1#vlan database

SW1(vlan)#vlan 10 name pc1

VLAN 10 added:

    Name: pc1

SW1(vlan)#vlan 20 name pc2

VLAN 20 added:

    Name: pc2

SW1(vlan)#exit

APPLY completed.

Exiting....

SW1#show vlan-switch

 

VLAN Name                             Status    Ports

---- -------------------------------- --------- -------------------------------

1    default                          active    Fa0/0, Fa0/1, 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

                                                Fa1/0, Fa1/1, Fa1/2, Fa1/3

                                                Fa1/4, Fa1/5, Fa1/6, Fa1/7

                                                Fa1/8, Fa1/9, Fa1/10, Fa1/11

                                                Fa1/12, Fa1/13, Fa1/14, Fa1/15

10   pc1                              active   

20   pc2                              active   

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  -      -      -        -    -        1002   1003

10   enet  100010     1500  -      -      -        -    -        0      0  

20   enet  100020     1500  -      -      -        -    -        0      0  

         

VLAN Type  SAID       MTU   Parent RingNo BridgeNo Stp  BrdgMode Trans1 Trans2

---- ----- ---------- ----- ------ ------ -------- ---- -------- ------ ------

1002 fddi  101002     1500  -      -      -        -    -        1      1003

1003 tr    101003     1500  1005   0      -        -    srb      1      1002

1004 fdnet 101004     1500  -      -      1        ibm  -        0      0  

1005 trnet 101005     1500  -      -      1        ibm  -        0      0  

SW1#config t

Enter configuration commands, one per line.  End with CNTL/Z.

SW1(config)#interface fastEthernet 0/0

SW1(config-if)#switch access vlan 10

SW1(config-if)#exit

SW1(config)#interface fastEthernet 0/10

SW1(config-if)#switch access vlan 20

SW1(config-if)#exit

SW1(config)#

*Mar  1 00:05:37.355: %LINEPROTO-5-UPDOWN: Line protocol on Interface Vlan1, changed state to down

SW1(config)#end

SW1#

*Mar  1 00:05:41.287: %SYS-5-CONFIG_I: Configured from console by console

SW1#show vlan-switch

 

VLAN Name                             Status    Ports

---- -------------------------------- --------- -------------------------------

1    default                          active    Fa0/1, Fa0/2, Fa0/3, Fa0/4

                                                Fa0/5, Fa0/6, Fa0/7, Fa0/8

                                                Fa0/9, Fa0/11, Fa0/12, Fa0/13

                                                Fa0/14, Fa0/15, Fa1/0, Fa1/1

                                                Fa1/2, Fa1/3, Fa1/4, Fa1/5

                                                Fa1/6, Fa1/7, Fa1/8, Fa1/9

                                                Fa1/10, Fa1/11, Fa1/12, Fa1/13

                                                Fa1/14, Fa1/15

10   pc1                              active    Fa0/0

20   pc2                              active    Fa0/10

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  -      -      -        -    -        1002   1003

10   enet  100010     1500  -      -      -        -    -        0      0  

20   enet  100020     1500  -      -      -        -    -        0      0  

 --More--

 

 

代码结束

本文出自 “springdatebk” 博客,谢绝转载!

你可能感兴趣的:(职场,VLAN,休闲,试验)