• 产品与解决方案
  • 行业解决方案
  • 服务
  • 支持
  • 合作伙伴
  • 新华三人才研学中心
  • 关于我们

H3C 园区盒式交换机典型配置举例-6W100

目录

01-登录设备典型配置举例

本章节下载 01-登录设备典型配置举例  (452.49 KB)

docurl=/cn/Service/Document_Software/Document_Center/Home/Switches/00-Public/Configure/Typical_Configuration_Example/H3C_CE-B70D022-6W100/202012/1371426_30005_0.htm

01-登录设备典型配置举例


1  简介

本文档介绍了登录设备的典型配置案例,以及如何通过命令行授权和计费对登录的用户进行控制。

2  配置前提

本文档中的配置均是在实验室环境下进行的配置和验证,配置前设备的所有参数均采用出厂时的缺省配置。如果您已经对设备进行了配置,为了保证配置效果,请确认现有配置和以下举例中的配置不冲突。

本文档假设您已了解登录设备的特性。

3  通过Console口登录设备配置举例

3.1  组网需求

主机通过配置电缆与设备的Console口连接。现要求:用户通过设备的Console口登录到设备,对设备进行管理和配置,并且配置本地认证方式为AAA认证,以提高设备的安全性。

3.2  配置思路

·            通过Console口登录设备,需要使用户终端的通信参数配置和交换机Console口的缺省配置保持一致。

·            当通过Console口采用本地认证方式登录时,由于本地用户缺省的授权用户角色为network-operator,且本地是无服务类型的。因此,需要设置本地用户的服务类型为terminal(通过Console口登录使用的是terminal服务类型),授权用户角色为network-admin,才能使用户下次成功登录并在登录后对设备进行管理和配置。

3.3  适用产品及版本

表1 适用产品及版本

产品

软件版本

S5560X-EI系列

Release 63xx系列

S5560X-HI系列

Release 63xx系列

S5500V2-EI系列

Release 63xx系列

MS4520V2-30F

Release 63xx系列

S6520X-HI系列

S6520X-EI系列

Release 63xx系列

S6520X-SI系列

S6520-SI系列

Release 63xx系列

S5000-EI系列

Release 63xx系列

MS4600系列

Release 63xx系列

S5560S-EI系列

S5560S-SI系列

Release 63xx系列

S5130S-HI系列

S5130S-EI系列

S5130S-SI系列

S5130S-LI系列

Release 63xx系列

S5120V2-SI系列

S5120V2-LI系列

Release 63xx系列

S3100V3-EI系列

S3100V3-SI系列

Release 63xx系列

S5110V2系列

Release 63xx系列

S5110V2-SI系列

Release 63xx系列

S5000V3-EI系列

Release 63xx系列

S5000E-X系列

Release 63xx系列

E128C

E152C

E500C系列

E500D系列

Release 63xx系列

MS4520V2系列(除MS4520V2-30F)

Release 63xx系列

MS4320V2系列

MS4300V2系列

MS4320系列

MS4200系列

Release 63xx系列

WS5850-WiNet系列

Release 63xx系列

WS5820-WiNet系列

WS5810-WiNet系列

Release 63xx系列

WAS6000系列

Release 63xx系列

 

3.4  配置注意事项

连接时请认准接口上“Console”的标识,以免误插入其它接口。

3.5  配置步骤

(1)       主机断电。因为PC机串口不支持热插拔,请不要在PC带电的情况下,将配置电缆插入或者拔出PC机。

(2)       请使用产品随机附带的配置电缆连接PC机和设备。请先将配置口电缆的DB-9(孔)插头插入PC机的9芯(针)串口中,再将RJ-45插头端插入设备的Console口中。

图1 将设备与PC通过配置口电缆进行连接

 

(3)       将PC上电。

(4)       在通过Console口搭建本地配置环境时,需要通过超级终端或PuTTY等终端仿真程序与设备建立连接。用户可以运行这些程序来连接网络设备、Telnet或SSH站点,这些程序的详细介绍和使用方法请参见该程序的使用指导。打开终端仿真程序后,请按如下要求设置终端参数:

·            波特率:9600

·            数据位:8

·            停止位:1

·            奇偶校验:无

·            流量控制:无

设备上电,终端上显示设备自检信息,自检结束后提示用户键入回车,出现命令行提示符即可键入命令来配置设备或查看设备运行状态,需要帮助可以随时键入“?”。

(5)       进入AUX用户线视图,并进行后续配置:

# 进入AUX用户线视图。

<Sysname> system-view

[Sysname] line aux 0

# 设置通过Console口登录交换机的用户进行AAA认证。

[Sysname-line-aux0] authentication-mode scheme

# 退出到系统视图,创建本地用户admin,并进入本地用户视图。

[Sysname-line-aux0] quit

[Sysname] local-user admin class manage

New local user added.

# 设置本地用户的认证口令为明文方式,口令为123。

[Sysname-luser-manage-admin] password simple 123

# 设置本地用户的服务类型为Terminal,授权用户角色为network-admin,删除默认角色。

[Sysname-luser-manage-admin] service-type terminal

[Sysname-luser-manage-admin] authorization-attribute user-role network-admin

[Sysname-luser-manage-admin] undo authorization-attribute user-role network-operator

[Sysname-luser-manage-admin] quit

3.6  验证配置

