思科模拟器 - 交换机常用技术配置

admin 2022年6月14日08:38:48评论356 views字数 8704阅读29分0秒阅读模式

补坑,很早以前写的笔记,本篇文章还同步在:rce.iloli.moe

markdown已上传到Github仓库,欢迎fork

https://github.com/icecliffs/ciscn0note

注:如有错误内容(e.g: 配置错误,命令错误,思路错误)

可以电邮我,我改改,或提 issue(


链路聚合技术

技术原理

链路聚合又称为(端口汇聚),是指两台交换机之间在物理上将两个或多个端口连接起来,将多条链路聚合成一条逻辑链路。从而增大链路带宽,解决交换网络中因带宽引起的网络瓶颈问题。多条物理链路之间能够相互冗余备份,其中任意一条链路断开,不会影响其他链路的正常转发数据。

本实验使用的是二层交换机实现链路聚合功能,在二层交换机互联时要用交叉线进行互联。当我们连接好设备时会发现,交换机互联的两条链路中,有一条是的链路标志是为黄色的,表示该链路处于关闭状态,此时两台交换机之间并没有实现链路聚合功能。

拓扑图

思科模拟器 - 交换机常用技术配置

说明

如图配置

交换机配置

  • 交换机 Switch0 改名为 S0

  • 交换机 Switch1 改名为 S1

  • 创建vlan10并改名为vlan0010

  • 配置端口聚合

PC端配置

  • PC0 IP配置 192.168.10.1

  • PC1 IP配置 192.168.10.2

  • PC0和PC1分别加入vlan10

配置命令

S0配置

S0>en
S0#conf
S0(config)#hostname S0 # 修改交换机名字
S0(config)#vlan 10
S0(config-vlan)#name vlan0010 # 修改 vlan 名字
S0(config-vlan)#int fa0/1
S0(config-if)#sw ac vlan 10 # 将 fa0/1 接口加入到 vlan 10
S0(config-if)#end
S0#
S0#sh vlan id 10
VLAN Name Status Ports
---- -------------------------------- --------- -------------------------------
10 vlan0010 active Fa0/1
VLAN Type SAID MTU Parent RingNo BridgeNo Stp BrdgMode Trans1 Trans2
---- ----- ---------- ----- ------ ------ -------- ---- -------- ------ ------
10 enet 100010 1500 - - - - - 0 0
S0#

端口聚合配置

S0(config)#int port-channel 1 # 创建聚合组1
S0(config-if)#sw mo tr # 模式配置成 trunk
S0(config-if)#exit
S0(config)#int range fa0/23-24 # 进入接口23和24
S0(config-if-range)#channel-group 1 mode on # 开启链路聚合
S0(config-if-range)#
S0(config-if-range)#end
S0#sh et summary # 查看聚合组1消息
Flags: D - down P - in port-channel
I - stand-alone s - suspended
H - Hot-standby (LACP only)
R - Layer3 S - Layer2
U - in use f - failed to allocate aggregator
u - unsuitable for bundling
w - waiting to be aggregated
d - default port
Number of channel-groups in use: 1
Number of aggregators: 1
Group Port-channel Protocol Ports
------+-------------+-----------+----------------------------------------------
1 Po1(SU) - Fa0/23(P) Fa0/24(P)
S0#sh et summary
Flags: D - down P - in port-channel
I - stand-alone s - suspended
H - Hot-standby (LACP only)
R - Layer3 S - Layer2
U - in use f - failed to allocate aggregator
u - unsuitable for bundling
w - waiting to be aggregated
d - default port
Number of channel-groups in use: 1
Number of aggregators: 1
Group Port-channel Protocol Ports
------+-------------+-----------+----------------------------------------------
1 Po1(SU) - Fa0/23(P) Fa0/24(P)
S0#

S1配置

步骤和S0一样

实验测试

PC0能ping通PC1说明实验成功

思科模拟器 - 交换机常用技术配置

VTP技术

技术原理

VTP(Vlan Trunk Protocol的简称)即Vlan的中继协议。VTP是通过网络保持VLAN配置统一性。VTP实现了系统化管理,方便管理员增加、删除和调整的VLAN的操作,实现自动地将Vlan配置信息向网络中其它的交换机广播。此外,VTP还减小了那些可能导致安全问题的配置。便于管理,只要在VTP服务器做相应设置,VTP客户端会自动学习VTP服务器上的Vlan信息。

拓扑图

思科模拟器 - 交换机常用技术配置

说明

设置核心层交换机VTPSERVER为VTP服务器,并创建Vlan10和Vlan20。设置接入层交换机VTPCLIENT0和VTPCLIENT1为VTP客户机,使它们实现Vlan的中继,自动创建与VTP服务器相同的Vlan规划。配置交换机互联端口为Trunk类型,以及规划交换机VTPCLIENT0和交换机VTPCLIENT1的Vlan的端口分配,最终实现全网互通。

交换机配置

  • 交换机 Multiply Switch0 改名为 VTPSERVER

  • 交换机 Switch0和Switch1 改名为 VTPCLIENT0和VTPCLIENT1

  • 创建vlan10并改名为vlan0010

  • 创建vlan20并改名为vlan0020

  • 分别在上图所示的交换机中配置VTP技术

PC端配置

  • PC0 IP配置 192.168.10.1 网关 192.168.10.100

  • PC1 IP配置 192.168.10.2 网关 192.168.20.100

  • PC0加入vlan10,和PC1加入vlan20

配置命令

VTPSERVER配置

Switch>en
Switch#conf
Switch(config)#hostname VTPSERVER
VTPSERVER(config)#vtp domain vtpconf # VTP域名要跟服务器上的一致
Changing VTP domain name from NULL to vtpconf
VTPSERVER(config)#vtp mode server
Device mode already VTP SERVER.
VTPSERVER(config)#ip routing
VTPSERVER(config)#vlan 10
VTPSERVER(config-vlan)#name vlan0010
VTPSERVER(config-vlan)#vlan 20
VTPSERVER(config-vlan)#name vlan0020
VTPSERVER(config-vlan)#int vlan 10
VTPSERVER(config-if)#ip add 192.168.10.100 255.255.255.0
VTPSERVER(config-if)#int vlan 20
VTPSERVER(config-if)#ip add 192.168.20.100 255.255.255.0
VTPSERVER(config)#int range fa0/1-2
VTPSERVER(config-if-range)#sw mo tr
VTPSERVER(config-if-range)#sw tr allow vlan all

VTPCLIENT0配置

Switch>en
Switch#conf
Switch(config)#hostname VTPCLIENT0
VTPCLIENT0(config)#vtp domain vtpconf # VTP域名要跟服务器上的一致
Changing VTP domain name from NULL to vtpconf
VTPCLIENT0(config)#vtp mode client
Setting device to VTP CLIENT mode.
VTPCLIENT0(config)#
VTPCLIENT0(config)#
VTPCLIENT0(config)#int fa0/24
VTPCLIENT0(config-if)#sw mo tr
VTPCLIENT0(config-if)#sw tr allow vlan all
VTPCLIENT0(config-if)#int fa0/1
VTPCLIENT0(config-if)#sw ac vlan 10

VTPCLIENT1配置

Switch>en
Switch#conf
Switch(config)#hostname VTPCLIENT1
VTPCLIENT1(config)#vtp domain vtpconf # VTP域名要跟服务器上的一致
Changing VTP domain name from NULL to vtpconf
VTPCLIENT1(config)#vtp mode client # 客户模式
Setting device to VTP CLIENT mode.
VTPCLIENT1(config)#int fa0/24
VTPCLIENT1(config)#sw mo tr
VTPCLIENT1(config-if)#sw tr allow vlan all
VTPCLIENT0(config-if)#int fa0/1
VTPCLIENT0(config-if)#sw ac vlan 20

实验测试

PC0 ping通PC1(不同网段)相反PC1也要能ping PC0

思科模拟器 - 交换机常用技术配置

生成树技术

技术原理

在两个交换机上配置生成树协议,实现Vlan的负载均衡,使得Vlan10的计算机通信时走Fa0/23的链路,Vlan20的计算机通信时走Fa0/24的链路,交换机配置生成树协议,可以为互联网络中提供多条冗余备份链路,并解决互联网络中的环路问题。默认情况下,两个交换机间的多条冗余链路仅有一条是处于工作状态,其他链路都处于关闭状态,只有当其他链路出现故障或断开的情况下才会启用。但如果设置了生成树的Vlan负载均衡技术,则可以实现多条链路同时工作,这在一定程度上实现了网络带宽的拓容,从而提升网络的速度。

拓扑图

思科模拟器 - 交换机常用技术配置

自己看图配置哈

配置命令

S0

Switch>
Switch>en
Switch#conf
Switch(config)#hostname S0
S0(config)#vlan 10
S0(config-vlan)#vlan 20
S0(config-vlan)#int fa0/1
S0(config-if)#sw ac vlan 10
S0(config-if)#int fa0/2
S0(config-if)#sw ac vlan 20
S0(config)#spanning-tree vlan 1
S0(config)#spanning-tree vlan 10
S0(config)#spanning-tree vlan 20

S1

Switch>en
Switch#conf
Switch(config)#int fa0/2
Switch(config-if)#sw ac vlan 10
Switch(config-if)#int fa0/1
Switch(config-if)#sw ac vlan 20
S0(config)#spanning-tree vlan 1
S0(config)#spanning-tree vlan 10
S0(config)#spanning-tree vlan 20
Switch(config)#int fa0/23
Switch(config-if)#sw mo tr
Switch(config-if)#sw tr allow vlan 10
Switch(config-if)#int fa0/24
Switch(config-if)#sw mo tr
Switch(config-if)#sw tr allow vlan 20

实验测试

相同vlan ping通即可

思科模拟器 - 交换机常用技术配置

DHCP服务

拓扑图

思科模拟器 - 交换机常用技术配置

如图配置

[alert]客户机需全部调成DHCP自动获取IP地址[/alert]

配置命令

三层

Switch(config)#ip routing
Switch(config)#int vlan 10
Switch(config-if)#ip address 192.168.10.100 255.255.255.0
Switch(config-if)#int vlan 20
Switch(config-if)#ip address 192.168.20.100 255.255.255.0
Switch(config-if)#int vlan 30
Switch(config-if)#ip address 192.168.30.100 255.255.255.0
Switch(config-if)#int vlan 40
Switch(config-if)#ip address 192.168.40.100 255.255.255.0
Switch(config-if)#exit
Switch(config)#ip dhcp pool vlan10
Switch(dhcp-config)#network 192.168.10.0 255.255.255.0
Switch(dhcp-config)#dns-server 114.114.114.114
Switch(dhcp-config)#default-router 192.168.10.100
Switch(config)#ip dhcp pool vlan20
Switch(dhcp-config)#network 192.168.20.0 255.255.255.0
Switch(dhcp-config)#dns-server 114.114.114.114
Switch(dhcp-config)#default-router 192.168.20.100
Switch(config)#ip dhcp pool vlan30
Switch(dhcp-config)#network 192.168.30.0 255.255.255.0
Switch(dhcp-config)#dns-server 114.114.114.114
Switch(dhcp-config)#default-router 192.168.30.100
Switch(config)#ip dhcp pool vlan40
Switch(dhcp-config)#network 192.168.40.0 255.255.255.0
Switch(dhcp-config)#dns-server 114.114.114.114
Switch(dhcp-config)#default-router 192.168.40.100
Switch(config)#ip dhcp excluded-address 192.168.10.233 192.168.10.254 # 保留IP地址范围
Switch(config)#int fa0/1
Switch(config-if)#sw ac vlan 30
Switch(config-if)#int fa0/2
Switch(config-if)#sw ac vlan 40
Switch(config-if)#int fa0/4
Switch(config-if)#sw ac vlan 10
Switch(config-if)#int fa0/3
Switch(config-if)#sw ac vlan 20
Switch(config)#int fa0/10
Switch(config-if)#sw ac vlan 30
Switch(config-if)#int fa0/11
Switch(config-if)#sw ac vlan 40
Switch(config-if)#int fa0/12
Switch(config-if)#sw ac vlan 10
Switch(config-if)#int fa0/13
Switch(config-if)#sw ac vlan 20

二层1

Switch(config)#vlan 10
Switch(config-vlan)#vlan 20
Switch(config-vlan)#vlan 30
Switch(config-vlan)#vlan 40
Switch(config-if)#int fa0/2
Switch(config-if)#sw ac vlan 40
Switch(config-if)#int fa0/1
Switch(config-if)#sw ac vlan 30
Switch(config-if)#int fa0/3
Switch(config-if)#sw ac vlan 20
Switch(config-if)#int fa0/4
Switch(config-if)#sw ac vlan 10
Switch(config-if)#sw mo tr

二层2

Switch(config)#int fa0/24
Switch(config-if)#sw mo tr
Switch(config-if)#int fa0/10
Switch(config-if)#sw ac vlan 10
Switch(config-if)#int fa0/11
Switch(config-if)#sw ac vlan 20
Switch(config-if)#int fa0/13
Switch(config-if)#sw ac vlan 30
Switch(config-if)#int fa0/12
Switch(config-if)#sw ac vlan 40

实验测试

能正确获取到IP地址即可

思科模拟器 - 交换机常用技术配置

Telnet服务

拓扑图

思科模拟器 - 交换机常用技术配置

不要求全网互通(你想做也可以),PC0和PC1能分别登录到R0和S0即可(无用户)

配置命令

R0

Router>en
Router#conf
Router(config)#int fa0/0
Router(config-if)#no shutdown
Router(config-if)#ip address 192.168.1.2 255.255.255.0
Router(config)#username oyang password pass.123
Router(config)#line vty 0 4
Router(config-line)#password abcdef
Router(config-line)#login
Router(config-line)#exit
Router(config)#enable secret abcdef
# enable se..加密密文,在sh ru中不会输出明文
# enable secret 5 $1$mERr$OAZJyntnash.EflFFzcMJ1

S0

Switch>en
Switch#conf
Switch(config)#int vlan 1
Switch(config-if)#ip address 192.168.0.2 255.255.255.0
Switch(config-if)#no shutdown
Switch(config-if)#exit
Switch(config)#enable password 123456
Switch(config)#line vty 0 4
Switch(config-line)#password abcdef # telnet密码abcdef
Switch(config-line)#login local # 开启本地远程登陆
Switch(config-line)#privilege level 3 # 配置远程登录用户的权限为最高级别权限3
Switch(config)#service password-encryption # 设置密码为密文存储

用户名密码模式

Switch>
Switch>en
Switch#conf
Switch(config)#enable password 123 # 配置特权密码
Switch(config)#int vlan 1
Switch(config-if)#ip add 192.168.1.1 255.255.255.0
Switch(config-if)#no shutdown
Switch(config-if)#exit
Switch(config)#username oyang password pass.123 # 配置telnet用户名密码
Switch(config)#line vty 0 4
Switch(config-line)#login local
Switch(config-line)#transport input telnet # 流量输出?
Switch(config-line)#exit
Switch(config)#line console 0 # 配置控制台密码
Switch(config-line)#password 123456
Switch(config-line)#login
Switch(config-line)#end

实验测试

PC0和PC1能分别登录到R0和S0

PC0登录S0

思科模拟器 - 交换机常用技术配置

用户名密码登录

思科模拟器 - 交换机常用技术配置


原文始发于微信公众号(Gh0xE9):思科模拟器 - 交换机常用技术配置

  • 左青龙
  • 微信扫一扫
  • weinxin
  • 右白虎
  • 微信扫一扫
  • weinxin
admin
  • 本文由 发表于 2022年6月14日08:38:48
  • 转载请保留本文链接(CN-SEC中文网:感谢原作者辛苦付出):
                   思科模拟器 - 交换机常用技术配置http://cn-sec.com/archives/1111002.html

发表评论

匿名网友 填写信息