单臂路由的基本配置(怎样在路由器上做单臂路由)

2023-06-10 18:42:05

一、单臂路由的基本配置


前面配置名字就不说了,在f0/0端口上建立子接口,并分别赋予vlan标记以及设置网关。

  • int f0/0.10

  • encapulation dot1q 10

  • ip add 192.168.10.1 255.255.255.0

  • int f0/0.20

  • encapulation dot1q 20

  • ip add 192.168.20.1 255.255.255.0

  • int f0/0.30

  • encapulation dot1q 30

  • ip add 192.168.30.1 255.255.255.0

    然后就是配置交换机,12口设置trunk允许vlan10、20、30通过,连接电脑的端口设置access口并允许相应的vlan

    电脑配置地址,ok!



二、怎样在路由器上做单臂路由


1、设备组网:2台电脑分别属于VLAN10和VLAN20,一台华为AR2220路由器和一台S5700交换机。

2、配置两台PC的IP地址。PC1为下图。

2、PC2为下图。

3、在交换机中进行如下配置:1).连接两台PC机的端口配置为access模式,且分别属于对应的VLAN;2).连接路由器的端口配置为trunk模式,且允许PC机的VLAN通过。

命令:

创建VLAN10和VLAN20:vlan batch 10 20

GE 0/0/2:

interface GigabitEthernet 0/0/2

port link-type access

port default vlan 10

quit

GE 0/0/3:

interface GigabitEthernet 0/0/3

port link-type access

port default vlan 20

quit

GE 0/0/1:

interface GigabitEthernet 0/0/1

port link-type trunk

port trunk allow-pass vlan 10 20

4、在路由器中将一个物理接口配置两个逻辑子接口,两个子接口都开启802.1q,且分别属于不同的VLAN。

命令:

子接口1:

interface GigabitEthernet 0/0/1.1

dot1q termination vid 10

ip address 10.0.10.1 255.255.255.0

arp broadcast enable

quit

子接口2:

interface GigabitEthernet 0/0/1.2

dot1q termination vid 20

ip address 10.0.20.1 255.255.255.0

arp broadcast enable

quit

5、当配置完成后,可以分别在PC1和PC2检查相互之间可以进行通信。



三、如何配置单臂路由与OSpF网络


Cisco单臂路由配置


单臂路由,即在路由器上设置多个逻辑子接口,每个子接口对应一个vlan。在每个子接口的数据在物理链路上传递都要标记封装。Cisco设备支持ISL和802.1q(dot1Q)协议。华为只支持802.1q。

DOT1Q和ISL的区别:DOT1Q是各类产品的VLAN通用协议模式,Dot1q是一种普遍使用的标准,适用所有交换机与路由设备。支持超过1024vlan,而ISL最多支持1024个vlan。ISL是CISCO设备的专用协议,适用于Cisco设备。 ISL(Interior Switching Link)交换机间协议用于实现CISCO交换机间的VLAN中继。它是一个信息包标记协议,在支持ISL接口上发送的帧由一个标准以太网帧及相关的VLAN信息组成。


PC1: IP :192.168.3.1/24 GW:255.255.255.0

PC2: IP :192.168.4.1/24 GW:255.255.255.0

S1:


Switch>enable

Switch#vlan database

Switch(vlan)#vlan 30

Switch(vlan)#vlan 40

Switch# configure terminal

Switch(config)#int fastEthernet 0/1

Switch(config-if)#switchport access vlan 30

Switch(config-if)#int f0/2

Switch(config-if)#switchport access vlan 40

Switch(config-if)#int f 0/24

Switch(config-if)#switchport mode trunk (把该接口设置为trunk模式)

Switch(config-if)#switchport trunk allowed vlan all (运行所有vlan通过)

如果要把交换机的多个端口划到一个vlan下用如下命令:

Switch-1(config)#interface range fastethernet 0/1 -10
Switch-1(config-range)#switchport access vlan 30

RT1:


Router>enable

Router#configure terminal

Router(config)#int fastEthernet 0/0.1 (进入子接口)

Router(config-subif)#encapsulation dot1Q 30 (封装dot1Q协议,建立与vlan30的关联)

Router(config-subif)#ip add 192.168.3.254 255.255.255.0

Router(config-subif)#int f 0/0.2

Router(config-subif)#encapsulation dot1Q 40 (封装dot1Q协议,建立与vlan40的关联)

Router(config-subif)#ip add 192.168.4.254 255.255.255.0

Router(config-subif)#int f 0/0

Router(config-if)#no shutdown (启动f0/0的接口,包括所有子接口)

完成。Vlan30能与vlan40互相通讯。

配置OSPF,带图连接:http://4011746.blog.51cto.com/4001746/1613198