计算机网络实验交换机的配置_Cisco Packet Tracer部分网络实验交换机路由器配置代码详解...

声明:

本文内容基于个人实践经验整理编写而成。注释组成为:“简写代码//全写代码//中文注释”本文属于Project HOW?项目组成部分。若有错误或不足之处存在请联系专栏作者指出,谢谢。本文禁止转载。

更新:

2020.03.05:修正注释。


  • 三层交换机互联实验代码详解:

61089fbaccc95a05ebf78c7a3130a0f7.png

第一台三层交换机(靠左):

>en enable 开启特权模式

>conf t configure terminal 开启全局配置模式

>ho MLS1 hostname MLS1 命名主机为MLS1

>vl 2 VLAN 2 创建VLAN 002

>vl 3 VLAN 3 创建VLAN 003

>vl 6 VLAN 6 创建VLAN 006

>in vl 2 interface VLAN 2 选择VLAN 002

>ip ad 192.168.1.254 255.255.255.0 ip address 192.168.1.254 255.255.255.0 为上述VLAN配置IP地址与子网掩码

>in vl 3 interface VLAN 3 选择VLAN 003

>ip ad 192.168.2.254 255.255.255.0 ip address 192.168.2.254 255.255.255.0 为上述VLAN配置IP地址与子网掩码

>in vl 6 interface VLAN 6 选择VLAN 006

>ip ad 192.168.5.1 255.255.255.0 ip address 192.168.5.1 255.255.255.0 为上述VLAN配置IP地址与子网掩码

>in r f0/1-2 interface range fastethernet0/1-2 批量选择端口f0/1与f0/2

>sw ac vl 2 switchport access VLAN 2 将上述端口加入VLAN 002

>in r f0/3-4 interface range fastethernet0/3-4 批量选择端口f0/3与f0/4

>sw ac vl 3 switchport access VLAN 3 将上述端口加入VLAN 003

>in f0/5 interface fastethernet0/5 选择端口f0/5

>sw ac vl 6 switchport access VLAN 6 将上述端口加入VLAN 006

>ip routi ip routing 启用交换机的路由功能

>ro rip router rip 启用RIP协议

>net 192.168.1.0 network 192.168.1.0 将网段加入协议

>net 192.168.2.0 network 192.168.2.0 将网段加入协议

>net 192.168.5.0 network 192.168.5.0 将网段加入协议

>in f0/5 interface fastethernet0/5 选择端口f0/5

>sw mo tr switchport mode trunk 为上述端口开启trunk模式

>sw tr en dot1q switchport trunk encapsulation dot1q 配置端口trunk模式以802.1q协议封装

>sw tr al vl 2,3,6 switchport trunk allowed VLAN 2,3,6 配置允许端口以trunk模式通过VLAN2,3,6

第二台三层交换机(靠右):

>en enable 开启特权模式

>conf t configure terminal 开启全局配置模式

>ho MLS2 hostname MLS2 命名主机为MLS2

>vl 4 VLAN 4 创建VLAN 004

>vl 5 VLAN 5 创建VLAN 005

>vl 6 VLAN 6 创建VLAN 006

>in vl 4 interface VLAN 4 选择VLAN 004

>ip ad 192.168.3.254 255.255.255.0 ip address 192.168.3.254 255.255.255.0 为上述VLAN配置IP地址与子网掩码

>in vl 5 interface VLAN 5 选择VLAN 005

>ip ad 192.168.4.254 255.255.255.0 ip address 192.168.4.254 255.255.255.0 为上述VLAN配置IP地址与子网掩码

>in vl 6 interface VLAN 6 选择VLAN 006

>ip ad 192.168.5.2 255.255.255.0 ip address 192.168.5.2 255.255.255.0 为上述VLAN配置IP地址与子网掩码

>in r f0/1-2 interface range fastethernet0/1-2 批量选择端口f0/1与f0/2

>sw ac vl 4 switchport access VLAN 4 将上述端口加入VLAN 004

>in r f0/3-4 interface range fastethernet0/3-4 批量选择端口f0/3与f0/4

>sw ac vl 5 switchport access VLAN 5 将上述端口加入VLAN 005

>in f0/5 interface fastethernet0/5 批量选择端口f0/5

>sw ac vl 6 switchport access VLAN 6 将上述端口加入VLAN 006

>ip routi ip routing 启用交换机的路由功能

>ro rip router rip 启用RIP协议

>net 192.168.3.0 network 192.168.3.0 将网段加入协议

>net 192.168.4.0 network 192.168.4.0 将网段加入协议

>net 192.168.5.0 network 192.168.5.0 将网段加入协议

>sw tr en dot1q switchport trunk encapsulation dot1q 配置端口trunk模式以802.1q协议封装