配置完成后,当用户再次通过Console口登录设备时,会出现如下界面。用户输入用户名“admin”和密码“123”成功登录设备后,登录界面中将出现命令行提示符。

Line aux0 is available.

 

 

Press ENTER to get started.

Login: admin

Password:

******************************************************************************

* Copyright (c) 2004-2019 New H3C Technologies Co., Ltd. All rights reserved.*

* Without the owner's prior written consent,                                 *

* no decompiling or reverse-engineering shall be allowed.                    *

******************************************************************************

 

<Sysname>

3.7  配置文件

#

line aux 0

 authentication-mode scheme

 user-role network-admin

#

local-user admin class manage

 password hash $h$6$RgG+mm4RKXICN1tY$ld6pV+qB2a/BBFXVnqocFJjYgx/EKCYod9tHmGRP8AA

1qnbeRcB6Bd4jW+cteG9aY2Gc+J8JqLHsWwvtnLyEAw==

 service-type terminal

 authorization-attribute user-role network-admin

#

4  基于用户角色的Telnet登录设备配置举例

4.1  组网需求

图2所示,要求仅允许使用IP地址为192.168.0.46/24和192.168.0.52/24的主机以Telnet方式登录设备,且在登录时必须进行基于用户名和密码的身份验证。这两个主机在相同的认证方式下使用两个不同的用户名登录设备时,具有两种不同的权限,分别为管理权限和可执行所有特性中读类型的命令权限。

图2 通过Telnet登录交换机组网图

 

4.2  配置思路

·           缺省情况下,设备的Telnet服务器处于关闭状态,需要通过Console口登录后开启设备的Telnet服务功能。

·           可以通过ACL来限制IP地址为192.168.0.58的主机不能以Telnet方式登录设备。

·           缺省情况下,本地用户的角色为network-operator。因此,对于用户权限仅为允许执行所有特性中读类型的命令,需要重新创建一个具有此权限的角色。

4.3  适用产品及版本

表2 适用产品及版本

产品

软件版本

S5560X-EI系列

Release 63xx系列

S5560X-HI系列

Release 63xx系列

S5500V2-EI系列

Release 63xx系列

MS4520V2-30F

Release 63xx系列

S6520X-HI系列

S6520X-EI系列

Release 63xx系列

S6520X-SI系列

S6520-SI系列

Release 63xx系列

S5000-EI系列

Release 63xx系列

MS4600系列

Release 63xx系列

S5560S-EI系列

S5560S-SI系列

Release 63xx系列

S5130S-HI系列

S5130S-EI系列

S5130S-SI系列

S5130S-LI系列

Release 63xx系列

S5120V2-SI系列

S5120V2-LI系列

Release 63xx系列

S3100V3-EI系列

S3100V3-SI系列

Release 63xx系列

S5110V2系列

Release 63xx系列

S5110V2-SI系列

Release 63xx系列

S5000V3-EI系列

Release 63xx系列

S5000E-X系列

Release 63xx系列

E128C

E152C

E500C系列

E500D系列

Release 63xx系列

MS4520V2系列(除MS4520V2-30F)

Release 63xx系列

MS4320V2系列

MS4300V2系列

MS4320系列

MS4200系列

Release 63xx系列

WS5850-WiNet系列

Release 63xx系列

WS5820-WiNet系列

WS5810-WiNet系列

Release 63xx系列

WAS6000系列

Release 63xx系列

 

4.4  配置步骤

# 通过Console口登录设备,进入系统视图,开启Telnet服务。

<Sysname> system-view

[Sysname] telnet server enable

# 设置通过VTY用户线登录交换机使用AAA的认证方式。

[Sysname] line vty 0 63

[Sysname-line-vty0-63] authentication-mode scheme

[Sysname-line-vty0-63] quit

# 创建本地用户userA,授权其用户角色为network-admin,为其配置密码,删除默认角色。

[Sysname] local-user userA class manage

New local user added.

[Sysname-luser-manage-userA] authorization-attribute user-role network-admin

[Sysname-luser-manage-userA] service-type telnet

[Sysname-luser-manage-userA] password simple 123

[Sysname-luser-manage-userA] undo authorization-attribute user-role network-operator

[Sysname-luser-manage-userA] quit

# 创建用户角色roleB,权限为允许执行所有特性中读类型的命令。

[Sysname] role name roleB

[Sysname-role-roleB] rule 1 permit read feature

[Sysname-role-roleB] quit

# 创建本地用户userB,为其配置密码,授权其用户角色为roleB,删除默认角色。

[Sysname] local-user userB class manage

New local user added.

[Sysname-luser-manage-userB] authorization-attribute user-role roleB

[Sysname-luser-manage-userB] service-type telnet

[Sysname-luser-manage-userB] password simple 123

[Sysname-luser-manage-userB] undo authorization-attribute user-role network-operator

[Sysname-luser-manage-userB] quit

# 创建ACL视图,定义规则,仅允许来自192.168.0.46和192.168.0.52的用户访问交换机。

[Sysname] acl basic 2000

[Sysname-acl-ipv4-basic-2000] rule 1 permit source 192.168.0.46 0

[Sysname-acl-ipv4-basic-2000] rule 2 permit source 192.168.0.52 0

[Sysname-acl-ipv4-basic-2000] rule 3 deny source any

[Sysname-acl-ipv4-basic-2000] quit

