您的当前位置:首页正文

vlan划分

2020-09-08 来源:步旅网
实验 用交换机划分VLAN

在sw1上配置

Router> Router>en Router#conf t

Enter configuration commands, one per line. End with CNTL/Z. Router(config)#no ip do lo Router(config)#line cons 0 Router(config-line)#no exec-t Router(config-line)#logg syn Router(config-line)#exit Router(config)#hostname sw1 sw1(config)#end sw1#v

*Mar 1 00:35:21.911: %SYS-5-CONFIG_I: Configured from console by console sw1#vlan da sw1#vlan database sw1(vlan)#vlan 2 name A VLAN 2 added: Name: A

sw1(vlan)#vlan 3 name B VLAN 3 added: Name: B sw1(vlan)#exi APPLY completed.

Exiting.... sw1#conf t

Enter configuration commands, one per line. End with CNTL/Z. sw1(config)#int f0/0 sw1(config-if)#swi mod acc sw1(config-if)#swi acc vlan 2 sw1(config-if)#no shut sw1(config-if)#no shutdown sw1(config-if)#exi sw1(config)#

*Mar 1 00:36:58.439: %LINK-3-UPDOWN: Interface FastEthernet0/0, changed state to up

*Mar 1 00:36:59.439: %LINEPROTO-5-UPDOWN: Line protocol on Interface FastEthernet0/0, changed state to up

sw1(config)#int f0/1 sw1(config-if)#swi mod acc sw1(config-if)#swo acc vlan 3 ^

% Invalid input detected at '^' marker.

sw1(config-if)#swi acc vlan 3 sw1(config-if)#no shut sw1(config-if)#

*Mar 1 00:37:36.591: %LINK-3-UPDOWN: Interface FastEthernet0/1, changed state to up

*Mar 1 00:37:37.591: %LINEPROTO-5-UPDOWN: Line protocol on Interface FastEthernet0/1, changed state to up

sw1(config-if)#exi sw1(config)#int f0/2 sw1(config-if)#swi mod tr sw1(config-if)#sw tru en d sw1(config-if)#no shut sw1(config-if)#end sw1#

*Mar 1 00:38:19.587: %DTP-5-TRUNKPORTON: Port Fa0/2 has become dot1q trunk

*Mar 1 00:38:20.087: %LINEPROTO-5-UPDOWN: Line protocol on Interface Vlan1, changed state to up *Mar 1 00:38:20.611: %SYS-5-CONFIG_I: Configured from console by console sw1#

*Mar 1 00:38:20.927: %LINK-3-UPDOWN: Interface FastEthernet0/2, changed state to up

*Mar 1 00:38:21.927: %LINEPROTO-5-UPDOWN: Line protocol on Interface FastEthernet0/2, changed state to up

sw1#show vlan-s

VLAN Name Status Ports ---- -------------------------------- --------- -------------------------------

1 default active 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 2 A active Fa0/0 3 B active Fa0/1 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 2 enet 100002 1500 - - - - - 0 0 3 enet 100003 1500 - - - - - 0 0 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#conf t

Enter configuration commands, one per line. End with CNTL/Z. sw1(config)#no ip routing sw1(config)#

在sw2上配置

Router> Router>en Router#conf t

Enter configuration commands, one per line. End with CNTL/Z. Router(config)#no ip do lo Router(config)#line cons 0 Router(config-line)#no exec-t Router(config-line)#logg syn Router(config-line)#exit

Router(config)#hostname sw2 sw2(config)#end sw2#v

*Mar 1 00:35:21.911: %SYS-5-CONFIG_I: Configured from console by console sw2#vlan da

sw2#vlan database sw2(vlan)#vlan 2 name A VLAN 2 added: Name: A

sw2(vlan)#vlan 3 name B

VLAN 3 added: Name: B sw2(vlan)#exi APPLY completed. Exiting.... sw2#conf t

Enter configuration commands, one per line. End with CNTL/Z. sw2(config)#int f0/0

sw2(config-if)#swi mod acc sw2(config-if)#swi acc vlan 2 sw2(config-if)#no shut

sw2(config-if)#no shutdown sw2(config-if)#exi sw2(config)#

*Mar 1 00:36:58.439: %LINK-3-UPDOWN: Interface FastEthernet0/0, changed state to up

*Mar 1 00:36:59.439: %LINEPROTO-5-UPDOWN: Line protocol on Interface FastEthernet0/0, changed state to up sw2(config)#int f0/1

sw2(config-if)#swi mod acc sw2(config-if)#swo acc vlan 3 ^

% Invalid input detected at '^' marker.

sw2(config-if)#swi acc vlan 3 sw2(config-if)#no shut sw2(config-if)#

*Mar 1 00:37:36.591: %LINK-3-UPDOWN: Interface FastEthernet0/1, changed state to up

*Mar 1 00:37:37.591: %LINEPROTO-5-UPDOWN: Line protocol on Interface FastEthernet0/1, changed state to up sw2(config-if)#exi sw2(config)#int f0/2

sw2(config-if)#swi mod tr sw2(config-if)#sw tru en d sw2(config-if)#no shut sw2(config-if)#end sw2#

*Mar 1 00:38:19.587: %DTP-5-TRUNKPORTON: Port Fa0/2 has become dot1q trunk

*Mar 1 00:38:20.087: %LINEPROTO-5-UPDOWN: Line protocol on Interface Vlan1, changed state to up

*Mar 1 00:38:20.611: %SYS-5-CONFIG_I: Configured from console by console sw2#

*Mar 1 00:38:20.927: %LINK-3-UPDOWN: Interface FastEthernet0/2, changed state to up

