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接口视图