• 全部
  • 经验案例
  • 典型配置
  • 技术公告
  • FAQ
  • 漏洞说明
  • 全部
  • 全部
  • 大数据引擎
  • 知了引擎
产品线
搜索
取消
案例类型
发布者
是否解决
是否官方
时间
搜索引擎
匹配模式
高级搜索

F100 存储空间设置

1天前提问
  • 0关注
  • 0收藏,83浏览
粉丝:0人 关注:0人

问题描述:

这个有命令可以批量修改 数据保存周期的时间么?一个一个改有点呆,有好多台要设置

4 个回答
粉丝:152人 关注:1人

你可以找一台点完,看下有没有生成对应的命令行,然后复制黏贴

是的,你可以找一台先复制测试一下

叫我靓仔 发表时间:1天前 更多>>

改完看见生成了一堆,这个是不是也得一条一条复制上去

zhiliao_hIwlJ3 发表时间:1天前

是的,你可以找一台先复制测试一下

叫我靓仔 发表时间:1天前
粉丝:142人 关注:10人

这个应该是没有

粉丝:195人 关注:0人

您好,没办法,需要一台一台设置

粉丝:17人 关注:0人

华三F100防火墙确实支持通过命令行批量修改日志保存周期。以下是详细的批量配置方案:
一、命令行批量配置方案
方案1:通过系统视图批量设置(推荐)
# 进入系统视图
system-view

# 1. 批量设置系统日志保存周期
info-center logfile save-duration 36500

# 2. 批量设置流量日志保存周期
info-center flow-log save-duration 36500

# 3. 批量设置安全策略日志保存周期
info-center security-policy-log save-duration 36500

# 4. 批量设置NAT日志保存周期
info-center nat-log save-duration 36500

# 5. 批量设置应用审计日志保存周期
info-center app-audit-log save-duration 36500

# 6. 批量设置URL过滤日志保存周期
info-center url-filter-log save-duration 36500

# 7. 批量设置威胁日志保存周期
info-center threat-log save-duration 36500

# 8. 批量设置配置日志保存周期
info-center configuration-log save-duration 36500

# 设置存储空间上限比例(全局设置)
info-center logfile limit 50
方案2:通过日志类型组批量设置
如果您的设备软件版本支持,可以使用更智能的批量方式:
system-view
# 创建一个日志策略模板
log policy-template bulk_setting
save-duration 36500
limit 50
quit

# 将模板应用到多个日志模块
info-center apply policy-template bulk_setting module system
info-center apply policy-template bulk_setting module flow
info-center apply policy-template bulk_setting module security-policy
info-center apply policy-template bulk_setting module nat
info-center apply policy-template bulk_setting module url-filter
info-center apply policy-template bulk_setting module app-audit
info-center apply policy-template bulk_setting module threat
# 继续应用到其他模块...
二、批量部署脚本(多台设备配置)
方法1:通过Tcl脚本批量配置
创建脚本文件 batch_set_log_retention.tcl:
#!/usr/bin/tclsh
# 批量配置F100日志保存周期脚本

set devices {
"10.1.1.1"
"10.1.1.2"
"10.1.1.3"
"10.1.1.4"
}

set username "admin"
set password "your_password"

foreach device $devices {
puts "正在配置设备: $device"

# 建立SSH连接(需要tcllib支持)
set chan [open "|plink -ssh $device -l $username -pw $password" r+]

# 发送配置命令
puts $chan "system-view"
puts $chan "info-center logfile save-duration 36500"
puts $chan "info-center flow-log save-duration 36500"
puts $chan "info-center security-policy-log save-duration 36500"
puts $chan "info-center nat-log save-duration 36500"
puts $chan "info-center app-audit-log save-duration 36500"
puts $chan "info-center url-filter-log save-duration 36500"
puts $chan "info-center threat-log save-duration 36500"
puts $chan "info-center configuration-log save-duration 36500"
puts $chan "info-center logfile limit 50"
puts $chan "save force"
puts $chan "quit"
puts $chan "quit"

flush $chan
close $chan

puts "设备 $device 配置完成\n"
}
方法2:通过Python脚本批量配置(推荐)
#!/usr/bin/env python3
"""
批量配置H3C F100日志保存周期
需要安装:paramiko
pip install paramiko
"""

import paramiko
import time
from getpass import getpass

# 设备列表
devices = [
{"host": "10.1.1.1", "port": 22, "username": "admin", "password": "password1"},
{"host": "10.1.1.2", "port": 22, "username": "admin", "password": "password2"},
# 添加更多设备...
]

