news 2026/6/21 3:23:50

Neutron Packet Logging (by quqi99)

作者头像

张小明

前端开发工程师

1.2k 24
文章封面图
Neutron Packet Logging (by quqi99)

作者:张华 发表于:2026-01-05
版权声明:可以任意转载,转载时请务必以超链接形式标明文章原始出处和作者信息及本版权声明

问题

客户想要集中存储下列日志:

  • User activity on the cloud/infra servers (SSH login/out etc.) - /var/log/auth.log
  • Security group firewall logs (any drop would need to emit a log) - ovn-controller.log

rsyslog test

rsyslog server side:

sudo apt install -y rsyslog sudo cp /etc/rsyslog.conf /etc/rsyslog.conf.bak sudo sed -i '/^#module(load="imudp")/s/^#//' /etc/rsyslog.conf sudo sed -i '/^#input(type="imudp" port="514")/s/^#//' /etc/rsyslog.conf sudo sed -i '/^#module(load="imtcp")/s/^#//' /etc/rsyslog.conf sudo sed -i '/^#input(type="imtcp" port="514")/s/^#//' /etc/rsyslog.conf cat <<EOF | sudo tee -a /etc/rsyslog.conf \$template RemoteLogs,"/var/log/remote/%fromhost-ip%/%\$YEAR%-%\$MONTH%-%\$DAY%.log" *.* ?RemoteLogs #& ~ EOF sudo mkdir -p /var/log/remote sudo chown -R syslog:syslog /var/log/remote sudo ufw allow 514/tcp sudo ufw allow 514/udp sudo systemctl restart rsyslog sudo netstat -tulnp | grep rsyslog #tell rsyslog how to store the log, add them before the 'GLOBAL DIRECTIVE' section $template IPLog, "/var/log/network/%fromhost-ip%.log" *.* ?IPLog #$template remote-incoming-logs,"/var/log/%HOSTNAME%/%PROGRAMNAME%.log" #*.* ?remote-incoming-logs #$template RouterAuditLogs, "/var/log/router/%fromhost-ip%.log" #:fromhost-ip, !isequal, "127.0.0.1" ?RouterAuditLogs

rsyslog client side:

sudo apt install rsyslog -y #can also add log type in the file /etc/rsyslog.d/50-default.conf echo "*.* @192.168.99.220:514" | sudo tee -a /etc/rsyslog.conf sudo systemctl restart rsyslog #test it logger -t TEST "This is a test message from client" logger -t kern -p err "addddddddddd" #sudo tail -f /var/log/remote/192.168.99.213/2026-01-05.log

logrotate

logrotate -f /etc/logrotate.d/ovn
logrotate -d /etc/logrotate.d/ovn

#other - log rotate - eg: /etc/logrotate.d/ovn /var/log/remote/*/*.log { daily missingok rotate 30 compress delaycompress notifempty sharedscripts postrotate systemctl reload rsyslog > /dev/null 2>&1 || true endscript }

如何设置将 /var/log/auth.log 和 ovn-controller.log及它的logrotate文件设置为通过rsync上传到日志服务器呢? 例如(未测试):

# /etc/rsyslog.d/50-remote-logs.conf module(load="imfile" PollingInterval="10") input(type="imfile" File="/var/log/auth.log" Tag="auth:" Severity="info" Facility="authpriv" StateFile="state-auth" PersistStateInterval="100") input(type="imfile" File="/var/log/ovn/ovn-controller.log" Tag="ovn-controller:" Severity="info" Facility="local0" StateFile="state-ovn-controller" PersistStateInterval="100") authpriv.* @@192.168.10.100:514 local0.* @@192.168.10.100:514

openstack rsyslog

openstack各工程支持rsyslog - https://docs.openstack.org/ocata/admin-guide/compute-manage-logs.html
rsyslog server side, 日志中hostname等于COMPUTE_01写到/mnt/rsyslog/logs/compute-01.log:

$ModLoad imtcp $InputTCPServerRun 1024 :hostname, isequal, "COMPUTE_01" /mnt/rsyslog/logs/compute-01.log

rsyslog client side:

local0.error @@172.20.1.43:1024

ovn-controller rsyslog

ovn-controller也是支持rsyslog的 - https://www.ovn.org/support/dist-docs/ovn-controller.8.pdf
但是显然ovn-controller charm是不支持的, 所以无法用这种ovn native rsyslog

