怎样让用路由器相连两台二层交换机的两个vlan互相访问?
1、配置PC1:IP: 192.168.1.2Submask: 255.255.255.0 Gageway:192.168.1.1。
2、配置PC2:IP: 192.168.2.2Submask: 255.255.255.0 Gageway:192.168.2.1。
3、测试连通性PC1 Ping PC2 ,Ping 192.168.2.2 。
4、设置交换机Switch:interface fastEthernet 0/2 //进入交换机0模块第2端口switchport access vlan 2 //加入vlan 2 exit int fa 0/3 //进入交换机0模块第3端口。
5、设置路由器:Router>en Router#conf t Router(config)#int fa0/0//进入路由器0模块第0端口 Router(config-if)#no shutdown //开启该端口。
6、测试连通性:PC1 Ping PC2 , Ping 192.168.2.2 。
有多种方法可以实现:比如PVLAN,ACL等。按照你的拓扑,我用PT模拟了一种做法:单臂路由+ACL,可以参考一下,有图,有配置:
交换机A:
interface FastEthernet0/2
switchport access vlan 100
switchport mode access
!
interface FastEthernet0/3
switchport access vlan 100
switchport mode access
!
interface FastEthernet0/11
switchport access vlan 200
switchport mode access
!
interface FastEthernet0/12
switchport access vlan 200
switchport mode access
!
interface FastEthernet0/1
switchport trunk allowed vlan 100,200
switchport mode trunk
交换机B:
interface FastEthernet0/2
switchport access vlan 300
switchport mode access
!
interface FastEthernet0/3
switchport access vlan 300
switchport mode access
!
interface FastEthernet0/11
switchport access vlan 400
switchport mode access
!
interface FastEthernet0/12
switchport access vlan 400
switchport mode access
!
interface FastEthernet0/1
switchport trunk allowed vlan 300,400
switchport mode trunk
Router:
interface FastEthernet0/0.1
encapsulation dot1Q 100
ip address 192.168.1.1 255.255.255.0
!
interface FastEthernet0/0.2
encapsulation dot1Q 200
ip address 192.168.2.1 255.255.255.0
!
interface FastEthernet0/1.1
encapsulation dot1Q 400
ip address 192.168.4.1 255.255.255.0
!
interface FastEthernet0/1.2
encapsulation dot1Q 300
ip address 192.168.3.1 255.255.255.0
ip access-group 1 out
!
access-list 1 deny 192.168.1.0 0.0.0.255
access-list 1 permit any
所以你应该把vlan200 和vlan400划为同一个vlan 当然你的两个vlan必须处于同一网段
vlan300 和vlan100 不用管
同时两交换机相连的接口应该打上他trunk