配置单臂路由--Cisco2621
单臂路由(Single-arm routing)是指在路由器的一个接口上通过配置子接口(或“逻辑接口”,并不存在真正物理接口)的方式,实现原来相互隔离的不同VLAN(虚拟局域网)之间的互联互通。由于从拓扑结构图上看,在交换机与路由器之间,数据从一条线路进去,又从一个线路出来,两条线路重合,故形象的称之为“单臂路由”
优点:实现不同vlan之间的通信,有助理解、学习VLAN原理和子接口概念。
缺点:容易成为网络单点故障,配置稍有复杂,现实意义不大。
拓扑图:
配置交换机:
fastEthernet 0/1-10端口加入vlan 2
fastEthernet 0/11-20端口加入vlan 3
fastEthernet 0/21-23端口加入vlan 4
fastEthernet 0/24端口模式改为trunk
Switch>enable
Switch#configure terminal
Switch(config)#vlan 2
Switch(config-vlan)#vlan 3
Switch(config-vlan)#vlan 4
Switch(config-vlan)#exit
Switch(config)#interface range fastEthernet 0/1-10
Switch(config-if-range)#switchport access vlan 2
Switch(config-if-range)#exit
Switch(config)#interface range fastEthernet 0/11-20
Switch(config-if-range)#switchport access vlan 3
Switch(config-if-range)#exit
Switch(config)#interface range fastEthernet 0/21-23
Switch(config-if-range)#switchport access vlan 4
Switch(config-if-range)#exit
Switch(config)#interface fastEthernet 0/24
Switch(config-if)#switchport mode trunk
Switch(config-if)#end
此时查看交换机vlan状态:
VLAN Name Status Ports
---- -------------------------------- --------- -------------------------------
1 default active Fa0/24, Gig1/1, Gig1/2
2 VLAN0002 active Fa0/1, Fa0/2, Fa0/3, Fa0/4
Fa0/5, Fa0/6, Fa0/7, Fa0/8
Fa0/9, Fa0/10
3 VLAN0003 active Fa0/11, Fa0/12, Fa0/13, Fa0/14
Fa0/15, Fa0/16, Fa0/17, Fa0/18
Fa0/19, Fa0/20
4 VLAN0004 active Fa0/21, Fa0/22, Fa0/23
1002 fddi-default act/unsup
1003 token-ring-default act/unsup
1004 fddinet-default act/unsup
1005 trnet-default act/unsup
配置路由器:
1、开启f0/0接口
2、设置fastEthernet0/0.1、fastEthernet0/0.2、fastEthernet0/0.3虚拟接口
3、用encapsulation dot1Q [vlan id]封装802.1q协议,并将虚拟接口划分到相应的VLAN中
fastEthernet0/0.1 划分到vlan 2 ====>>encapsulation dot1Q 2
fastEthernet0/0.2 划分到vlan 3 ====>>encapsulation dot1Q 3
fastEthernet0/0.3 划分到vlan 4 ====>>encapsulation dot1Q 4
4、给这三个虚拟机接口配置IP地址
Router>enable
Router#configure terminal
Router(config)#interface fastEthernet 0/0
Router(config-if)#no shutdown
Router(config-if)#interface fastEthernet 0/0.1
Router(config-subif)#encapsulation dot1Q 2
Router(config-subif)#interface fastEthernet 0/0.2
Router(config-subif)#encapsulation dot1Q 3
Router(config-subif)#interface fastEthernet 0/0.3
Router(config-subif)#encapsulation dot1Q 4
Router(config-subif)#exit
Router(config)#interface fastEthernet 0/0.1
Router(config-subif)#ip add 192.168.1.1 255.255.255.0
Router(config-subif)#no shutdown
Router(config-subif)#exit
Router(config)#interface fastEthernet 0/0.2
Router(config-subif)#ip add 192.168.2.1 255.255.255.0
Router(config-subif)#no shutdown
Router(config-subif)#exit
Router(config)#interface fastEthernet 0/0.3
Router(config-subif)#ip add 192.168.3.1 255.255.255.0
Router(config-subif)#no shutdown
Router(config-subif)#end
在路由器上启动DHCP
Router#configure terminal
Router(config)#ip dhcp pool vlan2
Router(dhcp-config)#network 192.168.1.0 255.255.255.0
Router(dhcp-config)#default-router 192.168.1.1
Router(dhcp-config)#dns-server 8.8.8.8
Router(dhcp-config)#exit
Router(config)#ip dhcp pool vlan3
Router(dhcp-config)#network 192.168.2.0 255.255.255.0
Router(dhcp-config)#default-router 192.168.2.1
Router(dhcp-config)#dns-server 8.8.8.8
Router(dhcp-config)#exit
Router(config)#ip dhcp pool vlan4
Router(dhcp-config)#network 192.168.3.0 255.255.255.0
Router(dhcp-config)#default-router 192.168.3.1
Router(dhcp-config)#dns-server 8.8.8.8
Router(dhcp-config)#end
最后,配置成功: