单臂路由实现不同vlan之间的通信

本文详细介绍了一个Cisco网络模拟配置实例,包括构建拓扑图、主机设置、交换机与路由器的详细配置步骤,以及如何验证配置结果。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

Cisco 模拟为例

1.在电脑里搭建一个模拟拓扑图
如下图所示
图1
在这里插入图片描述
图1
一个路由器,三个交换机,再来四台主机,型号随便选,自己的习惯。
接线的话可以自动连接,也可以自己手动连接,连线口诀:相同设备用交叉线,异同设备用直连线

2.搭建好后就是设置问题了
2.1 第一台主机的设置:
设计主机0位为vlan100 IP 192.168.1.10 , 子网掩码以及网关
在这里插入图片描述在这里插入图片描述

接着设计第二台、第三台和第四台pc
在这里插入图片描述在这里插入图片描述
在这里插入图片描述在这里插入图片描述
在这里插入图片描述在这里插入图片描述

2.2交换机的配置
双击进入交换机0

Switch>enable
Switch#vlan database 
% 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 100 name it
VLAN 100 added:
    Name: it
Switch(vlan)#vlan 200 name cw
VLAN 200 added:
    Name: cw
Switch(vlan)#exit
APPLY completed.
Exiting....
Switch#configure terminal 
Enter configuration commands, one per line.  End with CNTL/Z.
Switch(config)#interface fastEthernet 0/1

Switch(config-if)#switchport mode access

Switch(config-if)#switchport access vlan 100
Switch(config-if)#exit

Switch(config)#interface fastEthernet 0/2

Switch(config-if)#switchport mode access

Switch(config-if)#switchport access vlan 200

Switch(config-if)#exit

Switch(config)#interface fastEthernet 0/24

Switch(config-if)#switchport mode trunk 

Switch(config-if)#switchport trunk allowed vlan all
Switch(config-if)#end

Switch#write
Building configuration...

在这里插入图片描述
在这里插入图片描述
设置成功后可查看当前的设置看是否设置正确。

交换机1同理

接着设计交换机2

Switch>enable 
Switch#configure term
Enter configuration commands, one per line.  End with CNTL/Z.

Switch(config)#interface range fastEthernet 0/1-2

Switch(config-if-range)#switchport mode trunk 

Switch(config-if-range)#switchport trunk allowed vlan all

Switch(config-if-range)#end

Switch#vlan data
Switch#vlan database 
Switch(vlan)#vlan 100 
VLAN 100 added:
    Name: VLAN0100
Switch(vlan)#vlan 200
VLAN 200 added:
    Name: VLAN0200
Switch(vlan)#exit
Switch>enable 

Switch#configure terminal 
Enter configuration commands, one per line.  End with CNTL/Z.

Switch(config)#interface fastEthernet 0/3

Switch(config-if)#switchport mode trunk 

Switch(config-if)#
%LINEPROTO-5-UPDOWN: Line protocol on Interface FastEthernet0/3, changed state to down

%LINEPROTO-5-UPDOWN: Line protocol on Interface FastEthernet0/3, changed state to up

Switch(config-if)#switchport trunk allowed vlan all

Switch(config-if)#exit
Switch(config)#end
Switch#write 

最后设置路由器0

Router>
Router>enable 
Router#configure terminal 
Enter configuration commands, one per line.  End with CNTL/Z.

Router(config)#interface fastEthernet 0/0

Router(config-if)#no shutdown 

Router(config-if)#
%LINK-5-CHANGED: Interface FastEthernet0/0, changed state to up

%LINEPROTO-5-UPDOWN: Line protocol on Interface FastEthernet0/0, changed state to up
Router(config-if)#exit

Router(config)#interface fastEthernet 0/0.1
Router(config-subif)#
%LINK-5-CHANGED: Interface FastEthernet0/0.1, changed state to up

%LINEPROTO-5-UPDOWN: Line protocol on Interface FastEthernet0/0.1, changed state to up

Router(config-subif)#en
Router(config-subif)#encapsulation ?
  dot1Q  IEEE 802.1Q Virtual LAN
Router(config-subif)#encapsulation 
% Incomplete command.
Router(config-subif)#encapsulation dot1Q 100

Router(config-subif)#ip address 192.168.1.254 255.255.255.0
Router(config-subif)#no shutdown 
Router(config-subif)#exit
Router(config)#interface fastEthernet 0/0.2
Router(config-subif)#
%LINK-5-CHANGED: Interface FastEthernet0/0.2, changed state to up

%LINEPROTO-5-UPDOWN: Line protocol on Interface FastEthernet0/0.2, changed state to up

Router(config-subif)#encapsulation dot1Q 200
Router(config-subif)#ip address 192.168.2.254 255.255.255.0
Router(config-subif)#no shut
Router(config-subif)#no shutdown 
Router(config-subif)#exit
Router(config)#end
Router#
%SYS-5-CONFIG_I: Configured from console by console

Router#show ip route 
Codes: C - connected, S - static, I - IGRP, R - RIP, M - mobile, B - BGP
       D - EIGRP, EX - EIGRP external, O - OSPF, IA - OSPF inter area
       N1 - OSPF NSSA external type 1, N2 - OSPF NSSA external type 2
       E1 - OSPF external type 1, E2 - OSPF external type 2, E - EGP
       i - IS-IS, L1 - IS-IS level-1, L2 - IS-IS level-2, ia - IS-IS inter area
       * - candidate default, U - per-user static route, o - ODR
       P - periodic downloaded static route

Gateway of last resort is not set

C    192.168.1.0/24 is directly connected, FastEthernet0/0.1
C    192.168.2.0/24 is directly connected, FastEthernet0/0.2

Router#write 

配置完成后,我们可以进行发包试试

在这里插入图片描述
最后实现不同vlan发包。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值