一、单臂路由配置
单臂路由配置如下:
连接拓扑图,在交换机上的全局模式下配置两个不同的vlan,比如:SW(config)#vlan10,将连接主机的端口划分进不同的vlan,SW(config)#intf0/2,SW(config-if)#swacvlan10,在交换机和路由器连接的链路上配置trunk,在路由器上配置子接口。
SW(config)#intf0/1,SW(config-if)#swmodetrunk,Router(config)#intf0/0,给主机配置IP地址和网关,如PC0的IP地址为172.168.1.2,网关为172.168.1.1.
单臂路由
是指在路由器的一个接口上通过配置子接口(或“逻辑接口”,并不存在真正物理接口)的方式,实现原来相互隔离的不同VLAN(虚拟局域网)之间的互联互通。在Cisco网络认证体系中,单臂路由是一个重要的学习知识点。
通过单臂路由的学习,能够深入的了解VLAN(虚拟局域网)的划分、封装和通信原理,理解路由器子接口、ISL协议和802.1Q协议,是CCNA考试中经常考的。
二、怎样在路由器上做单臂路由
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检查相互之间可以进行通信。
三、单臂路由的配置
单臂路由(一个路同器端口上两个以上的VLAN)+静态路由
先在左边交换机上配置两个VLAN10和VLAN20,将10、11端口配置给VLAN10,将20、21端口配置给VLAN20
PC0的IP为192.68.10.10 255.255.255.255.0
PC1的IP为192.68.10.11 255.255.255.255.0
PC2的IP为192.68.20.20 255.255.255.255.0
PC3的IP为192.68.20.21 255.255.255.255.0
Switch(config)#interface f 0/1
Switch(config-if)#switchport mode trunk
Switch(config-if)#no shutdown(设置交换机的0/1口为trunk,与路由器相连的设备)
Router(config)#interface fastEthernet 0/0(要先进0/0)
Router(config-if)#no shutdown(开启0/0端口)
Router(config-if)#interface fastEthernet 0/0.1(再进0/0.1)
Router(config-subif)#encapsulation dot1Q 10(0.1子接口封装VLAN10)
Router(config-subif)#ip address 192.168.10.1 255.255.255.0(设置0.1端口IP地址)
Router(config-subif)#int f 0/0.2
Router(config-subif)#encapsulation dot1Q 20(0.2子接口封装VLAN20)
Router(config-subif)#ip address 192.168.20.1 255.255.255.0(设置0.2端口IP地址)
第一个路由器
Router(config)#interface serial 2/0
Router(config-if)#ip address 192.168.30.1 255.255.255.0
Router(config-if)#no shuntdown(进入SERIAL2/0端口,配置IP地址并开启)
Router(config-if)#clock rate 4800(设置DCE端的时钟频率为4800 ?可查频率值)
第二个路由器
PC3的IP为192.68.20.21 255.255.255.255.0
Router(config)#interface serial 2/0
Router(config-if)#ip address 192.168.30.2 255.255.255.0
Router(config-if)#no shuntdown(进入SERIAL2/0端口,配置IP地址并开启)
Router(config)#interface fastEthernet 0/0
Router(config-if)#ip address 192.168.40.1 255.255.255.0
Router(config-if)#no shuntdown(进入fastEthernet 0/0端口,配置IP地址并开启)
分别配置第一个和第二个路由器的表态路由表
(1)Router(config)#ip route 192.168.40.0 255.255.255.0 192.168.30.2
(2)Router(config)#ip route 192.168.10.0 255.255.255.0 192.168.30.1
(2)Router(config)#ip route 192.168.20.0 255.255.255.0 192.168.30.1