−−syslog−target=host:port Send syslog messages to UDP port on host, in addition to the system syslog. The host must be a numerical IP address, not a hostname. −−syslog−method=method Specify method as how syslog messages should be sent to syslog daemon. The following forms are supported: • libc, to use the libc syslog() function. Downside of using this options is that libc adds fixed prefix to every message before it is actually sent to the syslog daemon over /dev/log UNIX domain socket. • unix:file, to use a UNIX domain socket directly. It is possible to specify arbitrary message format with this option. However, rsyslogd 8.9 and older versions use hard coded parser function anyway that limits UNIX domain socket use. If you want to use arbitrary message format with older rsyslogd versions, then use UDP socket to localhost IP address instead. • udp:ip:port, to use a UDP socket. With this method it is possible to use arbitrary message format also with older rsyslogd. When sending syslog messages over UDP socket extra precaution needs to be taken into account, for example, syslog daemon needs to be configured to listen on the specified UDP port, accidental iptables rules could be interfering with local syslog traffic and there are some security considerations that apply to UDP sockets, but do not apply to UNIX domain sockets. • null, to discard all messages logged to syslog. The default is taken from the OVS_SYSLOG_METHOD environment variable; if it is unset, the default is libc.

Neutron Packet Logging

neutron支持SG log - https://docs.openstack.org/neutron/latest/admin/config-logging.html


ovs的配置:

1, neutron-api /etc/neutron/neutron.conf service_plugins = router,metering,log 2, ovn没有agent故无须配置这个, 但对于ovs需配置, 在neutron-api /etc/neutron/plugins/ml2/ml2_conf.ini与nova-compute /etc/neutron/plugins/ml2/openvswitch_agent.ini中配置: [agent] extensions = log 3, ovn没有agent故无须配置这个, 但对于ovs且需enable logging for FWaaS需配置, 在neutron-api /etc/neutron/plugins/ml2/ml2_conf.ini与nova-compute /etc/neutron/plugins/ml2/openvswitch_agent.ini中配置: [AGENT] extensions = fwaas_v2,fwaas_v2_log 4, ovn没有agent故无须配置这个, 但对于ovn需配置, 在nova-compute /etc/neutron/plugins/ml2/openvswitch_agent.ini中配置: [network_log] rate_limit = 100 burst_limit = 25 #local_output_log_base = <None>

ovn的配置:

1, neutron-api /etc/neutron/neutron.conf service_plugins = router,metering,log 2, neutron-api /etc/neutron/plugins/ml2/ml2_conf.ini [network_log] rate_limit = 150 burst_limit = 50 #ovn-nbctl list meter-band

policy的配置:

neutrona-api /etc/neutron/policy.json "get_loggable_resources": "rule:regular_user", "create_log": "rule:regular_user", "get_log": "rule:regular_user", "get_logs": "rule:regular_user", "update_log": "rule:regular_user", "delete_log": "rule:regular_user",

CLI demo

juju config neutron-api config-flags="service_plugins=metering,segments,ovn-router,log" openstack network loggable resources list openstack network log create --resource-type security_group --description "Collecting all security events" --event ALL Log_Created #openstack network log create --resource-type security_group --resource sg1 --event ALL log1 #OVN SG drops can't be enabled per security group but they can only be enabled for all security groups in once: openstack network log create --resource-type security_group --event DROP drop-logging #openstack network log create --resource-type security_group --resource sg1 --event DROP drop-logging openstack network log set --disable Log_Created openstack network log show Log_Created #In the case of --resource and --target are not specified from the request, these arguments will be assigned to ALL by default. #and ovn doesn't support --target openstack network log create my-log --resource-type security_group --resource sg1 openstack network log create my-log --resource-type firewall_group --resource fwg1 openstack network log create my-log --resource-type security_group --target portA

注意, 由于下列ovn driver的限制, OVN the security groups drops can’t be enabled per security group but they can only be enabled for all security groups in once:
Due to the internal design of the ML2/OVN driver, there is one ACL that aggregates all dropped traffic, instead of having one drop ACL per security group. Since the smallest logging unit in OVN is the ACL, that means that if we choose to log DROP traffic, we will get traffic logged from all security groups.

openstack network log create --resource-type security_group --event DROP drop-logging #openstack network log create --resource-type security_group --resource sg1 --event DROP drop-logging

日志的格式如下:

2025-06-20T08:10:32.737Z|168460|acl_log(ovn_pinctrl0)|INFO|name="neutron-e9550bd3-b246-4e3f-af93-3f21cd7289ac", verdict=drop, severity=info, direction=to-lport: ip,vlan_tci=0x0000,dl_src=00:50:56:ae:de:7f,dl_dst=01:00:5e:00:00:12,nw_src=51.148.81.194,nw_dst=224.0.0.18,nw_proto=112,nw_tos=192,nw_ecn=0,nw_ttl=255,nw_frag=no

