单臂路由配置实例

详解单臂路由

  单臂路由又名子接口,实际上是一个逻辑的接口,并不存在真正物理上的子接口。子接口有两种类型:点到点和点到多点。当采用点到点子接口时,每一个子接口用来连接一条PVC,每条PVC的另一端连接到另一路由器的一个子接口或物理接口,这种子接口的连接与通过物理接口连接的点对点连接交换果是一样的。每一对点对点的连接都是在不同的子网上。
  一个点到多点子接口被用来建立多条PVC,这些PVC连接到远端路由器的多点子接口或物理接口。这时,所有加入连接的接口(不管是物理接口还是子接口)都应该在同一个子网上。点到多点子接口和一个没有配置子接口的物理主接口相同,路由更新要受到水平分割的限制。默认情况下,多点子接口水平分割是开启的。
  基本信息
  目标:通过路由器进行多个VLAN互联
  环境:1. 交换机二层交换机,支持VLAN划分;2. 路由器只有1个Ethernet接口
  实施:采用单臂路由,即在路由器上设置多个逻辑子接口,每个子接口对应于一个VLAN。由于物理路由接口只有一个,各子接口的数据在物理链路上传递要进行标记封装。Cisco设备支持ISL和802.1q协议。华为设备只支持802.1q。

单臂路由的配置实例

  设备如图:pc机2台分别为 pc2和pc3、二层交换机1个为 s1、路由器1个为 R1
  实验拓扑

实验拓扑

  首先开始配置pc机的ip地址pc2:192.168.2.10 网关:192.168.2.1 pc3:192.168.3.10 网关:192.168.3.1 掩码都是24位的
  下面来配置交换机,分配好vlan。(简单的我就不解释了)
  Switch>enable
  Switch#vlan d
  % Warning: It is recommended to configure VLAN from config mode,
  as VLAN database mode is being deprecated. Please consult user
  documentation for configuring VTP/VLAN in config mode.
  Switch(vlan)#vlan 2 name test01
  VLAN 2 added:
  Name: test01
  Switch(vlan)#vlan 3 name test02
  VLAN 3 added:
  Name: test02 →设置好vlan ,这里只简单设置两个。
  Switch(vlan)#exit
  APPLY completed.
  Exiting....
  Switch#config
  Configuring from terminal, memory, or network [terminal]?
  Enter configuration commands, one per line. End with CNTL/Z.
  Switch(config)#interface fa0/2
  Switch(config-if)#switchport access vlan 2
  Switch(config-if)#exit
  Switch(config)#interface fa0/3
  Switch(config-if)#switchport access vlan 3
  Switch(config-if)#exit
  Switch(config)#interface fa0/1
  Switch(config-if)#switchport trunk encapsulation dot1q (2960等交换机只支持802.1q协议,这里忽略)
  Switch(config-if)#switchport mode trunk
  Switch(config-if)#switchport trunk allowed vlan all
  Switch(config-if)#exit
  Switch(config)#end
  %SYS-5-CONFIG_I: Configured from console by console
  Switch#write memory
  Building configuration...
  [OK]
  下面来重点,配置单臂路由:
  Router>enable
  Router#config
  Configuring from terminal, memory, or network [terminal]?
  Enter configuration commands, one per line. End with CNTL/Z. .................进入全局配置模式
  Router(config)#interface fa0/0 ................进入和交换机连接的那个接口
  Router(config-if)#no shutdown ................激活该端口
  Router(config-if)#exit ……………返回到全局配置模式
  Router(config)#interface fa0/0.1 ...........配置 子接口 这是配置单臂路由的关键,这个接口是个 逻辑接口,并不是实际存在的物理接口,但是功能却和物理接口是一样的。
  Router(config-subif)#encapsulation dot1q 2 .......为这个接口配置802.1Q协议,最后面的 2 是vlan 号,这也是关键部分
  Router(config-subif)#ip address 192.168.2.1 255.255.255.0 .........为该接口划分ip地址。
  Router(config-subif)#exit
  Router(config)#interface fa0/0.2 .....同样,进入第2个子接口,进行配置
  Router(config-subif)#encapsulation dot1q 3 .........配置802.1Q协议
  Router(config-subif)#ip address 192.168.3.1 255.255.255.0 ......划分ip地址和子网掩码
  Router(config-subif)#end
  %SYS-5-CONFIG_I: Configured from console by console ..........完成配置
  下面是测试结果:
  经过分别对两台机子互相ping的测试,可以发现能够ping通,说明实验成功。
原文地址:https://www.cnblogs.com/owenyang/p/3579105.html