思科模拟器的单臂路由,交换机,路由器,路由器只要两个端口的话,连接三台电脑该怎么办,划分VLAN,dotlq协议

发布于:2025-04-15 ⋅ 阅读:(28) ⋅ 点赞:(0)

单臂路由

1. 需求:让三台电脑互通
2. 在二层交换机划分vlan,并加入;
3. 将连接二层交换机和路由器的端口f0/4改为trunk模式
4. 路由器:进入连接路由器的f0/0端口将端口开启
5. 进入每个vlan设dotlq协议并设网络IP(ip address)
  • 将路由器给网络设网关

  • 给二层交换机设置VLAN

  • 记得配不通IP和不同网关(每台电脑都要,维护电脑可不要)具体看图

image-20250414223948236

二层交换机

image-20250414223202092

Switch>en
Switch#conf t
Switch(config)#vlan 10   //创建VLAN
Switch(config-vlan)#vlan 20
Switch(config-vlan)#vlan 30
Switch(config-vlan)#exit
Switch(config)#interface f0/1  //进入f0/1端口
Switch(config-if)#switchport access vlan 10  //将端口加入VLAN10
Switch(config-if)#exit
Switch(config)#interface f0/2  //进入f0/2端口
Switch(config-if)#switchport access vlan 30  //这边是要加入vlan20,不小心加错,下一步重新加入即可
Switch(config-if)#switchport access vlan 20  //将端口加入VLAN20
Switch(config-if)#exit
Switch(config)#interface f0/3  //进入f0/3端口
Switch(config-if)#switchport access vlan 30     //将端口加入VLAN30
Switch(config-if)#exit
Switch(config)#interface f0/4  //进入f0/4端口(可看到是连接路由器和交换机的那个端口
Switch(config-if)#switchport mode trunk //修改为trunk模式
Switch(config-if)#exit
Switch(config)#exit
Switch#
%SYS-5-CONFIG_I: Configured from console by console
​
Switch#show vlan brief //查看VLAN情况
​
VLAN Name                             Status    Ports
---- -------------------------------- --------- -------------------------------
1    default                          active    Fa0/4, Fa0/5, Fa0/6, Fa0/7
                                                Fa0/8, Fa0/9, Fa0/10, Fa0/11
                                                Fa0/12, Fa0/13, Fa0/14, Fa0/15
                                                Fa0/16, Fa0/17, Fa0/18, Fa0/19
                                                Fa0/20, Fa0/21, Fa0/22, Fa0/23
                                                Fa0/24, Gig0/1, Gig0/2
10   VLAN0010                         active    Fa0/1
20   VLAN0020                         active    Fa0/2
30   VLAN0030                         active    Fa0/3
1002 fddi-default                     active    
1003 token-ring-default               active    
1004 fddinet-default                  active    
1005 trnet-default                    active  

路由器

image-20250414224823865

Would you like to enter the initial configuration dialog? [yes/no]: no
​
​
Press RETURN to get started!
​
​
​
Router>en
Router#conf t
Router(config)#interface f0/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 f0/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)#encapsulation dot1Q 10  //dotlq协议 ,10表示的是vlan 10
Router(config-subif)#ip address 192.168.10.254 255.255.255.0 //ip地址 ip address 网关 子网掩码
Router(config-subif)#exit
Router(config)#interface f0/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 20  //dotlq协议 ,20表示的是vlan 20
Router(config-subif)#ip address 192.168.20.254 255.255.255.0
Router(config-subif)#exit
Router(config)#interface f0/0.3    //进入子接口
Router(config-subif)#
%LINK-5-CHANGED: Interface FastEthernet0/0.3, changed state to up
​
%LINEPROTO-5-UPDOWN: Line protocol on Interface FastEthernet0/0.3, changed state to up
​
Router(config-subif)#encapsulation dot1Q 30
Router(config-subif)#ip address 192.168.30.254 255.255.255.0
Router(config-subif)#exit
Router(config)#exit
​
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.10.0/24 is directly connected, FastEthernet0/0.1
C    192.168.20.0/24 is directly connected, FastEthernet0/0.2
C    192.168.30.0/24 is directly connected, FastEthernet0/0.3
​
Router#


网站公告

今日签到

点亮在社区的每一天
去签到