天天看点

单臂路由:实现不同vlan之间的通信

1.单臂路由:实现不同vlan的通信。

(1)基本配置:

int f0/0

no shut

int f0/0.10 //创建一个子接口

encapsulation dot1q 10 //设置数据帧的封装格式为dot1q,对应的vlanID是10

ip add 192.168.10.254 255.255.255.0

(2)工作原理:

源目IP地址不变,二层mac地址被重写,实现标签置换。

2.实验步骤:先实现内网通信;再实现外网通信。

(1)第一步:先配置PC和网关

(2)第二步:配置二层交换机————划分vlan,配置trunk

Switch(config-if)#int f0/2

Switch(config-if)#sw mode acc

Switch(config-if)#sw acc vlan 20

Switch(config-if)#int f0/3

Switch(config-if)#switchport access vlan 30

Switch(config-if)#int f0/4

Switch(config-if)#switchport mode trunk

(3)第三步:在出口路由器的内接口,配置单臂路由,实现内网不同vlan的通信

interface FastEthernet0/0

no shutdown

interface FastEthernet0/0.10

encapsulation dot1Q 10

ip address 192.168.10.254 255.255.255.0

(4)第四步:内网通了以后,实现外网通信。

检查IP的命令:

R2(config-if)#do show ip int bri

R2(config-if)#do show ip route //检查路由表