浅谈背包问题
2025/12/20 16:31:04
验证
CLI配置
# 进入用户视图 <H3C> clock datetime 14:30:00 2025-12-20 # 设置时区为东八区(北京时间) [H3C] clock timezone BJ add 8 # 验证时间设置 [H3C] display clock· 时间格式:HH:MM:SS YYYY-MM-DD
· 断电重启后需重新设置,建议配合NTP使用
CLI配置
# 配置NTP服务器 [H3C] ntp-service enable [H3C] ntp-service unicast-server 192.168.1.100 # 配置本地时区 [H3C] clock timezone BJ add 8 # 验证同步状态 [H3C] display ntp-service status· 推荐使用内网NTP服务器或公网时间源
· 同步周期约15分钟,可通过display ntp-service sessions查看同步状态
为确保日志审计系统接收到带有时区信息的标准化时间戳,需进行以下配置:
| 配置项 | 命令 | 作用 |
|---|---|---|
| 启用时间戳 | info-center timestamp loghost date | 为syslog添加完整日期时间戳 |
| 快速日志时间戳 | customlog timestamp localtime | 设置快速日志使用本地时间 |
| 夏令时设置 | clock summer-time PDT 6 0801 6 0901 1 | 配置夏令时偏移(如需要) |
综合配置脚本
# 1. 基础时间设置 system-view clock timezone BJ add 8 clock datetime 14:36:56 2025-12-20# 2. NTP同步(推荐) ntp-service enable ntp-service unicast-server 192.168.1.100# 3. 日志主机配置 info-center enable info-center loghost 192.168.1.200 facility local5 info-center timestamp loghost date# 4. 快速日志配置(可选) customlog format syslog customlog host 192.168.1.200 port 514 customlog timestamp localtime # 5. 验证配置 display clock display ntp-service status display info-center