# 引用访问控制列表2000,通过源IP对Telnet用户进行控制。

[Sysname] telnet server acl 2000

4.5  验证配置

配置完成后,各用户的权限为:

·            当用户使用userA作为用户名以Telnet方式登录设备时,会出现如下界面。用户输入用户名“userA”和密码“123”后能够成功登录到设备上,具有对设备进行管理和配置的权限。

Login: userA

Password:

******************************************************************************

* Copyright (c) 2004-2019 New H3C Technologies Co., Ltd. All rights reserved.*

* Without the owner's prior written consent,                                 *

* no decompiling or reverse-engineering shall be allowed.                    *

******************************************************************************

 

<Sysname> ?

User view commands:

  archive             Archive configuration

  arp                 Address Resolution Protocol (ARP) module

  backup              Backup operation

  boot-loader         Software image file management

  bootrom             Update/read/backup/restore bootrom

  cd                  Change current directory

  cfd                 Connectivity Fault Detection (CFD) module

  clock               Specify the system clock

  copy                Copy a file

  create              Create a file

  debugging           Enable system debugging functions

  delete              Delete a file

  diagnostic-logfile  Diagnostic log file configuration

  dir                 Display files and directories on the storage media

  display             Display current system information

  erase               Alias for 'delete'

  exception           Exception information configuration

  exit                Alias for 'quit'

  fdisk               Partition a storage medium

  fixdisk             Check and repair a storage medium

  format              Format a storage medium

  free                Release a connection

  ftp                 Open an FTP connection

---- More ----

·           当用户使用userB作为用户名以Telnet方式登录到设备上时,会出现如下界面,要求输入用户名和密码,输入用户名和密码123后能够成功登录到设备上,只允许该用户执行所有特性中读类型的命令。

Login: userB

Password:

******************************************************************************

* Copyright (c) 2004-2019 New H3C Technologies Co., Ltd. All rights reserved.*

* Without the owner's prior written consent,                                 *

* no decompiling or reverse-engineering shall be allowed.                    *

******************************************************************************

 

<Sysname> ?

User view commands:

  dir          Display files and directories on the storage media

  display      Display current system information

  erase        Alias for 'delete'

  exit         Alias for 'quit'

  md5sum       Compute the hash digest of a file using the MD5 algorithm

  more         Display the contents of a file

  no           Alias for 'undo'

  pwd          Display current working directory

  quit         Exit from current command view

  sha256sum    Compute the hash digest of a file using the SHA256 algorithm

  show         Alias for 'display'

  system-view  Enter the System View

  write        Alias for 'save'

 

<Sysname>

·           Host C无法通过Telnet登录设备。

4.6  配置文件

#

 telnet server enable

 telnet server acl 2000

#

acl basic 2000

 rule 1 permit source 192.168.0.46 0

 rule 2 permit source 192.168.0.52 0

 rule 3 deny

#

line vty 0 63

 authentication-mode scheme

user-role network-operator

#

local-user userA class manage

 password hash $h$6$I2Sg4Llj1qVUWQZ3$JA6KkU3zfVVRg48MM92X6cVpdiqR2JF887PKi3GQMwn

XXXcsWBuz7GIeJZeeNFMmMBaV7DPkKblnb0sGT2axvg==

 service-type telnet

 authorization-attribute user-role network-admin

#

local-user userB class manage

 password hash $h$6$q+c3OcSxrPpDpsDf$BWkgfOyxBLyR5zyYgF/+VvN/1ofy81zoHDlFf80OjDl

a6/EiSJbSBl33PeazilSkWSYcttkg5v5bGecB7oYwAw==

 service-type telnet

 authorization-attribute user-role roleB

#

role name roleB

 rule 1 permit read feature

#

5  用户登录交换机认证及命令行授权和计费的典型配置举例

5.1  组网需求

某公司组网如图3所示,为了保证交换机能够安全的运行,在交换机使用过程中,需要对登录用户进行认证、命令行执行限制以及对用户执行过的所有命令进行记录。

图3 用户登录设备认证及命令行授权和计费组网图

 

5.2  配置思路

·           本案例使用远程认证、授权和计费功能,需要配置HWTACACS方案(本举例使用HWTACACS服务器)。

·           如果需要HWTACACS服务器记录用户执行过的命令,可以通过创建一个可用Telnet方式登录设备的用户名,为其授权权限。则使用该用户登录时,只能执行HWTACACS服务器授权的命令,且这些命令都会被记录。

5.3  适用产品及版本

表3 适用产品及版本

产品

软件版本

S5560X-EI系列

Release 63xx系列

S5560X-HI系列

Release 63xx系列

S5500V2-EI系列

Release 63xx系列

MS4520V2-30F

Release 63xx系列

S6520X-HI系列

S6520X-EI系列

Release 63xx系列

S6520X-SI系列

S6520-SI系列

Release 63xx系列

S5000-EI系列

Release 63xx系列

MS4600系列

Release 63xx系列

S5560S-EI系列

S5560S-SI系列

Release 63xx系列

S5130S-HI系列

S5130S-EI系列

S5130S-SI系列

S5130S-LI系列

Release 63xx系列

S5120V2-SI系列

S5120V2-LI系列

Release 63xx系列

S3100V3-EI系列

S3100V3-SI系列

Release 63xx系列

S5110V2系列

Release 63xx系列

