【vlan间通信的小玩法】在三层交换机上做ospf

目录

一、拓扑图如下:

1、方法一:

划分vlan(access和trunk)

 交换机与终端相连的配置access口 交换机之间全trunk口,放行所有vlan(allow 10 20 30 40 50)

2、方法二:

运用ospf 

将lsw1和lsw2当做路由器,配置ospf将vlan50 作为lsw1和lsw2的连接链路注意:此时两个单臂路由的vlanif 50的IP地址就不同了我配置的是254和253

3.静态路由(略)

配静态有些许麻烦就没整了


一、拓扑图如下:

实现全网通,任意方式都可

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
#

3.静态路由(略)

配静态有些许麻烦就没整了

  • 5
    点赞
  • 75
    收藏
    觉得还不错? 一键收藏
  • 2
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值