首页 > 其他分享 >思科交换机与路由器的小型局域网互通配置

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

时间:2023-03-01 11:59:03浏览次数:32  
标签:ip route 局域网 Switch 交换机 line config 路由器

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

实验拓扑:

 

实验目标:

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界面手动进行配置

由于路由器的三层端口都是管理员手动关掉

route> en
route#conf t
route(config)#int f0/0
route(config-if)# no shutdown
route(config-if)#int f0/1
route(config-if)#no shut
#成功开启路由器的两个三层接口

#配置接口的ip
route(config-if)# ip add 20.1.1.254 255.255.255.0
route(config-if)#int f0/0
route(config-if)#ip add 10.1.1.1254 255.255.255.0
#ip配置完毕

二.配置pc ip(这里先用静态)

  

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

 10.1.1.1ping 20.1.1.1 测试成功

实验目标 配置交换机和路由器的用户模式密码和特权模式密码

  解析:用户模式密码需要在line console 0口进行配置

  特权模式密码要在全局模式配置 tips:本地用户创建也是在全局模式设置

一. 对交换机的操作

进入sw0的CLI界面

#配置用户模式登录密码
Switch> Switch>en Switch#conf t Enter configuration commands, one per line. End with CNTL/Z. Switch(config)#line con Switch(config)#line console 1 Switch(config)#line console 0 Switch(config-line)#password 123 Switch(config-line)#login Switch(config-line)#exit

#配置特权模式登录密码

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 Switch(config)#line vty 0 4 #VTY是路由器的远程登陆的虚拟端口,0 4表示可以同时打开5个会话,line vty 0 4是进入VTY端口,对VTY端口进行配置
 2 Switch(config-line)#transp
 3 Switch(config-line)#transport inpu
 4 Switch(config-line)#transport input ? #查看有什么远程登陆的方式 可以指定
 5   all     All protocols
 6   none    No protocols
 7   ssh     TCP/IP SSH protocol
 8   telnet  TCP/IP Telnet protocol
 9 Switch(config-line)#transport input all
10 Switch(config-line)#login local  #配置是本地登录
11 Switch(config-line)#exit
12 Switch(config)#int vlan1      #配置vlan1的ip 这个接口的名字可以通过 do sh ip int b 来查看
13 Switch(config-if)#no sh 
Swithc(config-if)#ip add 10.1.1.253 255.255.255.0 14 Switch(config-if)#exit 15 Switch(config)#username lisenmiller password 123 #配置本地账户命令

用PC0telnet测试

C:\>telnet 10.1.1.253
Trying 10.1.1.253 ...Open

User Access Verification

Username: lisenmiller
Password: 
Switch> #进入到交换机的命令配置页面 成功

二.对路由器telnet的操作

 1 Router(config)#
 2 Router(config)#do sh ip int b
 3 Interface              IP-Address      OK? Method Status                Protocol 
 4 FastEthernet0/0        10.1.1.254      YES manual up                    up 
 5 FastEthernet0/1        20.1.1.254      YES manual up                    up 
 6 Vlan1                  unassigned      YES unset  administratively down down
 7 Router(config)#lin
 8 Router(config)#line vty 0 4
 9 Router(config-line)#login local
10 Router(config-line)#trans input all
11 Router(config-line)#exit
12 Router(config)#username lisenmiller password 123 

由于路由器已经有了两个ip 10.1.1.254 20.1.1.254都代表路由器 所以可以不用配置vlanip代表它

用pc0telnet测试

C:\>telnet 20.1.1.254  tips:当用PC远程telnet 网关时,如果网关之前没有配置过特权模式的密码PC机也不能登录进去。所以只能通过配置网关的特权模式密码调整
Trying 20.1.1.254 ...Open

User Access Verification

Username: lisenmiller
Password: 
Router>  #进入到路由器的命令配置页面 成功

三 ssh连接

  解析:

1.配置vlan口的ip

2.配置本地用户并且本地登录

3.配置hostname 和domain-name

4.生成密钥对

对交换机操作

route(config)#host route
route(config)#ip domain-name HackTB.com
route(config)#crypto key generate rsa
The name for the keys will be: route.HackTB.com
Choose the size of the key modulus in the range of 360 to 2048 for your
  General Purpose Keys. Choosing a key modulus greater than 512 may take
  a few minutes.

