21.2.4 安全通信

2025-06-23 18:40:54 更新

设备和管理工作站的安全通信方式:SSH和VPN

(一)SSH

路由器RouterOne设置SSH访问,VTY配置只允许SSH访问

Router# config terminal

Enter configuration commands,one per line. End with CNTL/Z.

Router(config)# hostname RouterOne

RouterOne(config)# ip domain-name mydomain. com// 配置IP域名

RouterOne(config)# crypto key generate rsa// 生成RSA密钥对

The name for the keys will be: Routerone

Choose the size of the key modulus in the range of 360 to 2048 for yourGeneral Purpose Keys.

Choosing a key modulus greater than 512 may takea few minutes.

How many bits in the modulus [512]:1024

Generating RSA keys ...

[OK]

RouterOne(config)# ip ssh time-out 60// 设置SSH超时时间为60s

RouterOne(config)# ip ssh authentication-retries 2// 设置SSH认证失败次数为2次

Routerone(config)# line vty 0 4

RouterOne(config-line)# transport input ssh// 允许远程连接协议SSH

Routerone(config-line)# ^Z

RouterOne#

(二)IPSec VPN

管理工作站IP地址X.Y.Z.10,设备是路由器RouterOne

(1)设置ISAKMP(密钥管理协议 Internet Security Association and Key Management Protocol)

RouterOne# config terminal

Enter configuration commands, one per line.End with CNTL/Z.

RouterOne(config)# crypto isakmp policy 10// 定义编号和优先级为10的安全策略

RouterOne(config-isakmp)# authentication pre-share// 指定共享密钥鉴别机制

RouterOne(config-isakmp)# ^Z

(2)创建可扩展的ACL

RouterOne# config terminal

Enter configuration commands, one per line.End with CNTL/Z.

RouterOne(config)# access-list 150 permit ip host X.Y.Z.10 host RouterOne

RouterOne(config)# access-list 150 deny ip any any

RouterOne(config)# ^Z

(3)创建IPSec transforms

RouterOne# config terminal

Enter configuration commands, one per line.End with CNTL/Z.

RouterOne(config)# crypto ipsec transform-set TransOne ah-md5-hmac esp-des// 指定安全协议及使用的加密算法和HMAC算法

RouterOne(cfg-crypto-trans)# ^Z

(4)创建crypto map

RouterOne# config terminal

Enter configuration commands, one per line.End with CNTL/Z.

RouterOne(config) #crypto map MyMapOne 10 ipsec-isakmp// 创建序号10的ipsec-isakmp环境加密映射

RouterOne(config-crypto-map)# set peer X.Y.Z.10// 指定安全关联的另一端

RouterOne(config-crypto-map)# sct transform-set TransOne// 指定安全关联的安全协议及加密

RouterOne(config-crypto-map)# match address 150指定安全关联传输的IP分组集为150分组过滤器

RouterOne(config-crypto-map)# ^Z

(5)应用crypto map到路由接口

RouterOne# config terminal

Enter configuration commands, one per line.End with CNTL/Z.

RouterOne(config)# int Serial 0/1// 进入串口模块0的1接口

RouterOne(config-if)# crypto map MyMapOne// 配置好的加密映射作用到路由器目标接口

RouterOne(config-if)# ^Z