vlan路由

VLAN间路由

定义

指导设备对不同vlan间进行三层数据转发

实现方式

单臂路由实验

在这里插入图片描述
1、路由器配置(使用子接口)

[R1]interface g0/0.1
[R1-GigabitEthernet0/0.1]vlan-type dot1q vid 10
[R1-GigabitEthernet0/0.1]ip add 192.168.1.254 24
[R1-GigabitEthernet0/0.1]int g0/0.2
[R1-GigabitEthernet0/0.2]vlan-type dot1q vid 20
[R1-GigabitEthernet0/0.2]ip address 192.168.2.254 24
[R1]dis ip  interface brief
*down: administratively down
(s): spoofing  (l): loopback
Interface                Physical Protocol IP Address      Description
GE0/0                    up       up       --              --
GE0/0.1                  up       up       192.168.1.254   --
GE0/0.2                  up       up       192.168.2.254   --
**路由也自动学到**
192.168.1.0/24     Direct  0   0           192.168.1.254   GE0/0.1
192.168.1.0/32     Direct  0   0           192.168.1.254   GE0/0.1
192.168.1.254/32   Direct  0   0           127.0.0.1       InLoop0
192.168.1.255/32   Direct  0   0           192.168.1.254   GE0/0.1
192.168.2.0/24     Direct  0   0           192.168.2.254   GE0/0.2
192.168.2.0/32     Direct  0   0           192.168.2.254   GE0/0.2

2、交换机配置

[SW]VLAN 10
[SW-vlan10]port g1/0/2
[SW-vlan10]vlan 20
[SW-vlan20]port g1/0/3
[SW-vlan20]inter g1/0/1
[SW-GigabitEthernet1/0/1]port link-type trunk
[SW-GigabitEthernet1/0/1]port trunk permit  vlan 10 20

三层交换

使交换机有三层路由的功能
三层交换机上启用vlanif三层接口,配置为网关IP
自动产生所有到达vlan的直连路由
实验
在这里插入图片描述
交换机

[SW]interface Vlan 10
[SW-Vlan-interface10]ip add 192.168.1.254 24
[SW-Vlan-interface10]int vlan 20
[SW-Vlan-interface20]ip add 192.168.2.254 24
[SW-Vlan-interface20]dis ip interface  b
*down: administratively down
(s): spoofing  (l): loopback
Interface                Physical Protocol IP Address      Description
MGE0/0/0                 down     down     --              --
Vlan10                   up       up       192.168.1.254   --
Vlan20                   up       up       192.168.2.254   --
<SW>dis ip routing-table
192.168.1.0/24     Direct  0   0           192.168.1.254   Vlan10
192.168.2.0/24     Direct  0   0           192.168.2.254   Vlan20

常用命令

interface 'sub-interface'  #创建子接口,进入子接口视图
[R1-GigabitEthernet0/0.1]vlan-type dot1q vid '为子接口开启802.1Q识别,并绑定vlanid
interface vlan-interface 'vlan-id' #创建Vlanif三层接口,进入Vlanif接口视图
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值