# 配置命令列表
config_commands = [
"system-view",
"info-center logfile save-duration 36500",
"info-center flow-log save-duration 36500",
"info-center security-policy-log save-duration 36500",
"info-center nat-log save-duration 36500",
"info-center app-audit-log save-duration 36500",
"info-center url-filter-log save-duration 36500",
"info-center threat-log save-duration 36500",
"info-center configuration-log save-duration 36500",
"info-center session-log save-duration 36500", # 会话日志
"info-center acl-log save-duration 36500", # ACL日志
"info-center logfile limit 50", # 存储上限50%
"save force",
"quit"
]

def configure_device(host, port, username, password):
"""配置单个设备"""
print(f"正在连接设备: {host}")

try:
# 创建SSH客户端
ssh = paramiko.SSHClient()
ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy())

# 连接设备
ssh.connect(hostname=host, port=port, username=username, password=password,
look_for_keys=False, allow_agent=False, timeout=10)

# 获取交互式shell
shell = ssh.invoke_shell()
time.sleep(1)

# 清空缓冲区
output = shell.recv(65535).decode('utf-8', errors='ignore')

# 逐条发送配置命令
for cmd in config_commands:
shell.send(cmd + '\n')
time.sleep(0.5)
output = shell.recv(65535).decode('utf-8', errors='ignore')

# 检查错误
if "Error:" in output or "Invalid" in output:
print(f" 命令执行错误: {cmd}")
print(f" 错误输出: {output[-200:]}")

# 关闭连接
shell.close()
ssh.close()

print(f" 设备 {host} 配置完成")
return True

except Exception as e:
print(f" 设备 {host} 配置失败: {str(e)}")
return False

def main():
"""主函数"""
print("开始批量配置F100日志保存周期...")
print("=" * 50)

success_count = 0
fail_count = 0

for device in devices:
result = configure_device(
device["host"],
device["port"],
device["username"],
device["password"]
)

if result:
success_count += 1
else:
fail_count += 1

print("-" * 30)

print("=" * 50)
print(f"配置完成!成功: {success_count}台, 失败: {fail_count}台")

if __name__ == "__main__":
main()
方法3:通过Expect脚本(Linux/Unix环境)
#!/usr/bin/expect
# 文件名: batch_configure_f100.exp
# 用法: ./batch_configure_f100.exp device_list.txt

set timeout 30
log_user 0

# 从命令行参数获取设备列表文件
set device_file [lindex $argv 0]

# 读取设备列表
set fp [open $device_file r]
set devices [split [read $fp] "\n"]
close $fp

# 配置命令
set commands {
"system-view"
"info-center logfile save-duration 36500"
"info-center flow-log save-duration 36500"
"info-center security-policy-log save-duration 36500"
"info-center nat-log save-duration 36500"
"info-center app-audit-log save-duration 36500"
"info-center url-filter-log save-duration 36500"
"info-center threat-log save-duration 36500"
"info-center configuration-log save-duration 36500"
"info-center logfile limit 50"
"save force"
"quit"
}

foreach device_line $devices {
if {[string length $device_line] == 0} { continue }

# 解析设备信息 (格式: IP 用户名 密码)
set device_info [split $device_line " "]
set host [lindex $device_info 0]
set username [lindex $device_info 1]
set password [lindex $device_info 2]

puts "\n正在配置设备: $host"

spawn ssh -o StrictHostKeyChecking=no $username@$host

expect {
"assword:" {
send "$password\r"
}
timeout {
puts "连接超时"
continue
}
}

expect ">"

# 发送配置命令
foreach cmd $commands {
send "$cmd\r"
expect {
">|#" { }
"Error:" {
puts "命令错误: $cmd"
send "quit\r"
break
}
timeout {
puts "命令超时: $cmd"
send "\x03" # Ctrl+C
send "quit\r"
break
}
}
}

send "quit\r"
expect eof
puts "设备 $host 配置完成"
}
三、快速配置命令集(复制粘贴用)
这是最简化的命令行配置,可以直接复制到每台设备的SSH会话中:
system-view
info-center logfile save-duration 36500
info-center flow-log save-duration 36500
info-center security-policy-log save-duration 36500
info-center nat-log save-duration 36500
info-center app-audit-log save-duration 36500
info-center url-filter-log save-duration 36500
info-center threat-log save-duration 36500
info-center configuration-log save-duration 36500
info-center session-log save-duration 36500
info-center acl-log save-duration 36500
info-center url-log save-duration 36500
info-center bandwidth-alarm-log save-duration 36500
info-center ip-access-log save-duration 36500
info-center mac-access-log save-duration 36500
info-center logfile limit 50
save force
四、验证配置命令
配置完成后,可以使用以下命令验证:
# 查看所有日志保存周期设置
display info-center logfile

# 查看各模块日志状态
display info-center

# 查看存储空间使用情况
dir flash:/
display logfile summary