>sw tr al vl 4,5,6 switch trunk allowed VLAN 4,5,6 配置允许端口以trunk模式通过VLAN4,5,6

  • RIP协议配置实验代码详解:

ff9ec4fe1eee0bbffc49d15ad9b01f63.png
RIP协议配置实验拓扑图

第一台路由器(靠左):

>en enable 开启特权模式

>conf t congfigure terminal 开启全局配置模式

>in f0/0 interface fastethernet0/0 选择端口f0/0

>ip ad 192.168.1.1 255.255.255.0 ip address 192.168.1.1 255.255.255.0 为上述端口配置IP地址与子网掩码

>no sh no shut 命令端口保持开启

>in f0/1 interface fastethernet0/1 选择端口f0/1

>ip ad 10.0.0.1 255.0.0.0 ip address 10.0.0.1 255.0.0.0 为上述端口添加IP地址与子网掩码

>no sh no shut 命令端口保持开启

>ro rip router rip 启用RIP协议

>net 192.168.1.0 network 192.168.1.0 将网段加入协议

>net 10.0.0.0 network 10.0.0.0 将网段加入协议

第二台路由器(中间):

>en enable 开启特权模式

>conf t congfigure terminal 开启全局配置模式

>in f0/0 interface fastethernet0/0 选择端口f0/0

>ip ad 10.0.0.2 255.0.0.0 ip address 10.0.0.2 255.0.0.0 为上述端口配置IP地址与子网掩码

>no sh no shut 命令端口保持开启

>in f0/1 interface fastethernet0/1 选择端口f0/1

>ip ad 20.0.0.1 255.0.0.0 ip address 20.0.0.1 255.0.0.0 为上述端口添加IP地址与子网掩码

>no sh no shut 命令端口保持开启

>ro rip router rip 启用RIP协议

>net 10.0.0.0 network 10.0.0.0 将网段加入协议

>net 20.0.0.0 network 20.0.0.0 将网段加入协议

第三台路由器(靠右):

>en enable 开启特权模式

>conf t congfigure terminal 开启全局配置模式

>in f0/0 interface fastethernet0/0 选择端口f0/0

>ip ad 20.0.0.2 255.0.0.0 ip address 20.0.0.2 255.0.0.0 为上述端口配置IP地址与子网掩码

>no sh no shut 命令端口保持开启

>in f0/1 interface fastethernet0/1 选择端口f0/1

>ip ad 192.168.2.1 255.255.255.0 ip address 192.168.2.1 255.255.255.0 为上述端口添加IP地址与子网掩码

>no sh no shut 命令端口保持开启

>ro rip router rip 启用RIP协议

>net 20.0.0.0 network 20.0.0.0 将网段加入协议

>net 192.168.2.0 network 192.168.2.0 将网段加入协议

OSPF协议配置实验代码详解:

01b2a6b01225233428e033a512fd5911.png
OSPF协议配置实验拓扑图

第一台路由器(靠左):

>en enable 开启特权模式

>conf t congfigure terminal 开启全局配置模式

>in f0/0 interface fastethernet0/0 选择端口f0/0

>ip ad 192.168.1.1 255.255.255.0 ip address 192.168.1.1 255.255.255.0 为上述端口配置IP地址与子网掩码

>no sh no shut 命令端口保持开启

>in f0/1 interface fastethernet0/1 选择端口f0/1

>ip ad 192.168.2.1 255.255.255.0 ip address 192.168.2.1 255.255.255.0 为上述端口配置IP地址与子网掩码

>no sh no shut 命令端口保持开启

>ro ospf 100 router ospf 100 创建OSPF协议,进程号100

>net 192.168.1.0 255.255.255.0 area 1 network 192.168.1.0 255.255.255.0 area 1 将网段加入协议

>net 192.168.2.0 255.255.255.0 area 0 network 192.168.2.0 255.255.255.0 area 1 将网段加入协议

第二台路由器(中间):

>en enable 开启特权模式

>conf t congfigure terminal 开启全局配置模式

>in f0/0 interface fastethernet0/0 选择端口f0/0

>ip ad 192.168.2.2 255.255.255.0 ip address 192.168.2.2 255.255.255.0 为上述端口配置IP地址与子网掩码

>no sh no shut 命令端口保持开启

>in f0/1 interface fastethernet0/1 选择端口f0/1

>ip ad 192.168.3.1 255.255.255.0 ip address 192.168.3.1 255.255.255.0 为上述端口配置IP地址与子网掩码

>no sh no shut 命令端口保持开启

>ro ospf 100 router ospf 100 创建OSPF协议,进程号100

>net 192.168.2.0 255.255.255.0 area 1 network 192.168.2.0 255.255.255.0 area 1 将网段加入协议

>net 192.168.3.0 255.255.255.0 area 0 network 192.168.3.0 255.255.255.0 area 1 将网段加入协议

第三台路由器(靠右):

