news 2026/5/19 2:45:46

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/5/5 8:33:44

机器人导航过程中GLM-4.6V-Flash-WEB的环境理解能力

机器人导航中的环境理解&#xff1a;GLM-4.6V-Flash-WEB 的实战价值 在智能机器人逐步走进写字楼、医院和工厂的今天&#xff0c;一个核心问题日益凸显&#xff1a;为什么有些机器人能在复杂环境中灵活穿梭&#xff0c;而另一些却频频“撞墙”或“卡顿”&#xff1f;答案往往不…

作者头像 李华
网站建设 2026/5/13 10:51:24

开源多模态新星:GLM-4.6V-Flash-WEB全面解读

开源多模态新星&#xff1a;GLM-4.6V-Flash-WEB全面解读 在如今的AI应用浪潮中&#xff0c;用户早已不再满足于“只看字”的智能系统。从电商客服收到一张商品破损图&#xff0c;到金融从业者上传一份扫描版财报&#xff0c;再到学生随手拍下一道几何题寻求解答——图文混合输入…

作者头像 李华
网站建设 2026/5/11 18:48:57

GLM-4.6V-Flash-WEB能否识别船舶超载迹象?

GLM-4.6V-Flash-WEB能否识别船舶超载迹象&#xff1f; 在港口码头的清晨&#xff0c;无人机缓缓升空&#xff0c;镜头扫过一排排货船。甲板上层层叠叠的集装箱高耸如山&#xff0c;有些甚至微微倾斜&#xff0c;边缘几乎触碰到空中电缆。监管人员盯着监控屏幕皱眉&#xff1a;“…

作者头像 李华
网站建设 2026/5/19 2:45:26

轨道交通建设:GLM-4.6V-Flash-WEB保障工程质量

轨道交通建设中的视觉智能革命&#xff1a;GLM-4.6V-Flash-WEB 如何重塑工程质量管控 在城市轨道交通项目日益密集的今天&#xff0c;一个看似不起眼的问题正不断挑战工程管理者的神经——如何在庞大的施工体量下&#xff0c;确保每一段隧道、每一根钢筋、每一个焊点都符合质量…

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

GLM-4.6V-Flash-WEB能否识别极端天气引发的次生灾害征兆?

GLM-4.6V-Flash-WEB能否识别极端天气引发的次生灾害征兆&#xff1f; 近年来&#xff0c;台风、暴雨、山洪等极端天气事件频发&#xff0c;其带来的次生灾害——如城市内涝、山体滑坡、道路损毁、泥石流等——往往在短时间内造成严重损失。传统预警系统依赖气象模型和固定传感…

作者头像 李华
网站建设 2026/5/15 18:08:16

用NODEPAD快速原型:1小时打造TODO应用

快速体验 打开 InsCode(快马)平台 https://www.inscode.net输入框内输入如下内容&#xff1a; 开发一个极简TODO应用原型&#xff0c;功能包括&#xff1a;1. 任务添加/删除&#xff1b;2. 状态标记&#xff1b;3. 本地存储&#xff1b;4. 响应式设计。要求使用最简技术栈(HT…

作者头像 李华