思科交换机与路由器的小型局域网互通配置

打印 上一主题 下一主题

主题 859|帖子 859|积分 2577

此次实验通过配置一个小型局域网来梳理细节

实验拓扑:


 
实验目标:

1. 实现两个网段互通
2.配置交换机和路由器的用户密码和特权密码(都为123)
3.PC通过telnet和ssh实现远程控制(需要用交换机和路由器的本地账号)
4.10网段主机能够远程控制20网段的交换机
实验ip预定 :

PC0 10.1.1.1
PC1 10.1.1.2
PC2 20.1.1.1
sw0(左) 10.1.1.253
sw1 20.1.1.253
route 10.1.1.254 20.1.1.254
实验开始交换机用2960 路由器用2811
实现目标:两个网段互通

一.对路由器的操作
进入路由器的CLI界面手动进行配置
由于路由器的三层端口都是管理员手动关掉
  1. route> en
  2. route#conf t
  3. route(config)#int f0/0
  4. route(config-if)# no shutdown
  5. route(config-if)#int f0/1
  6. route(config-if)#no shut
  7. #成功开启路由器的两个三层接口
  8. #配置接口的ip
  9. route(config-if)# ip add 20.1.1.254 255.255.255.0
  10. route(config-if)#int f0/0
  11. route(config-if)#ip add 10.1.1.1254 255.255.255.0
  12. #ip配置完毕
复制代码
二.配置pc ip(这里先用静态)
  

 至此应该可以实现两个网段的互通了

 10.1.1.1ping 20.1.1.1 测试成功
实验目标 配置交换机和路由器的用户模式密码和特权模式密码

  解析:用户模式密码需要在line console 0口进行配置
  特权模式密码要在全局模式配置 tips:本地用户创建也是在全局模式设置
一. 对交换机的操作
进入sw0的CLI界面
  1. #配置用户模式登录密码<br>Switch>
  2. Switch>en
  3. Switch#conf t
  4. Enter configuration commands, one per line.  End with CNTL/Z.
  5. Switch(config)#line con
  6. Switch(config)#line console 1
  7. Switch(config)#line console 0
  8. Switch(config-line)#password 123
  9. Switch(config-line)#login
  10. Switch(config-line)#exit<br><br>#配置特权模式登录密码
复制代码
Switch(config)#enable password 123 #明文密码
Switch(config)#enable secret 123 #也可以用secret 如果用了secret则在running-config文件是加密密码
路由器也是一样的命令
实验目标 PC通过telnet和ssh实现远程控制(需要用交换机和路由器的本地账号)

  解析:
  1.要开启交换机和路由器的vlan口并配置一个ip让pc能连接 
  2.要开启交换机和路由器的本地账户
  3.ssh生成一对密钥
  4.开启虚拟端口
一 对交换机telnet操作
进入交换机的CLI界面
  1. 1 Switch(config)#line vty 0 4 #VTY是路由器的远程登陆的虚拟端口,0 4表示可以同时打开5个会话,line vty 0 4是进入VTY端口,对VTY端口进行配置
  2. 2 Switch(config-line)#transp
  3. 3 Switch(config-line)#transport inpu
  4. 4 Switch(config-line)#transport input ? #查看有什么远程登陆的方式 可以指定
  5. 5   all     All protocols
  6. 6   none    No protocols
  7. 7   ssh     TCP/IP SSH protocol
  8. 8   telnet  TCP/IP Telnet protocol
  9. 9 Switch(config-line)#transport input all
  10. 10 Switch(config-line)#login local  #配置是本地登录
  11. 11 Switch(config-line)#exit
  12. 12 Switch(config)#int vlan1      #配置vlan1的ip 这个接口的名字可以通过 do sh ip int b 来查看
  13. 13 Switch(config-if)#no sh <br>   Swithc(config-if)#ip add  10.1.1.253 255.255.255.0
  14. 14 Switch(config-if)#exit
  15. 15 Switch(config)#username lisenmiller password 123 #配置本地账户命令<br>