>en enable 开启特权模式

>conf t congfigure terminal 开启全局配置模式

>in f0/0 interface fastethernet0/0 选择端口f0/0

>ip ad 192.168.3.2 255.255.255.0 ip address 192.168.3.2 255.255.255.0 为上述端口配置IP地址与子网掩码

>no sh no shut 命令端口保持开启

>in f0/1 interface fastethernet0/1 选择端口f0/1

>ip ad 192.168.4.1 255.255.255.0 ip address 192.168.4.1 255.255.255.0 为上述端口配置IP地址与子网掩码

>no sh no shut 命令端口保持开启

>ro ospf 100 router ospf 100 创建OSPF协议,进程号100

>net 192.168.3.0 255.255.255.0 area 1 network 192.168.3.0 255.255.255.0 area 1 将网段加入协议

>net 192.168.4.0 255.255.255.0 area 0 network 192.168.4.0 255.255.255.0 area 1 将网段加入协议

默认路由与静态路由配置实验代码详解:

2fcad73e74ef008a44a0c3061b4c90da.png
默认路由与静态路由配置实验拓扑图

第一台路由器(靠左):

>en enable 开启特权模式

>conf t congfigure terminal 开启全局配置模式

>in f0/0 interface fastethernet0/0 选择端口f0/0

>ip ad 192.168.1.1 255.255.255.0 ip address 192.168.1.1 255.255.255.0 为上述端口配置IP地址与子网掩码

>no sh no shut 命令端口保持开启

>in f0/1 interface fastethernet0/1 选择端口f0/1

>ip ad 192.168.2.1 255.255.255.0 ip address 192.168.2.1 255.255.255.0 为上述端口配置IP地址与子网掩码

>no sh no shut 命令端口保持开启

>ip route 0.0.0.0 0.0.0.0 192.168.2.2 ip route 0.0.0.0 0.0.0.0 192.168.2.2 配置静态路由的目标IP地址、子网掩码与下一跳IP地址

第二台路由器(中间):

>en enable 开启特权模式

>conf t congfigure terminal 开启全局配置模式

>in f0/0 interface fastethernet0/0 选择端口f0/0

>ip ad 192.168.2.2 255.255.255.0 ip address 192.168.2.2 255.255.255.0 为上述端口配置IP地址与子网掩码

>no sh no shut 命令端口保持开启

>in f0/1 interface fastethernet0/1 选择端口f0/1

>ip ad 192.168.3.1 255.255.255.0 ip address 192.168.3.1 255.255.255.0 为上述端口配置IP地址与子网掩码

>no sh no shut 命令端口保持开启

>ip route 192.168.1.0 255.255.255.0 192.168.2.1 ip route 192.168.1.0 255.255.255.0 192.168.2.1 配置静态路由的目标IP地址、子网掩码与下一跳IP地址

>ip route 192.168.4.0 255.255.255.0 192.168.3.2 ip route 192.168.4.0 255.255.255.0 192.168.3.2 配置静态路由的目标IP地址、子网掩码与下一跳IP地址

第三台路由器(靠右):

>en enable 开启特权模式

>conf t congfigure terminal 开启全局配置模式

>in f0/0 interface fastethernet0/0 选择端口f0/0

>ip ad 192.168.3.2 255.255.255.0 ip address 192.168.3.2 255.255.255.0 为上述端口配置IP地址与子网掩码

>no sh no shut 命令端口保持开启

>in f0/1 interface fastethernet0/1 选择端口f0/1

>ip ad 192.168.4.1 255.255.255.0 ip address 192.168.4.1 255.255.255.0 为上述端口配置IP地址与子网掩码

>no sh no shut 命令端口保持开启

>ip route 0.0.0.0 0.0.0.0 192.168.3.1 ip route 0.0.0.0 0.0.0.0 192.168.3.1 配置静态路由的目标IP地址、子网掩码与下一跳IP地址

TRUNK模式配置实验代码详解:

5f96d747c976a2ea97bcb99f657c6072.png
TRUNK模式配置实验拓扑图

第一台交换机(靠左):

>en enable 开启特权模式

>conf t congfigure terminal 开启全局配置模式

>vl 2 VLAN 2 创建VLAN 002

>vl 3 VLAN 3 创建VLAN 003

>exit exit 退出VLAN配置模式

>in r f0/1-2 interface range fastethernet0/1-2 批量选择端口f0/1与f0/2

>sw ac vl 2 switchport access VLAN 2 将上述端口加入VLAN 002

>in r f0/3-4 interface range fastethernetf0/3-4 批量选择端口f0/3与f0/4

>sw ac vl 3 switchport access VLAN 3 将上述端口加入VLAN 003

>in f0/24 interface fastethernet0/24 选择端口f0/24

>sw mo tr switchport mode trunk 为上述端口开启trunk模式

  • 0
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值