*Mar 1 00:38:21.927: %LINEPROTO-5-UPDOWN: Line protocol on Interface FastEthernet0/2, changed state to up

sw2#show vlan-s

VLAN Name Status Ports ---- -------------------------------- --------- -------------------------------

1 default active 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 2 A active Fa0/0 3 B active Fa0/1 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 2 enet 100002 1500 - - - - - 0 0 3 enet 100003 1500 - - - - - 0 0 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 sw2#conf t

Enter configuration commands, one per line. End with CNTL/Z. sw2(config)#no ip routing sw2(config)#

在PC上配置

Router> Router>en Router#conf t

Enter configuration commands, one per line. End with CNTL/Z. Router(config)#no ip do lo Router(config)#line cons 0 Router(config-line)#no exec-t Router(config-line)#logg syn Router(config-line)#exit

Router(config)#hostname PC1 PC1(config)#int f0/0

PC1(config-if)#ip add 11.1.1.1 255.255.255.0 PC1(config-if)#no shut

PC1(config-if)#no shutdown

PC1(config-if)#end PC1#

*Mar 1 00:41:24.479: %LINK-3-UPDOWN: Interface FastEthernet0/0, changed state to up *Mar 1 00:41:25.055: %SYS-5-CONFIG_I: Configured from console by console

*Mar 1 00:41:25.479: %LINEPROTO-5-UPDOWN: Line protocol on Interface FastEthernet0/0, changed state to up PC1#conf t

Enter configuration commands, one per line. End with CNTL/Z. PC1(config)#no ip routing PC1(config)#end

Router>en Router#conf t

Enter configuration commands, one per line. End with CNTL/Z. Router(config)#no ip do lo Router(config)#line cons 0 Router(config-line)#no exec-t Router(config-line)#logg syn Router(config-line)#exit

Router(config)#hostname PC2 PC2(config)#int f0/0 PC2(config-if)#int add PC2(config-if)#ip add

PC2(config-if)#ip address 11.1.2.1 255.255.255.0 PC2(config-if)#no shut PC2(config-if)#

*Mar 1 00:40:59.843: %LINK-3-UPDOWN: Interface FastEthernet0/0, changed state to up

*Mar 1 00:41:00.843: %LINEPROTO-5-UPDOWN: Line protocol on Interface FastEthernet0/0, changed state to up PC2(config-if)#end PC2#

*Mar 1 00:41:03.291: %SYS-5-CONFIG_I: Configured from console by console PC2#conf t

Enter configuration commands, one per line. End with CNTL/Z. PC2(config)#no ip routing PC2(config)#end

Router>en Router#conf t

Enter configuration commands, one per line. End with CNTL/Z. Router(config)#no ip do lo

Router(config)#line cons 0 Router(config-line)#no exec-t Router(config-line)#logg syn Router(config-line)#exit

Router(config)#hostname PC3 PC3(config)#in f0/0

PC3(config-if)#ip add 11.1.3.1 255.255.255.0 PC3(config-if)#no shu

PC3(config-if)#no shutdown PC3(config-if)#end PC3#

*Mar 1 00:43:33.659: %LINK-3-UPDOWN: Interface FastEthernet0/0, changed state to up PC3#

*Mar 1 00:43:33.891: %SYS-5-CONFIG_I: Configured from console by console

*Mar 1 00:43:34.659: %LINEPROTO-5-UPDOWN: Line protocol on Interface FastEthernet0/0, changed state to up PC3#conf t

Enter configuration commands, one per line. End with CNTL/Z. PC3(config)#no ip routing PC3(config)#

Router> Router>en Router#conf t

Enter configuration commands, one per line. End with CNTL/Z. Router(config)#no ip do lo Router(config)#line cons 0 Router(config-line)#no exec-t Router(config-line)#logg syn Router(config-line)#exit

Router(config)#hostname PC4 PC4(config)#int f0/0

PC4(config-if)#ip add 11.1.4.1 255.255.255.0 PC4(config-if)#no shut

PC4(config-if)#no shutdown PC4(config-if)#end PC4#

*Mar 1 00:43:54.995: %SYS-5-CONFIG_I: Configured from console by console PC4#

*Mar 1 00:43:55.599: %LINK-3-UPDOWN: Interface FastEthernet0/0, changed state to up

*Mar 1 00:43:56.599: %LINEPROTO-5-UPDOWN: Line protocol on Interface FastEthernet0/0, changed state to up PC4#conf t

Enter configuration commands, one per line. End with CNTL/Z. PC4(config)#no ip routing PC4(config)#end

测试vlan 2之间连通性

PC1#ping 11.1.3.1

Type escape sequence to abort.

Sending 5, 100-byte ICMP Echos to 11.1.3.1, timeout is 2 seconds: ..!!!

Success rate is 60 percent (3/5), round-trip min/avg/max = 36/50/72 ms PC1#ping 11.1.3.1

Type escape sequence to abort.

Sending 5, 100-byte ICMP Echos to 11.1.3.1, timeout is 2 seconds: !!!!!

Success rate is 100 percent (5/5), round-trip min/avg/max = 12/40/72 ms

测试vlan 3之间连通性

PC2#ping 11.1.4.1

Type escape sequence to abort.

Sending 5, 100-byte ICMP Echos to 11.1.4.1, timeout is 2 seconds: .!!!!

Success rate is 80 percent (4/5), round-trip min/avg/max = 4/35/64 ms PC2#ping 11.1.4.1

Type escape sequence to abort.

Sending 5, 100-byte ICMP Echos to 11.1.4.1, timeout is 2 seconds: !!!!!

Success rate is 100 percent (5/5), round-trip min/avg/max = 4/33/76 ms

因篇幅问题不能全部显示,请点此查看更多更全内容