交换机配置——三层交换机实现VLAN间通信

一、实验目的::用三层交换机让同一vlan的主机能通信,不同vlan的主机也能通信

二、拓扑图如下

三、具体步骤如下:、

先给每台主机和服务器配置ip地址和网关

例:

(1)S1三层交换机配置:

Switch>en
Switch#conf t
Enter configuration commands, one per line. End with CNTL/Z.
Switch(config)#hostname S1
S1(config)#vtp domain test
Domain name already set to test.
S1(config)#vtp mode server
Device mode already VTP SERVER.
S1(config)#vlan 10
S1(config-vlan)#vlan 20
S1(config-vlan)#vlan 30
S1(config-vlan)#vlan 40
S1(config-vlan)#interface f0/1
S1(config-if)#switchport mode access
S1(config-if)#switchport mode trunk

S1(config-if)#interface range f0/2-3
S1(config-if-range)#switchport mode access
S1(config-if-range)#switchport access vlan 40
S1(config-if-range)#exit
S1(config)#ip routing
S1(config)#interface vlan 10
S1(config-if)#ip address 192.168.1.254 255.255.255.0
S1(config-if)#interface vlan 20
S1(config-if)#ip address 192.168.2.254 255.255.255.0
S1(config-if)#interface vlan 30
S1(config-if)#ip address 192.168.3.254 255.255.255.0
S1(config-if)#interface vlan 40
S1(config-if)#ip address 192.168.4.254 255.255.255.0
S1(config-if)#end
S1#copy running-config startup-config
%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

%LINK-5-CHANGED: Interface Vlan10, changed state to up

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

%LINK-5-CHANGED: Interface Vlan20, changed state to up

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

%LINK-5-CHANGED: Interface Vlan30, changed state to up

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

%LINK-5-CHANGED: Interface Vlan40, changed state to up

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

%SYS-5-CONFIG_I: Configured from console by console

Destination filename [startup-config]?
Building configuration...
[OK]

(2)S2交换机配置

Switch>en
Switch#conf t
Enter configuration commands, one per line. End with CNTL/Z.
Switch(config)#hostname S2
S2(config)#vtp mode client
Device mode already VTP CLIENT.
S2(config)#interface f0/10
S2(config-if)#switchport mode trunk

S2(config-if)#interface f0/1
S2(config-if)#switchport mode access
S2(config-if)#switchport access vlan 30
S2(config-if)#interface f0/2
S2(config-if)#switchport mode access
S2(config-if)#switchport access vlan 20
S2(config-if)#interface f0/3
S2(config-if)#switchport mode access
S2(config-if)#switchport access vlan 10
S2(config-if)#end
S2#copy running-config startup-config
%LINEPROTO-5-UPDOWN: Line protocol on Interface FastEthernet0/10, changed state to down

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

%SYS-5-CONFIG_I: Configured from console by console

Destination filename [startup-config]?
Building configuration...
[OK]

(3)S3交换机配置

Switch>en
Switch#conf t
Enter configuration commands, one per line. End with CNTL/Z.
Switch(config)#hostname S3
S3(config)#vtp mode client
Device mode already VTP CLIENT.
S3(config)#interface range f0/10-12
S3(config-if-range)#switchport mode trunk


S3(config-if-range)#interface f0/1
S3(config-if)#switchport mode access
S3(config-if)#switchport access vlan 30
S3(config-if)#interface f0/2
S3(config-if)#switchport mode access
S3(config-if)#switchport access vlan 20
S3(config-if)#interface f0/3
S3(config-if)#switchport mode access
S3(config-if)#switchport access vlan 10
S3(config-if)#end
S3#copy running-config startup-config
%LINEPROTO-5-UPDOWN: Line protocol on Interface FastEthernet0/10, changed state to down

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

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

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

%SYS-5-CONFIG_I: Configured from console by console

Destination filename [startup-config]?
Building configuration...
[OK]

(4)S4交换机配置

Switch>en
Switch#conf t
Enter configuration commands, one per line. End with CNTL/Z.
Switch(config)#hostname S4
S4(config)#vtp mode client
Device mode already VTP CLIENT.
S4(config)#interface f0/10
S4(config-if)#switchport mode trunk
S4(config-if)#interface f0/1
S4(config-if)#switchport mode access
S4(config-if)#switchport access vlan 30
S4(config-if)#interface f0/2
S4(config-if)#switchport mode access
S4(config-if)#switchport access vlan 20
S4(config-if)#interface f0/3
S4(config-if)#switchport mode access
S4(config-if)#switchport access vlan 10
S4(config-if)#end
S4#copy running-config startup-config
%SYS-5-CONFIG_I: Configured from console by console

Destination filename [startup-config]?
Building configuration...
[OK]

四、验证

测试不同vlan下的主机是否互通

(1)PC11PC33

vlan10vlan30互通

(2)PC13PC21

vlan10vlan20互通

猜你喜欢

转载自www.cnblogs.com/evolve/p/9184987.html