S5110V2-SI系列

Release 63xx系列

S5000V3-EI系列

Release 63xx系列

S5000E-X系列

Release 63xx系列

E128C

E152C

E500C系列

E500D系列

Release 63xx系列

MS4520V2系列(除MS4520V2-30F)

Release 63xx系列

MS4320V2系列

MS4300V2系列

MS4320系列

MS4200系列

Release 63xx系列

WS5850-WiNet系列

Release 63xx系列

WS5820-WiNet系列

WS5810-WiNet系列

Release 63xx系列

WAS6000系列

Release 63xx系列

 

5.4  配置注意事项

执行command authorization命令后,命令行授权功能将立即生效,用户执行的命令只有被授权后才被允许执行。因此,在执行此命令之前,请先在HWTACACS服务器上配置相应用户及用户可以使用的命令行,再在设备上配置命令行授权功能对应的HWTACACS方案。

5.5  配置步骤

5.5.1  iMC的配置步骤

说明

下面以iMC为例(使用iMC版本为:iMC PLAT 7.1(E0302)、iMC EIA 7.1(E0301)),说明HWTACACS服务器的基本配置。

 

# 增加设备区域。

选择“用户”页签,单击导航树中的[设备用户策略管理/授权场景条件/设备区域管理]菜单项,进入设备区域列表页面。单击<增加>按钮,进入增加设备区域页面。

·            输入区域名称system。

·            其它参数采用缺省值。

·            单击<确定>按钮,完成增加设备区域。

图4 增加设备区域

 

# 增加设备。

选择“用户”页签,单击导航树中的[设备用户策略管理/设备管理]菜单项,进入设备管理页面。单击<增加>按钮,进入增加设备页面。

·            输入共享密钥和确认共享密钥expert。

·            输入认证端口,缺省为49。

·            选择设备区域为system。

·            选择是否支持单一连接,选择“不支持”,表示设备与TAM通信时不支持在同一个TCP连接中建立多个会话。

·            选择是否支持Watchdog报文,选择“不支持”,表示用户在线时设备不发送Watchdog报文。

·            单击设备管理中的<手工增加>按钮,打开设备增加窗口。输入设备IP地址192.168.2.1,单击<确定>按钮即可增加设备。

·            单击<确定>按钮,完成增加设备的操作。

图5 增加设备

 

# 增加Shell Profile。

选择“用户”页签,单击导航树中的[设备用户策略管理/授权命令配置/Shell Profie配置]菜单项,进入Shell Profie列表页面。单击<增加>按钮,进入增加Shell Profie页面。

·            输入Shell Profile名称Shell Profile1。

·            输入授权级别,这里选择级别1。

·            其它参数采用缺省值。

·            单击<确定>按钮,完成增加Shell Profile。

图6 增加Shell Profile

 

# 接入授权信息。

选择“用户”页签,单击导航树中的[设备用户策略管理/授权策略管理]菜单项,进入授权策略列表页面。单击<增加>按钮,进入增加授权策略页面。输入策略的名称tac。单击接入授权信息区域的<增加>按钮,打开增加授权项的页面。

·            设备区域选择“system”,表示任意设备区域都符合要求。

·            设备类型选择“不限”,表示任意设备类型都符合要求。

·            授权时段选择“不限”,表示任意时间段都符合要求。

·            选择Shell Profile为Shell Profile1。

·            选择命令集选择“不限”,表示用户登录设备后可以执行任何命令。

·            单击<确定>按钮,完成增加授权项。

图7 接入授权信息

 

单击<确定>按钮,完成增加授权策略。

图8 增加授权策略

 

# 增加设备用户。

选择“用户”页签,单击导航树中的[设备用户管理/所有设备用户]菜单项,进入设备用户列表页面。

单击<增加>按钮,进入增加设备用户页面。

·            输入帐号名monitor。

·            输入用户名telnet-user。

·            输入登录密码和登录密码确认为123。

·            选择用户使用的授权策略为tac。

·            输入在线数量限制为5,表示最多允许5个该用户同时在线。

·            其它参数采用缺省值。

·            单击<确定>按钮,完成增加设备用户。

图9 增加设备用户

 

5.5.2  设备的配置步骤

# 在设备上配置IP地址及路由,以保证Device、Host A、HWTACACS server之间相互路由可达。(配置步骤略)

# 开启设备的Telnet服务器功能,以便用户访问。

<Sysname> system-view

[Sysname] telnet server enable

# 配置HWTACACS方案:

·            授权计费服务器的IP地址:TCP端口号为192.168.2.20:49(该端口号必须和HWTACACS服务器上的设置一致)。

·            报文的加密密码是expert。

·            登录时不需要输入域名,使用缺省域。

[Sysname] hwtacacs scheme tac

Create a new HWTACACS scheme.

[Sysname-hwtacacs-tac] primary authentication 192.168.2.20 49

[Sysname-hwtacacs-tac] primary authorization 192.168.2.20 49

[Sysname-hwtacacs-tac] primary accounting 192.168.2.20 49

[Sysname-hwtacacs-tac] key authentication simple expert

[Sysname-hwtacacs-tac] key authorization simple expert

[Sysname-hwtacacs-tac] key accounting simple expert

[Sysname-hwtacacs-tac] user-name-format without-domain

[Sysname-hwtacacs-tac] quit

