#路由技术基础#
#任务二单臂路由的配置2#
#1配置计算机的IP地址、子网掩码和网关
#2在交换机A上配置主机名
Switch>enable
Switch#conf t
Switch(config)#hostname Switch-A
#3在交换机A上创建vlan 10,端口成员为fa0/1;创建vlan 20,端口成员2
Switch-A(config)#vlan 10
Switch-A(config-vlan)#exit
Switch-A(config)#vlan 20
Switch-A(config-vlan)#exit
Switch-A(config)#int fa0/1
Switch-A(config-if)#switchport access vlan 10
Switch-A(config)#int fa0/2
Switch-A(config-if)#switchport access vlan 20
#4在交换机A上配置Trunk
Switch-A(config)#int f0/24
Switch-A(config-if)#switchport mode trunk
#5路由器A的配置
Router>enable
Router#conf
Router(config)#hostname Router-A
Router-A(config)#int g0/0
Router-A(config-if)#no shutdown
Router-A(config-if)#no ip add
Router-A(config-if)#int g0/0.1 !进入g0/0.1子接口
Router-A(config-subif)#encapsulation dot1q 10 !封装Trunk协议dot1q,10为vlan 号
Router-A(config-subif)#ip add 192.168.10.1 255.255.255.0 !子接口就是电脑的网关
Router-A(config-subif)#no shutdown
Router-A(config-subif)#int g0/0.2
Router-A(config-subif)#encapsulation dot1q 20
Router-A(config-subif)#ip add 192.168.20.1 255.255.255.0
Router-A(config-subif)#no shutdown
#6测试连通性。在PC1上ping PC2的IP地址,网络已通
小贴士:
单臂路由,即在路由器上设置多个逻辑子接口。每个子接口对应一个vlan。每个子接口的数据在物理链路上传递时都要标记封装。对于路由器的端口,在支持子接口的同时,还必须支持Trunk功能。路由器中一定要创建两个vlan才能进行后续配置。