Persisting conntrack table to MySQL on OpenWRT

I needed a way to persist the conntrack table on an OpenWRT based router, so I made this quick & dirty script.

This uses the included luci.sys.net library to get the conntrack table and LuaSQL (MySQL in this instance) to persist.

The table structure has primary keys on nearly all the fields, except namely packets and bytes. If a duplicate key is detected on INSERT, it’ll update those 2 fields instead.

Figured I’d put this on Gist in case anyone else needed it.
Never made anything in Lua before, so I’m sure there are better ways to do certain things.

https://gist.github.com/sigmaprojects/27c71d26ac86c56eb666

Leave a Comment


NOTE - You can use these HTML tags and attributes:
<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>

WordPress Appliance - Powered by TurnKey Linux