How many bits in the modulus [512]: 
% Generating 512 bit RSA keys, keys will be non-exportable...[OK]

route(config)#

PC测试 

C:\>ssh -l lisenmiller 10.1.1.254  tips :注意这里的ssh格式是思科软件的 现实中的ssh登录应该是 ssh 用户名@ip

Password: 

route> #成功 

路由器的操作相似

实验目标 10网段主机能够远程控制20网段的交换机

解析 需要为交换机配置默认网关: 目的:可被跨网段管理

在全局模式下配置

Switch(config)#ip default-gateway 10.1.1.254

PC2测试sw0 20.1.1.1 连接sw0

C:\>ipconfig
FastEthernet0 Connection:(default port)

   Connection-specific DNS Suffix..: 
   Link-local IPv6 Address.........: FE80::2D0:58FF:FE05:41A0
   IPv6 Address....................: ::
   IPv4 Address....................: 20.1.1.1
   Subnet Mask.....................: 255.255.255.0
   Default Gateway.................: ::
                                     20.1.1.254
C:\>telnet 10.1.1.253
Trying 10.1.1.253 ...Open
User Access Verification

Username: lisenmiller
Password: 
Switch> #成功

 

标签:ip,route,局域网,Switch,交换机,line,config,路由器
From: https://www.cnblogs.com/lisenMiller/p/17167649.html

相关文章

  • 关于在接入交换机上配置静态路由
    近期,在一台二层的接入交换机上看到了一条缺省的静态路由:iproute0.0.0.00.0.0.0192.168.1.1已知,该接入交换机有一个管理接口,管理IP为192.168.1.10/24经实验发现,这条缺省......
  • 发现局域网中存活主机
    主机发现一个局域网中肯定是连接多台设备,那么我们如何确定哪些设备正在开机状态呢?方案一:使用ping命令进行循环探测,效率比较低:通过ICMP循环对整个网段中的每个IP地址......
  • 从Linux Bridge引发的网桥、交换机与路由器区别探究
    背景最近接触docker的网络配置方式,发现其默认会创建一个docker0的LinuxBridge,宿主机上运行的容器可以通过连接该birdge实现与外网的通信,根据bridge这个命名很自然的认为......
  • 交换机中IP表的生存周期及部分路由技术
    一.交换机中IP注册表的存在周期首先上理论:对于不同的环境,交换机都有不同的设定,就是注册表中的信息过期时间,虽然各自的时间不同,但是我们不可否认的就是这个机制它是存在的,......
  • wsl2 通过桥接网络实现被外部局域网主机直接访问
    wsl2通过桥接网络实现被外部局域网主机直接访问背景介绍之所以有这个需求的主要原因是需要用WSL和外部机器人硬件调试分布部署的ROS系统,WSL2是在windows主机内部建立的......
  • HHDESK局域网连接功能
    近年来,许多单位和部门根据实际需要都组建了局域网,这为日常事务处理带来了极大的便利。然而也有许多的局域网相互独立,未实现真正意义上的信息共享。因此,网络互联在这种环境......
  • python通过snmp获取交换机端口状态
    frompysnmp.entity.rfc3413.onelinerimportcmdgenclassNumberStatus:def__int__(self,host):self.host=hostdefwalk(self,dswitch,comm......
  • 华为交换机配置链路聚合(手工模式链路聚合和lacp模式聚合)UBUNTU 20.04 服务器配置多网
    一.华为交换机配置链路聚合(Eth-Trunk),是将多个物理接口捆绑为一个逻辑接口,实现增加链路带宽、提高可靠性、提供负载分担的目的。链路聚合两种模式:手工负载分担模式(默认模式,默......
  • 局域网实现PC、Pad、Android互联
    目录局域网实现PC、Pad、Android互联一、网络邻居1、Windows配置1.1开启共享功能1.2设置用户1.3共享文件夹2、Pad连接二、FTP&HTTP1、电脑配置1.1HTTP服务1.2......
  • PC怎样利用交换机进行信息交互
    一.IP地址及网络划分 我们这里有三台pc,分别是pc1,pc2,pc3,他们现在是不能互相交互的,很显然,默认状态下他们的IP地址都是属于C类,子网掩码也就是255,255,255,0;所以这三台电脑的......