单臂路由不同Vlan配置(三层交换机与路由器)

单臂路由与交换机(VLAN)
在这里插入图片描述
PC设置ip
PC0:192.168.10.10
PC1:192.168.20.10
PC2:192.168.30.10

PC3:192.168.20.11
PC4:192.168.30.11
PC5:192.168.40.11

交换机sw0:
Switch>enable
Switch#conf t
Switch(config)#hostname sw0
sw0(config)#enable password 111
sw0(config)#line console 0
sw0(config-line)#password 112
sw0(config-line)#exit
sw0(config)#line vty 0 15
sw0(config-line)#password 113
sw0(config-line)#exit
sw0(config)#exit

sw0#vlan database
sw0(vlan)#vlan 10 name v10
VLAN 10 added:
Name: v10
sw0(vlan)#vlan 20 name v20
VLAN 20 added:
Name: v20
sw0(vlan)#vlan 30 name v30
VLAN 30 added:
Name: v30
sw0(vlan)#exit

sw0#conf t
sw0(config)#int range f0/1-f0/7
sw0(config-if-range)#switchport access vlan 10
sw0(config-if-range)#no shutdown
sw0(config-if-range)#exit
sw0(config)#int range f0/8-f0/15
sw0(config-if-range)#switchport access vlan 20
sw0(config-if-range)#no shutdown
sw0(config-if-range)#exit
sw0(config)#int range f0/16-f0/23
sw0(config-if-range)#switchport access vlan 30
sw0(config-if-range)#no shutdown
sw0(config-if-range)#exit
sw0(config)#int f0/24
sw0(config-if)#switchport mode trunk
sw0(config-if)#exit
sw0(config)#exit

交换机sw1:
Switch>enable
Switch#conf t
Switch(config)#enable password 221
Switch(config)#line console 0
Switch(config-line)#password 222
Switch(config-line)#exit
Switch(config)#line vty 0 15
Switch(config-line)#password 223
Switch(config-line)#exit
Switch(config)#hostname sw1
sw1(config)#exit

sw1#vlan database
sw1(vlan)#vlan 10 name v10
VLAN 10 added:
Name: v10
sw1(vlan)#vlan 20 name v20
VLAN 20 added:
Name: v20
sw1(vlan)#vlan 30 name v30
VLAN 30 added:
Name: v30
sw1(vlan)#vlan 40 name v40
VLAN 40 added:
Name: v40
sw1(vlan)#exit

sw1#conf t
sw1(config)#int range f0/1-f0/7
sw1(config-if-range)#switchport access vlan 20
sw1(config-if-range)#no shutdown
sw1(config-if-range)#exit
sw1(config)#int range f0/8-f0/15
sw1(config-if-range)#switchport access vlan 30
sw1(config-if-range)#no shutdown
sw1(config-if-range)#exit
sw1(config)#int range f0/16-f0/22
sw1(config-if-range)#switchport access vlan 40
sw1(config-if-range)#no shutdown
sw1(config-if-range)#exit
sw1(config)#int f0/23
sw1(config-if)#switchport mode trunk
sw1(config-if)#exit
sw1(config)#int f0/24
sw1(config-if)#switchport mode trunk
sw1(config)#exit

核心交换机msw1:
Switch>en
Switch#conf t
Switch(config)#hostname msw1
msw1(config)#enable password 331
msw1(config)#line console 0
msw1(config-line)#password 332
msw1(config-line)#exit
msw1(config)#line vty 0 15
msw1(config-line)#password 333
msw1(config-line)#exit
msw1(config)#exit

msw1#vlan database
msw1(vlan)#vlan 10 name v10
VLAN 10 added:
Name: v10
msw1(vlan)#vlan 20 name v20
VLAN 20 added:
Name: v20
msw1(vlan)#vlan 30 name v30
VLAN 30 added:
Name: v30
msw1(vlan)#vlan 40 name v40
VLAN 40 added:
Name: v40
msw1(vlan)#exit

msw1#conf t
msw1(config)#int vlan 10
msw1(config-if)#ip add 192.168.10.1 255.255.255.0
msw1(config-if)#no shutdown
msw1(config-if)#exit
msw1(config)#int vlan 20
msw1(config-if)#ip add 192.168.20.1 255.255.255.0
msw1(config-if)#no shutdown
msw1(config-if)#exit
msw1(config)#int vlan 30
msw1(config-if)#ip add 192.168.30.1 255.255.255.0
msw1(config-if)#no shutdown
msw1(config-if)#exit
msw1(config)#int vlan 40
msw1(config-if)#ip add 192.168.40.1 255.255.255.0
msw1(config-if)#no shutdown
msw1(config-if)#exit
msw1(config)#ip routing
msw1(config)#exit

在这里插入图片描述
将核心交换机换成路由器:
在这里插入图片描述
Router>en
Router#conf t
Router(config)#hostname r1
r1(config)#enable password 331
r1(config)#line console 0
r1(config-line)#password 332
r1(config-line)#exit
r1(config)#line vty 0 15
r1(config-line)#password 333
r1(config-line)#exit

r1(config)#int f0/0
r1(config-if)#no shutdown
r1(config-if)#int f0/0.10
r1(config-subif)#encapsulation dot1Q 10
r1(config-subif)#ip add 192.168.10.1 255.255.255.0
r1(config-subif)#no shutdown
r1(config-subif)#exit
r1(config)#int f0/0.20
r1(config-subif)#encapsulation dot1Q 20
r1(config-subif)#ip add 192.168.20.1 255.255.255.0
r1(config-subif)#no shutdown
r1(config-subif)#exit
r1(config)#int f0/0.30
r1(config-subif)#encapsulation dot1Q 30
r1(config-subif)#ip add 192.168.30.1 255.255.255.0
r1(config-subif)#no shutdown
r1(config-subif)#exit
r1(config)#int f0/0.40
r1(config-subif)#encapsulation dot1Q 40
r1(config-subif)#ip address 192.168.40.1 255.255.255.0
r1(config-subif)#no shutdown
r1(config-subif)#exit
r1(config)#exit

切记:
1,在连接三层交换机和路由器的二层交换机端口必须设置trunk,否则vlan数据无法通过二层交换机到达三成交换机和路由器。
2,在三层交换机和路由器切换的时候,一定要重启PC电脑,网络才可以ping通。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值