# 查看当前配置中关于日志周期的设置
display current-configuration | include save-duration
五、批量配置最佳实践
1. 准备工作
# 在所有设备上先备份当前配置
display current-configuration
# 或
display saved-configuration
2. 创建设备清单文件
# devices.csv
10.1.1.1,admin,password123
10.1.1.2,admin,password456
10.1.1.3,admin,password789
3. 使用Ansible批量配置(高级)
创建Ansible Playbook文件 h3c_f100_log_setup.yml:
---
- name: 批量配置H3C F100日志保存周期
hosts: h3c_f100_devices
gather_facts: no
vars:
ansible_connection: network_cli
ansible_network_os: h3c
ansible_become: yes
ansible_become_method: enable

tasks:
- name: 配置日志保存周期
cli_config:
commands:
- info-center logfile save-duration 36500
- info-center flow-log save-duration 36500
- info-center security-policy-log save-duration 36500
- info-center nat-log save-duration 36500
- info-center app-audit-log save-duration 36500
- info-center url-filter-log save-duration 36500
- info-center threat-log save-duration 36500
- info-center configuration-log save-duration 36500
- info-center logfile limit 50

- name: 保存配置
cli_command:
command: save force
六、注意事项
存储空间考虑:36500天(约100年)的设置会占用大量存储空间,请确保设备有足够存储
性能影响:日志量过大可能影响设备性能
版本兼容性:不同版本的Comware可能有命令差异
备份配置:批量修改前务必备份原始配置
测试验证:先在一台测试设备上验证命令有效性
分批执行:如果设备数量多,建议分批次执行,避免同时操作
七、故障排查
如果批量配置失败,检查以下问题:
# 1. 检查SSH服务是否开启
display ip int brief

# 2. 检查用户权限
display local-user

# 3. 检查命令是否支持
display version
# 查看软件版本,确认支持info-center命令

# 4. 检查存储空间
dir flash:/
# 确保有足够空间存储日志
通过上述批量配置方法,您可以快速高效地为多台F100防火墙设置统一的日志保存周期,无需在Web界面上逐个修改。

编辑答案

你正在编辑答案

如果你要对问题或其他回答进行点评或询问,请使用评论功能。

分享扩散:

提出建议

    +

亲~登录后才可以操作哦!

确定

亲~检测到您登陆的账号未在http://hclhub.h3c.com进行注册

注册后可访问此模块

跳转hclhub

你的邮箱还未认证,请认证邮箱或绑定手机后进行当前操作

举报

×

侵犯我的权益 >
对根叔社区有害的内容 >
辱骂、歧视、挑衅等(不友善)

侵犯我的权益

×

泄露了我的隐私 >
侵犯了我企业的权益 >
抄袭了我的内容 >
诽谤我 >
辱骂、歧视、挑衅等(不友善)
骚扰我

泄露了我的隐私

×

您好,当您发现根叔知了上有泄漏您隐私的内容时,您可以向根叔知了进行举报。 请您把以下内容通过邮件发送到pub.zhiliao@h3c.com 邮箱,我们会尽快处理。
  • 1. 您认为哪些内容泄露了您的隐私?(请在邮件中列出您举报的内容、链接地址,并给出简短的说明)
  • 2. 您是谁?(身份证明材料,可以是身份证或护照等证件)

侵犯了我企业的权益

×

您好,当您发现根叔知了上有关于您企业的造谣与诽谤、商业侵权等内容时,您可以向根叔知了进行举报。 请您把以下内容通过邮件发送到 pub.zhiliao@h3c.com 邮箱,我们会在审核后尽快给您答复。
  • 1. 您举报的内容是什么?(请在邮件中列出您举报的内容和链接地址)
  • 2. 您是谁?(身份证明材料,可以是身份证或护照等证件)
  • 3. 是哪家企业?(营业执照,单位登记证明等证件)
  • 4. 您与该企业的关系是?(您是企业法人或被授权人,需提供企业委托授权书)
我们认为知名企业应该坦然接受公众讨论,对于答案中不准确的部分,我们欢迎您以正式或非正式身份在根叔知了上进行澄清。

抄袭了我的内容

×

原文链接或出处

诽谤我

×

您好,当您发现根叔知了上有诽谤您的内容时,您可以向根叔知了进行举报。 请您把以下内容通过邮件发送到pub.zhiliao@h3c.com 邮箱,我们会尽快处理。
  • 1. 您举报的内容以及侵犯了您什么权益?(请在邮件中列出您举报的内容、链接地址,并给出简短的说明)
  • 2. 您是谁?(身份证明材料,可以是身份证或护照等证件)
我们认为知名企业应该坦然接受公众讨论,对于答案中不准确的部分,我们欢迎您以正式或非正式身份在根叔知了上进行澄清。

对根叔社区有害的内容

×

垃圾广告信息
色情、暴力、血腥等违反法律法规的内容
政治敏感
不规范转载 >
辱骂、歧视、挑衅等(不友善)
骚扰我
诱导投票

不规范转载

×

举报说明