# 配置缺省域的命令行授权计费的AAA方案,使用HWTACACS方案tac进行认证,并且使用本地认证local作为备选认证方法。

[Sysname] domain system

[Sysname-isp-system] authentication login hwtacacs-scheme tac local

[Sysname-isp-system] authorization login hwtacacs-scheme tac local

[Sysname-isp-system] authorization command hwtacacs-scheme tac local

[Sysname-isp-system] accounting login hwtacacs-scheme tac local

[Sysname-isp-system] accounting command hwtacacs-scheme tac

[Sysname-isp-system] quit

# 配置本地认证所需参数:创建本地用户monitor,密码为123,可使用的服务类型为telnet。删除用户缺省角色,配置用户角色为level-1,限制用户权限。

[Sysname] local-user monitor class manage

New local user added.

[Sysname-luser-manage-monitor] password simple 123

[Sysname-luser-manage-monitor] service-type telnet

[Sysname-luser-manage-monitor] authorization-attribute user-role level-1

[Sysname-luser-manage-monitor] undo authorization-attribute user-role network-operator

[Sysname-luser-manage-monitor] quit

#设置通过VTY用户线登录交换机使用AAA的认证方式。

[Sysname] line vty 0 63

[Sysname-line-vty0-63] authentication-mode scheme

# 使能命令行授权和命令行计费功能。

[Sysname-line-vty0-63] command authorization

[Sysname-line-vty0-63] command accounting

[Sysname-line-vty0-63] quit

5.6  验证配置

(1)       验证命令行授权功能

# 在用户主机上通过telnet方式登录设备,进入登录界面下。用户输入用户名“monitor”和密码“123”。

C:\Documents and Settings\Administrator> telnet 192.168.2.1

 

Login: monitor

Password:

******************************************************************************

* Copyright (c) 2004-2019 New H3C Technologies Co., Ltd. All rights reserved.*

* Without the owner's prior written consent,                                 *

* no decompiling or reverse-engineering shall be allowed.                    *

******************************************************************************

 

# 输入“?”,可以查看登录设备后能操作的命令行权限,此处显示仅能输入用户角色level-1允许执行的命令。

<Sysname> ?

User view commands:

  display      Display current system information

  erase        Alias for 'delete'

  exit         Alias for 'quit'

  mtrace       Configure the multicast traceroute

  no           Alias for 'undo'

  ping         Ping function

  quit         Exit from current command view

  show         Alias for 'display'

  ssh2         Establish an Stelnet connection to an Stelnet server

  super        Switch to a user role

  system-view  Enter the System View

  telnet       Establish a telnet connection

  tracert      Tracert function

  write        Alias for 'save'

 

<Sysname> system-view

[Sysname] ?

System view commands:

  access-list  Alias for 'acl'

  display      Display current system information

  end          Alias for 'return'

  erase        Alias for 'delete'

  exit         Alias for 'quit'

  hostname     Alias for 'sysname'

  logging      Alias for 'info-center'

  mtrace       Configure the multicast traceroute

  no           Alias for 'undo'

  ping         Ping function

  quit         Exit from current command view

  return       Exit to User View

  show         Alias for 'display'

  tracert      Tracert function

  write        Alias for 'save'

(2)       验证命令行计费功能

# 选择“用户”页签,单击导航树中的[设备用户管理/日志管理/审计日志]菜单项,进入审计日志列表页面。

·            输入账号名“monitor”。

·            选择审计起始时间。

单击<查询>按钮,查询出符合条件的审计日志。

图10 审计日志查询

 

可以看到帐号名为monitor有命令行system-view,审计通过。

# 单击开始类型详细信息,查看审计日志详细信息。

图11 查看审计日志详细信息

# 单击命令行结束类型详细信息,查看审计日志详细信息。

图12 查看审计日志详细信息

 

5.7  配置文件

#

telnet server enable

#

hwtacacs scheme tac

 primary authentication 192.168.2.20

 primary authorization 192.168.2.20

 primary accounting 192.168.2.20

 key authentication cipher $c$3$Fl1Mn3wBsh+vH6otPvoz+AdE7VaNS3c0Pw==

 key authorization cipher $c$3$2x6XI5xU7UGX6VqWFXNp2n3FG07uTNjiQw==

 key accounting cipher $c$3$2oKsuCOAZX1+3ibvTPxnJ1YvJ1MHqv73Lw==

 user-name-format without-domain

#

domain system

 authentication login hwtacacs-scheme tac local

 authorization login hwtacacs-scheme tac local

 accounting login hwtacacs-scheme tac local

 authorization command hwtacacs-scheme tac local

 accounting command hwtacacs-scheme tac

#

local-user monitor class manage

 password hash $h$6$5BqWnAJTpBbU5NbY$PbdgF+43eE5WMvj2iHPySfd5nGqj5AhDCDOXTiUMJvR

FFVsZaF8EW1tgpsQPRSq7SDKaGqwHTy9nsabAoGNaYg==

 service-type telnet

 authorization-attribute user-role level-1

#

line vty 0 63

 authentication-mode scheme

user-role network-operator

 idle-timeout 0 0

 command authorization

 command accounting

#

6  通过Telnet登录设备配置举例

6.1  组网需求

图13所示,将Host A的网口通过网线与Device设备的GigabitEthernet1/0/1接口连接。通过在Device设备上进行配置,实现以下要求:

