1.0
如何配置IP网关
S1
:vlan 1 :IP : 10.1.0 .216
vlan 10
: name--V1 下属pc:IP:192.168.1.x24 网关 192.168.1.25424
vlan 20
: name--V2 下属pc:IP:192.168.2.x24 网关 192.168.2.25424
S2
:vlan1:IP: 10.2.0 .216
vlan 30
: name--V3 下属pc:IP:192.168.3.x24 网关 192.168.3.25424
vlan 40
: name--V4 下属pc:IP:192.168.4.x24 网关 192.168.4.25424
R1
:F00:IP: 10.1.0 .116
虚接口地址:
F00.1 IP
:192.168.1.25424
F00.2 IP
:192.168.2.25424
F01
:IP: 10.2.0 .116
虚接口地址:
F01.1 IP
:192.168.3.25424
F01.2 IP
:192.168.4.25424
拓扑图如下:
1.1
交换机S1 S2的配置:
S1
配置如下
Switch>en
Switch#conf t
Enter configuration commands, one per line. End with CNTL/Z.
Switch(config)#host
Switch(config)#hostname S1
S1(config)#vlan 10
S1(config-vlan)#name V1
S1(config-vlan)#exit
S1(config)#vlan 20
S1(config-vlan)#name V2
S1(config-vlan)#int vlan 1
S1(config-if)#ip address 10.1.0 .2 255.255.0.0
S1(config-if)#no shut
%LINK-5-CHANGED: Interface Vlan1, changed state to up
%LINEPROTO-5-UPDOWN: Line protocol on Interface Vlan1, changed state to up
S1(config-if)#int f0/2
S1(config-if)#switchport mode access
S1(config-if)#switchport access vlan 10
S1(config-if)#no shut
S1(config-if)#int f0/3
S1(config-if)#switchport mode access
S1(config-if)#switchport access vlan 20
S1(config-if)#no shut
S1(config-if)#int f0/1
S1(config-if)#switchport mode trunk
S1(config-if)#switchport trunk allowed vlan all
S1(config-if)#no shut
S1(config-if)#end
%SYS-5-CONFIG_I: Configured from console by console
S1#sh vlan
S2
设置如下
Switch>en
Switch#conf t
Enter configuration commands, one per line. End with CNTL/Z.
Switch(config)#hostname S2
S2(config)#vlan 30
S2(config-vlan)#name V3
S2(config-vlan)#no shut
% Invalid input detected at '^' marker.
S2(config-vlan)#vlan 40
S2(config-vlan)#name V4
S2(config-vlan)#int vlan 1
S2(config-if)#ip address 10.2.0 .2 255.255.0.0
S2(config-if)#no shut
%LINK-5-CHANGED: Interface Vlan1, changed state to up
%LINEPROTO-5-UPDOWN: Line protocol on Interface Vlan1, changed state to up
S2(config-if)#int f0/2
S2(config-if)#swit m a
S2(config-if)#swit access vlan 30
S2(config-if)#no shut
S2(config-if)#int f0/3
S2(config-if)#swit m a
S2(config-if)#swit a vlan 40
S2(config-if)#no shut
S2(config-if)#int f0/1
S2(config-if)#swit m t
S2(config-if)#swit trunk allowed vlan all
S2(config-if)#no shut
S2(config-if)#end
%SYS-5-CONFIG_I: Configured from console by console
S2#sh vlan
1.3
路由器的配置 :
路由器R1设置
Router>enable
Router#conf t
Enter configuration commands, one per line. End with CNTL/Z.
Router(config)#hostname R1
R1(config)#
R1(config)#int f0/0
R1(config-if)#ip address 10.1.0 .1 255.255.0.0
R1(config-if)#no shut
%LINK-5-CHANGED: Interface FastEthernet0/0, changed state to up
%LINEPROTO-5-UPDOWN: Line protocol on Interface FastEthernet0/0, changed state to up
R1(config-if)#int f0/1
R1(config-if)#ip address 10.1.1 .1 255.255.0.0
% 10.1.0 .0 overlaps with FastEthernet0/0
R1(config-if)#ip address 10.2.0 .1 255.255.0.0
R1(config-if)#no shut
%LINK-5-CHANGED: Interface FastEthernet0/1, changed state to up
%LINEPROTO-5-UPDOWN: Line protocol on Interface FastEthernet0/1, changed state to up
R1(config-if)#int f0/0.1
%LINK-5-CHANGED: Interface FastEthernet0/0.1, changed state to up
%LINEPROTO-5-UPDOWN: Line protocol on Interface FastEthernet0/0.1, changed
state to up
R1(config-subif)#encapsulation dot1q 10
R1(config-subif)#ip address 192.168.1.254 255.255.255.0
R1(config-subif)#no shut
R1(config-subif)#int f0/0.2
%LINK-5-CHANGED: Interface FastEthernet0/0.2, changed state to up
%LINEPROTO-5-UPDOWN: Line protocol on Interface FastEthernet0/0.2, changed state to up
R1(config-subif)#encapsulation dot1q 20
R1(config-subif)#ip address 192.168.2.254 255.255.255.0
R1(config-subif)#no shut
R1(config-subif)#int f0/1.1
%LINK-5-CHANGED: Interface FastEthernet0/1.1, changed state to up
%LINEPROTO-5-UPDOWN: Line protocol on Interface FastEthernet0/1.1, changed state to upR1(config-subif)#encapsulation dot1q 30
R1(config-subif)#ip address 192.168.3.254 255.255.255.0
R1(config-subif)#no shut
R1(config-subif)#int f0/1.2
%LINK-5-CHANGED: Interface FastEthernet0/1.2, changed state to up
%LINEPROTO-5-UPDOWN: Line protocol on Interface FastEthernet0/1.2, changed state to up
R1(config-subif)#encapsulation dot1q 40
R1(config-subif)#ip address 192.168.4.254 255.255.255.0
R1(config-subif)#no shut
R1(config-subif)#end
%SYS-5-CONFIG_I: Configured from console by console
现在,可以设置PC的属性了,别忘了四处ping下,检查是否设置成功。
二层交换机只允许同时存在一个vlan,这就决定了我们不可能靠二层交换机实现vlan的通讯,我们需要支持路由功能的三层交换机或者路由器来实现它。
3
层交换实现vlan通讯,好像不用多说了,interface vlan vlan-id 然后配置ip地址,ip address <ip address > <subnet mask>,前提是已经no switchport开启3层的路由功能了.而所说的虚接口地址就是vlan的ip address
本文出自 “企业VLAN路由” 博客,谢绝转载!