飞道的博客

《网络安全笔记》第十五章:交换机的基本配置

356人阅读  评论(0)

一、思科设备的命令行基础

1、要想进入设备的命令行界面

  • 设备支持命令行界面
    • 去查看设备上的接口,是否有console口
  • 需要有console线
  • 需要超级终端软件进行连接
    • putty
    • secret CRT
    • xshell

2、命令行基础

  • 思科设备上的命令行模式

    • 用户模式:查看统计信息(一般情况下用得非常少),用“>“表示

      switch>
      
      • 用户模式切换到特权模式

        enable
        en					#命令可以简写
        
    • 特权模式:查看并修改设备的配置(一般情况下都是查看居多),用“#”表示

      • 特权模式切换到全局模式

        configure terminal
        conf t				#命令可以简写
        
    • 全局模式:针对设备的整体配置参数,用“(config)#表示

      • 全局模式切换到接口模式

        interface fastEthernet0/1
        int f0/1			#命令可以简写
        
    • 接口模式:针对设备的接口修改配置参数,用“(config-if)#“表示

      进入对应模式,只能一级一级进入

      返回对应模式,一级一级返回使用“exit”,如果说想要快速直接返回特权模式,可以使用“end”

    • 当命令输错后会进入

      exti
      Translating "exti"...domain server (255.255.255.255)
      #快速终止按ctrl+shift+6
      #永久不进行域名解析
      switch(config)#no ip domain-lookup		#注意模式
      

3、常见配置

  • 给交换机配置一个主机名

    Switch>en
    Switch#conf t
    Enter configuration commands, one per line.  End with CNTL/Z.
    Switch(config)#hostname SW1
    SW1(config)#
    SW1#
    %SYS-5-CONFIG_I: Configured from console by console
    
  • 如何查看交换机里的MAC表

    SW1(config)#
    SW1#
    %SYS-5-CONFIG_I: Configured from console by console
    
  • 交换机的双工模式

    SW1#conf t
    SW1(config)#int f0/1
    SW1(config-if)#duplex half	#半双工
    SW1#show int f0/1
    
  • 交换机的接口速率

    SW1#conf t
    SW1(config)#int f0/2
    SW1(config-if)#speed 10
    SW1#show int f0/2
    
  • 配置console口的密码

    SW1#conf t
    SW1(config)#line console 0
    SW1(config-line)#password 123
    SW1(config-line)#login
    

二、通过远程管理方式连接交换机(telnet、ssh

1、telnet是应用层协议,基于传输层TCP,默认端口号:23,采用的是明文密码方式,不是太安全,一般用于内网管理

2、SSH是应用层协议,基于传输层TCP,默认端口号22,采用的是密文密码方式,相对来讲比较安全,经常用于跨越互联网管理,也常用于远程管理Linux操作系统

3、思路

(1)telnet

  • 既然是通过网络的方式管理设备,设备就必须配置IP地址,由于交换机上的接口都是交换接口,是不允许配置IP地址,直接为交换机的虚接口配置IP地址,默认情况下交换机的默认虚接口就是 vlan1 接口

    Switch>en
    Switch#conf t
    Switch(config)#hostname sw1
    sw1(config)#int vlan 1		#进入vlan 1
    sw1(config-if)#ip address 192.168.1.1 255.255.255.0		#配置设备IP和子网掩码
    sw1(config-if)#no shutdown		#开启接口
    
  • 配置设备的连接终端并直接设置密码,应用

    sw1#conf t
    sw1(config)#line vty 0 4
    sw1(config-line)#password 123
    sw1(config-line)#login			//直接使用密码登录
    
  • 创建连接用户名密码,配置设备的连接终端并应用

    sw1#conf t
    sw1(config)#username zhangsan password 789
    sw1(config)#line vty 0 4
    sw1(config-line)#login local		//表示使用用户名密码登录
    

(2)SSH

Switch(config)#hostname SW1				//创建主机名,因为创建域名的时候不允许默认的主机名
SW1(config)#ip domain-name woniu.com	//创建域名
SW1(config)#crypto key generate rsa		//创建密钥对
创建密钥返回值:
The name for the keys will be: SW1.woniu.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]: 2048			//2048是密钥长度
% Generating 2048 bit RSA keys, keys will be non-exportable...[OK]

SW1(config)#ip ssh time-out 120						//配置超时时间
SW1(config)#ip ssh authentication-retries 5			//配置认证失败的次数
SW1(config)#username lisi password 456				//创建用户名密码
SW1(config)#line vty 0 4							//进入Line 模式对vty 0~4线路进行配置
SW1(config-line)#login local						//需要用户名密码
SW1(config)#enable secret 999						//设置特权模式密码

 

4、设置特权模式密码(当同时设置了明文和密文密码,密文密码生效)

sw1(config)#enable password 123		//设置明文密码
sw1(config)#enable secret 456		//设置密文密码
sw1#show running-config				//查看当前配置文件命令
enable secret 5 $1$mERr$DqFv/bNKU3CFm5jwSLasx/		//查看当前配置命令后显示的密文密码,其中5代表MD5
enable password 123									//查看当前配置命令后显示的明文密码

转载:https://blog.csdn.net/weixin_45239751/article/details/127770409
查看评论
* 以上用户言论只代表其个人观点,不代表本网站的观点或立场