·            设备通过Telnet登录的同时在线的最大用户连接数为10,每屏显示20行,设备历史命令缓冲区大小为100;

·            用户通过Telnet方式登录Device设备时采用scheme本地认证方式,需要输入用户名和密码(用户名和密码均为test);

·            登录后,当用户20分钟没有对设备进行操作,设备会自动断开连接。

图13 通过Telnet登录交换机组网图

 

6.2  配置思路

·            缺省情况下,设备的Telnet服务器处于关闭状态,需要通过Console口登录后开启设备的Telnet服务功能。

·            缺省情况下,本地用户的角色为network-operator,为了使用户登录后能正常使用设备上的所有命令,建议将本地用户的用户角色配置为network-admin。

6.3  适用产品及版本

表4 适用产品及版本

产品

软件版本

S5560X-EI系列

Release 63xx系列

S5560X-HI系列

Release 63xx系列

S5500V2-EI系列

Release 63xx系列

MS4520V2-30F

Release 63xx系列

S6520X-HI系列

S6520X-EI系列

Release 63xx系列

S6520X-SI系列

S6520-SI系列

Release 63xx系列

S5000-EI系列

Release 63xx系列

MS4600系列

Release 63xx系列

S5560S-EI系列

S5560S-SI系列

Release 63xx系列

S5130S-HI系列

S5130S-EI系列

S5130S-SI系列

S5130S-LI系列

Release 63xx系列

S5120V2-SI系列

S5120V2-LI系列

Release 63xx系列

S3100V3-EI系列

S3100V3-SI系列

Release 63xx系列

S5110V2系列

Release 63xx系列

S5110V2-SI系列

Release 63xx系列

S5000V3-EI系列

Release 63xx系列

S5000E-X系列

Release 63xx系列

E128C

E152C

E500C系列

E500D系列

Release 63xx系列

MS4520V2系列(除MS4520V2-30F)

Release 63xx系列

MS4320V2系列

MS4300V2系列

MS4320系列

MS4200系列

Release 63xx系列

WS5850-WiNet系列

Release 63xx系列

WS5820-WiNet系列

WS5810-WiNet系列

Release 63xx系列

WAS6000系列

Release 63xx系列

 

6.4  配置步骤

# 通过Console口登录设备,进入系统视图,修改设备名称,开启Telnet服务。

<Sysname> system-view

[Sysname] sysname Device

[Device] telnet server enable

# 创建接口地址。

[Device] vlan 2

[Device-vlan2] port gigabitethernet 1/0/1

[Device-vlan2] quit

[Device] interface vlan-interface 2

[Device-Vlan-interface2] ip address 192.168.3.1 24

[Device-Vlan-interface2] quit

# 配置所有的Telnet用户登录设备的认证方式为scheme,设置VTY用户线的公共属性。

[Device] line vty 0 63

[Device-line-vty0-63] authentication-mode scheme

[Device-line-vty0-63] screen-length 20

[Device-line-vty0-63] history-command max-size 100

[Device-line-vty0-63] idle-timeout 20

[Device-line-vty0-63] quit

# 配置通过Telnet登录的同时在线的最大用户连接数为10

[Device] aaa session-limit telnet 10

# 配置本地用户,用户名为test,密码为test,配置服务类型为telnet,用户角色为network-admin,删除默认角色。

[Device] local-user test class manage

New local user added.

[Device-luser-manage-test] password simple test

[Device-luser-manage-test] authorization-attribute user-role network-admin

[Device-luser-manage-test] undo authorization-attribute user-role network-operator

[Device-luser-manage-test] service-type telnet

[Device-luser-manage-test] quit

6.5  验证配置

# 在Host A命令窗口执行Telnet命令登录到设备,会出现如下界面。用户输入用户名“test”和密码“test”后能够成功登录到设备上对设备进行操作。

Login: test

Password:

******************************************************************************

* Copyright (c) 2004-2019 New H3C Technologies Co., Ltd. All rights reserved.*

* Without the owner's prior written consent,                                 *

* no decompiling or reverse-engineering shall be allowed.                    *

******************************************************************************

 

<Device>

# 当在线人数到达10个时,超出最大限制的用户不能Telnet登录到设备。

C:\Users\zhangsan>telnet 192.168.3.1

Trying 192.168.3.1 ...

Press CTRL+K to abort

Connected to 192.168.3.1 ...

 

The connection was closed by the remote host!

# 当用户20分钟没有对设备进行操作时,会自动退出登录,此时需要重新登录。

Inactive timeout reached, logging out.

 

The connection was closed by the remote host!

6.6  配置文件

说明

部分交换机的配置文件中会显示port link-mode bridge命令,请以实际情况为准。

 

#

 sysname Device

#

telnet server enable

#

interface Vlan-interface2

 ip address 192.168.3.1 255.255.255.0

#

interface GigabitEthernet1/0/1

 port link-mode bridge

 port access vlan 2

#

line vty 0 63

 authentication-mode scheme

user-role network-operator

 idle-timeout 20 0

 screen-length 20

 history-command max-size 100

#

aaa session-limit telnet 10

#

local-user test class manage

 password hash $h$6$/Xa6qIOrThQEVqbK$C00MPM5UaYoigaOfflWhpTskb/uB80yZ9O06tpztnDe

