目录
交换机与终端相连的配置access口 交换机之间全trunk口,放行所有vlan(allow 10 20 30 40 50)
将lsw1和lsw2当做路由器,配置ospf将vlan50 作为lsw1和lsw2的连接链路注意:此时两个单臂路由的vlanif 50的IP地址就不同了我配置的是254和253
一、拓扑图如下:
实现全网通,任意方式都可
1、方法一:
划分vlan(access和trunk)
交换机与终端相连的配置access口
交换机之间全trunk口,放行所有vlan(allow 10 20 30 40 50)
lsw3的配置如下:
#
vlan batch 10 20 30 40 50
#
#
interface GigabitEthernet0/0/1
port link-type access
port default vlan 10
#
interface GigabitEthernet0/0/2
port link-type access
port default vlan 20
#
interface GigabitEthernet0/0/3
port link-type access
port default vlan 50
#
interface GigabitEthernet0/0/4
port link-type trunk
port trunk allow-pass vlan 10 20 30 40 50
#
lsw4的配置如下:
(同理lsw3)
#
vlan batch 10 20 30 40 50
#
#
interface GigabitEthernet0/0/1
port link-type access
port default vlan 40
#
interface GigabitEthernet0/0/2
port link-type access
port default vlan 40
#
interface GigabitEthernet0/0/3
port link-type access
port default vlan 50
#
interface GigabitEthernet0/0/4
port link-type trunk
port trunk allow-pass vlan 10 20 30 40 50
#
lsw1的配置如下:
#
vlan batch 10 20 30 40 50
#
#
interface Vlanif10
ip address 192.168.1.254 255.255.255.0
#
interface Vlanif20
ip address 192.168.2.254 255.255.255.0
#
#
interface Vlanif30
ip address 192.168.3.254 255.255.255.0
#
interface Vlanif40
ip address 192.168.4.254 255.255.255.0
#
#
interface Vlanif50
ip address 192.168.5.254 255.255.255.0
#
#
interface GigabitEthernet0/0/1
port link-type trunk
port trunk allow-pass vlan 10 20 30 40 50
#
interface GigabitEthernet0/0/2
port link-type trunk
port trunk allow-pass vlan 10 20 30 40 50
#
lsw2的配置如下:
(同理lsw1)
#
vlan batch 10 20 30 40 50
#
#
interface Vlanif10
ip address 192.168.1.254 255.255.255.0
#
interface Vlanif20
ip address 192.168.2.254 255.255.255.0
#
interface Vlanif30
ip address 192.168.3.254 255.255.255.0
#
interface Vlanif40
ip address 192.168.4.254 255.255.255.0
#
interface Vlanif50
ip address 192.168.5.254 255.255.255.0
#
#
interface GigabitEthernet0/0/1
port link-type trunk
port trunk allow-pass vlan 10 20 30 40 50
#
interface GigabitEthernet0/0/2
port link-type trunk
port trunk allow-pass vlan 10 20 30 40 50
#
2、方法二:
运用ospf
将lsw1和lsw2当做路由器,配置ospf
将vlan50 作为lsw1和lsw2的连接链路
注意:此时两个单臂路由的vlanif 50的IP地址就不同了
我配置的是254和253
把三层交换机看做是路由器隔离广播域,在 单个单臂路由下vlan能相互访问,然后配置ospf
将接口直连的网段宣告出去就好,因为两个单臂路由都有相同的vlan 50,所以可以看做是路由器之间vlan 50在联通链路。
可以理解成这样:如图:
配置命令:
lsw3的配置如下: # vlan batch 10 20 50 # # interface GigabitEthernet0/0/1 port link-type access port default vlan 10 # interface GigabitEthernet0/0/2 port link-type access port default vlan 20 # interface GigabitEthernet0/0/3 port link-type access port default vlan 50 # interface GigabitEthernet0/0/4 port link-type trunk port trunk allow-pass vlan 10 20 30 40 50 # lsw4的配置如下: (同理lsw3) # vlan batch 10 20 30 40 50 # # interface GigabitEthernet0/0/1 port link-type access port default vlan 30 # interface GigabitEthernet0/0/2 port link-type access port default vlan 40 # interface GigabitEthernet0/0/3 port link-type access port default vlan 50 # # interface GigabitEthernet0/0/4 port link-type trunk port trunk allow-pass vlan 10 20 30 40 50 #
lsw1的配置如下: # vlan batch 10 20 30 40 50 # # interface Vlanif10 ip address 192.168.1.254 255.255.255.0 # interface Vlanif20 ip address 192.168.2.254 255.255.255.0 # # interface Vlanif50 ip address 192.168.5.254 255.255.255.0 # # interface GigabitEthernet0/0/1 port link-type trunk port trunk allow-pass vlan 10 20 50 # interface GigabitEthernet0/0/2 port link-type trunk port trunk allow-pass vlan 50 # # ospf 1 router-id 1.1.1.1 area 0.0.0.0 network 192.168.1.0 0.0.0.255 network 192.168.2.0 0.0.0.255 network 192.168.5.0 0.0.0.255 # lsw2的配置如下: (同理lsw1) # vlan batch 10 20 30 40 50 # # interface Vlanif30 ip address 192.168.3.254 255.255.255.0 # interface Vlanif40 ip address 192.168.4.254 255.255.255.0 # interface Vlanif50 ip address 192.168.5.253 255.255.255.0 # # interface GigabitEthernet0/0/1 port link-type trunk port trunk allow-pass vlan 30 40 50 # interface GigabitEthernet0/0/2 port link-type trunk port trunk allow-pass vlan 50 # # ospf 1 router-id 2.2.2.2 area 0.0.0.0 network 192.168.3.0 0.0.0.255 network 192.168.4.0 0.0.0.255 network 192.168.5.0 0.0.0.255 #