复制代码
用PC0telnet测试
  1. C:\>telnet 10.1.1.253
  2. Trying 10.1.1.253 ...Open
  3. User Access Verification
  4. Username: lisenmiller
  5. Password:
  6. Switch> #进入到交换机的命令配置页面 成功
复制代码
二.对路由器telnet的操作
  1. 1 Router(config)#
  2. 2 Router(config)#do sh ip int b
  3. 3 Interface              IP-Address      OK? Method Status                Protocol
  4. 4 FastEthernet0/0        10.1.1.254      YES manual up                    up
  5. 5 FastEthernet0/1        20.1.1.254      YES manual up                    up
  6. 6 Vlan1                  unassigned      YES unset  administratively down down
  7. 7 Router(config)#lin
  8. 8 Router(config)#line vty 0 4
  9. 9 Router(config-line)#login local
  10. 10 Router(config-line)#trans input all
  11. 11 Router(config-line)#exit
  12. 12 Router(config)#username lisenmiller password 123
复制代码
由于路由器已经有了两个ip 10.1.1.254 20.1.1.254都代表路由器 所以可以不用配置vlanip代表它
用pc0telnet测试
  1. C:\>telnet 20.1.1.254  tips:<strong>当用PC远程telnet 网关时,如果网关之前没有配置过特权模式的密码PC机也不能登录进去。所以只能通过配置网关的特权模式密码调整</strong>
  2. Trying 20.1.1.254 ...Open
  3. User Access Verification
  4. Username: lisenmiller
  5. Password:
  6. Router>  #进入到路由器的命令配置页面 成功
复制代码
三 ssh连接
  解析:
1.配置vlan口的ip
2.配置本地用户并且本地登录
3.配置hostname 和domain-name
4.生成密钥对
对交换机操作
  1. route(config)#host route
  2. route(config)#ip domain-name HackTB.com
  3. route(config)#crypto key generate rsa
  4. The name for the keys will be: route.HackTB.com
  5. Choose the size of the key modulus in the range of 360 to 2048 for your
  6.   General Purpose Keys. Choosing a key modulus greater than 512 may take
  7.   a few minutes.
  8. How many bits in the modulus [512]:
  9. % Generating 512 bit RSA keys, keys will be non-exportable...[OK]
  10. route(config)#
复制代码
PC测试 
  1. C:\>ssh -l lisenmiller 10.1.1.254  tips :注意这里的ssh格式是思科软件的 现实中的ssh登录应该是 ssh 用户名@ip
  2. Password:
  3. route> #成功
复制代码
路由器的操作相似
实验目标 10网段主机能够远程控制20网段的交换机

解析 需要为交换机配置默认网关:  目的:可被跨网段管理
在全局模式下配置
  1. Switch(config)#ip default-gateway 10.1.1.254
复制代码
PC2测试sw0 20.1.1.1 连接sw0
  1. C:\>ipconfig
  2. FastEthernet0 Connection:(default port)
  3.    Connection-specific DNS Suffix..:
  4.    Link-local IPv6 Address.........: FE80::2D0:58FF:FE05:41A0
  5.    IPv6 Address....................: ::
  6.    IPv4 Address....................: 20.1.1.1
  7.    Subnet Mask.....................: 255.255.255.0
  8.    Default Gateway.................: ::
  9.                                      20.1.1.254
  10. C:\>telnet 10.1.1.253
  11. Trying 10.1.1.253 ...Open
  12. User Access Verification
  13. Username: lisenmiller
  14. Password:
  15. Switch> #成功
复制代码
 

免责声明:如果侵犯了您的权益,请联系站长,我们会及时删除侵权内容,谢谢合作!

本帖子中包含更多资源

您需要 登录 才可以下载或查看,没有账号?立即注册

x
回复

使用道具 举报

0 个回复

倒序浏览

快速回复

您需要登录后才可以回帖 登录 or 立即注册

本版积分规则

耶耶耶耶耶

金牌会员
这个人很懒什么都没写!

标签云

快速回复 返回顶部 返回列表