OPNsense Forum

Archive => 23.1 Legacy Series => Topic started by: Shcshc on March 03, 2023, 07:38:12 AM

Title: Have to reset firewall state every night
Post by: Shcshc on March 03, 2023, 07:38:12 AM
With the last update i have to reset every night the firewall state table. I have an dynamic ip. Without the state reset my sip trunks on my pbx and Audiocodes SBC don't get ready. How can i do the state reset automatically? I renew every night my ip with Cron, but i have to reset the state table every morning manually. Without this reset internet surfing is ok, but i think there ist an problem with udp.


Gesendet von iPad mit Tapatalk Pro
Title: Re: Have to reset firewall state every night
Post by: EdwinKM on March 03, 2023, 10:20:45 PM
Well, we use a "free" product. The developers can only fix this if you figure out how to reproduce the issues. (or you can to inspect other reported bugs if someone else already did).
Title: Re: Have to reset firewall state every night
Post by: alex303 on March 04, 2023, 01:27:22 AM
Log into your OPNSense box via SSH. Press 8 to start the shell.

Type this:

vi rstate.sh

And then paste this code:

#!/bin/sh

service firewall stop
rm -rf /var/db/stateful/pf*
service firewall start


Write and save changes by pressing : and then type wq and press enter.

Make the script executable by typing:

chmod +x rstate.sh

Once completed add cron job by typing

crontab -e

Add a new line that looks like this and set the time when you want the script to kick in. For this example ill use 1:30AM.

30 1 * * * /path/to/your/script/rstates.sh

Thats it. Simple.