vrFEHqkvxfkSb4hUadHuknPSnjLNQByztfr30cP/Hlg==

 service-type telnet

 authorization-attribute user-role network-admin

#

7  设备作为Telnet客户端登录其他设备配置举例

7.1  组网需求

图14所示,将Host A的网口通过网线与Device A的GigabitEthernet1/0/2接口连接。通过在Device A设备上进行配置,实现以下要求:

·            用户可以通过Device A Telnet登录到Device B上,对Device B进行配置;

·            用户通过Telnet方式登录Device A时采用scheme本地认证方式,需要输入用户名和密码(用户名和密码均为test);

·            Device A仅允许使用IP地址为192.168.10.1的PC以Telnet方式登录,Device B仅允许Device A以Telnet方式登录;

·            Device A和Device B设备每屏显示20行,设备历史命令缓冲区大小为100;

·            登录设备后,如果用户20分钟没有对Device A或Device B进行操作,Device A或Device B会自动断开连接。

图14 通过Telnet登录交换机组网图

 

7.2  配置思路

·            缺省情况下,设备的Telnet服务器处于关闭状态,需要通过Console口登录后开启设备的Telnet服务功能。

·            缺省情况下,本地用户的角色为network-operator,为了使用户登录后能正常使用设备上的所有命令,建议将本地用户的用户角色配置为network-admin。

·            可以通过ACL来限制仅IP地址为192.168.10.1的主机以Telnet方式登录Device A,仅Device A设备以Telnet方式登录Device B。

7.3  适用产品及版本

表5 适用产品及版本

产品

软件版本

S5560X-EI系列

Release 63xx系列

S5560X-HI系列

Release 63xx系列

S5500V2-EI系列

Release 63xx系列

MS4520V2-30F

Release 63xx系列

S6520X-HI系列

S6520X-EI系列

Release 63xx系列

S6520X-SI系列

S6520-SI系列

Release 63xx系列

S5000-EI系列

Release 63xx系列

MS4600系列

Release 63xx系列

S5560S-EI系列

S5560S-SI系列

Release 63xx系列

S5130S-HI系列

S5130S-EI系列

S5130S-SI系列

S5130S-LI系列

Release 63xx系列

S5120V2-SI系列

S5120V2-LI系列

Release 63xx系列

S3100V3-EI系列

S3100V3-SI系列

Release 63xx系列

S5110V2系列

Release 63xx系列

S5110V2-SI系列

Release 63xx系列

S5000V3-EI系列

Release 63xx系列

S5000E-X系列

Release 63xx系列

E128C

E152C

E500C系列

E500D系列

Release 63xx系列

MS4520V2系列(除MS4520V2-30F)

Release 63xx系列

MS4320V2系列

MS4300V2系列

MS4320系列

MS4200系列

Release 63xx系列

WS5850-WiNet系列

Release 63xx系列

WS5820-WiNet系列

WS5810-WiNet系列

Release 63xx系列

WAS6000系列

Release 63xx系列

 

7.4  配置步骤

7.4.1  配置Device A

# 通过Console口登录设备,进入系统视图,修改设备名称,开启Telnet服务。

<Sysname> system-view

[Sysname] sysname DeviceA

[DeviceA] telnet server enable

# 创建接口地址。

[DeviceA] vlan 3

[DeviceA-vlan3] port gigabitethernet 1/0/1

[DeviceA-vlan3] quit

[DeviceA] interface vlan-interface 3

[DeviceA-Vlan-interface3] ip address 192.168.3.2 24

[DeviceA-Vlan-interface3] quit

[DeviceA] vlan 2

[DeviceA-vlan2] port gigabitethernet 1/0/2

[DeviceA-vlan3] quit

[DeviceA] interface vlan-interface 2

[DeviceA-Vlan-interface2] ip address 192.168.10.2 24

[DeviceA-Vlan-interface2] quit

# 配置所有的Telnet用户登录设备的认证方式为scheme,设置VTY用户线的公共属性。

[DeviceA] line vty 0 63

[DeviceA-line-vty0-63] authentication-mode scheme

[DeviceA-line-vty0-63] screen-length 20

[DeviceA-line-vty0-63] history-command max-size 100

[DeviceA-line-vty0-63] idle-timeout 20

[DeviceA-line-vty0-63] protocol inbound telnet

[DeviceA-line-vty0-63] quit

# 配置本地用户,用户名为test,密码为test,配置服务类型为telnet,用户角色为network-admin,删除默认角色。

[DeviceA] local-user test class manage

New local user added.

[DeviceA-luser-manage-test] password simple test

[DeviceA-luser-manage-test] authorization-attribute user-role network-admin

[DeviceA-luser-manage-test] undo authorization-attribute user-role network-operator

[DeviceA-luser-manage-test] service-type telnet

[DeviceA-luser-manage-test] quit

# 创建ACL并进入ACL视图,创建规则,仅允许来自192.168.10.1的用户访问交换机。

[DeviceA] acl basic 2000

[DeviceA-acl-ipv4-basic-2000] rule 1 permit source 192.168.10.1 0

[DeviceA-acl-ipv4-basic-2000] rule 2 deny source any

[DeviceA-acl-ipv4-basic-2000] quit

# 引用访问控制列表2000,通过源IP对Telnet用户进行控制。

[DeviceA] telnet server acl 2000

7.4.2  配置Device B

# 通过Console口登录设备,进入系统视图,修改设备名称,开启Telnet服务。