目前遇到的2个问题

octavia units运行在lxd containers中, ovs会检测下列不正确的东西(2025-07-29T04:13:08.058Z|00036|dpif_netlink|INFO|The kernel module has a broken meter implementation.), 从而造成lxd的octavia units打开rsync后cause octavia to be unable to communicate with loadbalancers.

另外, ovn-controller.log is owned by root but service runs as syslog, 所以也会报下列错:
error accessing file ‘/var/log/ovn/ovn-controller.log’: Permission denied [v8.2112.0]

一个workaround是用下列配置create 0640 root syslog, 然后运行’sudo logrotate -f /etc/logrotate.d/ovn-common’ (debug it: sudo logrotate -d /etc/logrotate.d/ovn-common ), but after a reboot the file is recreate with root:root permission.

#vim /etc/logrotate.d/ovn-common var/log/ovn/*.log { su root root create 0640 root syslog # I added this line here daily compress sharedscripts missingok postrotate # Tell OVN daemons to reopen their log files if [ -d /var/run/ovn ]; then for ctl in /var/run/ovn/*.ctl; do ovs-appctl -t "$ctl" vlog/reopen 2>/dev/null || : done fi endscript }

Reference

[1] Linux系统基于rsyslog搭建中央日志服务器全攻略 - https://comate.baidu.com/zh/page/qoe6ga2iu69

版权声明: 本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若内容造成侵权/违法违规/事实不符,请联系邮箱:809451989@qq.com进行投诉反馈,一经查实,立即删除!
网站建设 2026/6/15 5:04:02

GLM-4.6V-Flash-WEB支持的多模态任务类型汇总介绍

GLM-4.6V-Flash-WEB 支持的多模态任务类型深度解析 在当前AI技术向“看得懂、问得清、答得准”演进的过程中&#xff0c;多模态大模型正从实验室走向真实业务场景。尤其是在内容平台、电商平台、智能客服等需要高频图文交互的系统中&#xff0c;开发者面临一个现实难题&#xf…

作者头像 李华
网站建设 2026/6/15 5:04:00

生态保护项目引入GLM-4.6V-Flash-WEB评估恢复成效

生态保护项目引入GLM-4.6V-Flash-WEB评估恢复成效 在一片刚刚完成退耕还林的山地&#xff0c;护林员举起手机拍下一张航拍图&#xff0c;上传到网页平台&#xff0c;输入问题&#xff1a;“当前植被覆盖情况如何&#xff1f;是否有裸露土壤或破坏痕迹&#xff1f;”不到30秒&am…

作者头像 李华
网站建设 2026/6/19 21:46:45

B站视频转文字实战指南:三步搞定高效内容提取

B站视频转文字实战指南&#xff1a;三步搞定高效内容提取 【免费下载链接】bili2text Bilibili视频转文字&#xff0c;一步到位&#xff0c;输入链接即可使用 项目地址: https://gitcode.com/gh_mirrors/bi/bili2text 还在为整理B站视频内容而反复暂停播放吗&#xff1f…

作者头像 李华
网站建设 2026/6/15 5:03:56

用AI打造智能斗鱼养殖监测系统

快速体验 打开 InsCode(快马)平台 https://www.inscode.net输入框内输入如下内容&#xff1a; 开发一个斗鱼智能养殖监测系统&#xff0c;使用传感器监测水温、PH值和溶氧量&#xff0c;通过AI分析数据并自动调节。系统需包含实时数据展示面板、异常报警功能和历史数据记录。…

作者头像 李华
网站建设 2026/6/15 5:03:54

从零搭建企业级云记事本:快马平台实战指南

快速体验 打开 InsCode(快马)平台 https://www.inscode.net输入框内输入如下内容&#xff1a; 开发一个企业级云记事本系统&#xff0c;功能包括&#xff1a;1. 用户注册/登录(支持OAuth) 2. 富文本编辑器(支持图片上传) 3. 多设备实时同步 4. 团队协作(多人同时编辑) 5. 版本…

作者头像 李华
网站建设 2026/6/20 10:39:42

企业级TOMCAT8实战:从下载到高可用集群部署

快速体验 打开 InsCode(快马)平台 https://www.inscode.net输入框内输入如下内容&#xff1a; 开发一个TOMCAT8企业部署向导&#xff0c;功能包括&#xff1a;1.不同场景下的版本选择建议 2.性能调优参数生成器 3.集群配置模板 4.健康检查脚本 5.日志分析工具集成。要求使用D…

作者头像 李华