<Sysname> system-view

[Sysname] sysname DeviceB

[DeviceB] telnet server enable

# 创建接口地址。

[DeviceB] vlan 3

[DeviceB-vlan3] port gigabitethernet 1/0/1

[DeviceB-vlan3] quit

[DeviceB] interface vlan-interface 3

[DeviceB-Vlan-interface3] ip address 192.168.3.1 24

[DeviceB-Vlan-interface3] quit

# 配置所有的Telnet用户登录设备的认证方式为none,设置VTY用户线的公共属性。

[DeviceB] line vty 0 63

[DeviceB-line-vty0-63] authentication-mode none

[DeviceB-line-vty0-63] screen-length 20

[DeviceB-line-vty0-63] history-command max-size 100

[DeviceB-line-vty0-63] idle-timeout 20

[DeviceB-line-vty0-63] protocol inbound telnet

[DeviceB-line-vty0-63] quit

# 创建ACL并进入ACL视图,创建规则,仅允许来自192.168.3.2的用户访问交换机。

[DeviceB] acl basic 2000

[DeviceB-acl-ipv4-basic-2000] rule 1 permit source 192.168.3.2 0

[DeviceB-acl-ipv4-basic-2000] rule 2 deny source any

[DeviceB-acl-ipv4-basic-2000] quit

# 引用访问控制列表2000,通过源IP对Telnet用户进行控制。

[DeviceB] telnet server acl 2000

7.5  验证配置

1. Device A上验证telnet功能

# 在Host A命令窗口执行Telnet命令登录到DeviceA,会出现如下界面。用户输入用户名“test”和密码“test”后能够成功登录到设备上对设备进行操作。

Login: test

Password:

******************************************************************************

* Copyright (c) 2004-2019 New H3C Technologies Co., Ltd. All rights reserved.*

* Without the owner's prior written consent,                                 *

* no decompiling or reverse-engineering shall be allowed.                    *

******************************************************************************

 

<DeviceA>

# 其他用户不能通过Telnet登录到DeviceA,会出现不能连接的提示。

C:\Users\zhangsan>telnet 192.168.10.2

Trying 192.168.10.2 ...

Press CTRL+K to abort

Connected to 192.168.10.2 ...

Failed to connect to the remote host!

# 20分钟没有对Device A 进行操作的话会自动退出登录,此时需要重新登录。

<DeviceA>

Inactive timeout reached, logging out.

 

The connection was closed by the remote host!

2. Device B上验证telnet功能

# Device A可以执行Telnet到Device B,无需密码就能够登录到Device B并对其进行操作。

<DeviceA>telnet 192.168.3.1

Trying 192.168.3.1 ...

Press CTRL+K to abort

Connected to 192.168.3.1 ...

******************************************************************************

* Copyright (c) 2004-2019 New H3C Technologies Co., Ltd. All rights reserved.*

* Without the owner's prior written consent,                                 *

* no decompiling or reverse-engineering shall be allowed.                    *

******************************************************************************

 

<DeviceB>

# 其他与DeviceB路由可达的设备不能通过Telnet登录到Device B。

<Device> telnet 192.168.3.1

Trying 192.168.3.1 ...

Press CTRL+K to abort

Connected to 192.168.3.1 ...

Failed to connect to the remote host!

20分钟没有对Device B进行操作的话会自动退出登录,此时需要重新登录。

7.6  配置文件

说明

部分交换机的配置文件中会显示port link-mode bridge命令,请以实际情况为准。

 

·            Device A

#

 sysname DeviceA

#

 telnet server enable

 telnet server acl 2000

#

interface Vlan-interface2

 ip address 192.168.10.2 255.255.255.0

#

interface Vlan-interface3

 ip address 192.168.3.2 255.255.255.0

#

interface GigabitEthernet1/0/1

 port link-mode bridge

 port access vlan 3

#

interface GigabitEthernet1/0/2

 port link-mode bridge

 port access vlan 2

#

line vty 0 63

 authentication-mode scheme

 user-role network-operator

 protocol inbound telnet

 idle-timeout 20 0

 screen-length 20

 history-command max-size 100

#

acl basic 2000

 rule 1 permit source 192.168.10.1 0

 rule 2 deny source any

#

local-user test class manage

 password hash $h$6$V5dw8qzFDLAOmDzx$upf9K29n110G6OGdSXI0t69IoE5eot/Qh9Iuv/hptq6

2vxUq3867QbUBzmc6/hHwIfVQcDC8gVWpGvDQWXQTSQ==

 service-type telnet

 authorization-attribute user-role network-admin

#

·            Device B

#

 sysname DeviceB

#

 telnet server enable

 telnet server acl 2000

#

interface Vlan-interface3

 ip address 192.168.3.1 255.255.255.0

#

interface GigabitEthernet1/0/1

 port link-mode bridge

 port access vlan 3

#

line vty 0 63

 authentication-mode none

 user-role network-operator

 protocol inbound telnet

 idle-timeout 20 0

 screen-length 20

 history-command max-size 100

#

acl basic 2000

 rule 1 permit source 192.168.3.2 0

 rule 2 deny source any

#

不同款型规格的资料略有差异, 详细信息请向具体销售和400咨询。H3C保留在没有任何通知或提示的情况下对资料内容进行修改的权利!

新华三官网
联系我们