OPNsense
  • Home
  • Help
  • Search
  • Login
  • Register

  • OPNsense Forum »
  • English Forums »
  • 23.7 Production Series »
  • is there a way to make aliases set with /sbin/pfctl command persistent ?
« previous next »
  • Print
Pages: [1]

Author Topic: is there a way to make aliases set with /sbin/pfctl command persistent ?  (Read 216 times)

shade_ch

  • Newbie
  • *
  • Posts: 21
  • Karma: 0
    • View Profile
is there a way to make aliases set with /sbin/pfctl command persistent ?
« on: September 21, 2023, 01:58:34 pm »
Hello,

I have a script which updates an alias twice a day (it replaces its content with a list of IPs taken from various sources). The script and cron job both (seem to) work fine. I only have one issue: if the opnsense box is rebooted, the alias is empty, it does not keep the last values which have been set by the script.

Here is the last part of the script which updates the alias:

Code: [Select]
# Update table from temp file
RESULT=`/sbin/pfctl -t ${ALIAS_NAME} -T replace -f ${TMP_FILE} 2>&1`

Is there a way to make this persistent in order to not have an empty list after reboot ? Is there another problem (such as alias flush at reboot) ?

Thank you in advance!
Logged

Maurice

  • Hero Member
  • *****
  • Posts: 938
  • Karma: 112
    • View Profile
    • GitHub
Re: is there a way to make aliases set with /sbin/pfctl command persistent ?
« Reply #1 on: September 21, 2023, 03:03:43 pm »
There is an API which you can use for handling aliases: https://docs.opnsense.org/development/api/core/firewall.html

Cheers
Maurice
Logged
OPNsense virtual machine images
OPNsense aarch64 firmware repository

meyergru

  • Hero Member
  • *****
  • Posts: 806
  • Karma: 77
    • View Profile
    • congenio
Re: is there a way to make aliases set with /sbin/pfctl command persistent ?
« Reply #2 on: September 21, 2023, 03:06:21 pm »
1. If you have a cron job which updates the tables, why don't you use an @reboot entry in crontab to call that update script on reboot as well?

2. If the file is from a URL, you could as well use one or more "URL Table (IPs)"-type alias(es).
Logged
DEC760 - the model that Deciso never built

shade_ch

  • Newbie
  • *
  • Posts: 21
  • Karma: 0
    • View Profile
Re: is there a way to make aliases set with /sbin/pfctl command persistent ?
« Reply #3 on: September 21, 2023, 04:51:04 pm »
Quote from: Maurice on September 21, 2023, 03:03:43 pm
There is an API which you can use for handling aliases: https://docs.opnsense.org/development/api/core/firewall.html

Cheers
Maurice

Once again, thanks a lot Maurice.
« Last Edit: September 21, 2023, 05:03:31 pm by shade_ch »
Logged

shade_ch

  • Newbie
  • *
  • Posts: 21
  • Karma: 0
    • View Profile
Re: is there a way to make aliases set with /sbin/pfctl command persistent ?
« Reply #4 on: September 21, 2023, 05:10:36 pm »
Quote from: meyergru on September 21, 2023, 03:06:21 pm
1. If you have a cron job which updates the tables, why don't you use an @reboot entry in crontab to call that update script on reboot as well?

2. If the file is from a URL, you could as well use one or more "URL Table (IPs)"-type alias(es).
Hi,
1. This is what I'm doing, but it's a workaround
2. No it isn't, it is built from multiple sources that are processed/filtered
Logged

  • Print
Pages: [1]
« previous next »
  • OPNsense Forum »
  • English Forums »
  • 23.7 Production Series »
  • is there a way to make aliases set with /sbin/pfctl command persistent ?
 

OPNsense is an OSS project © Deciso B.V. 2015 - 2023 All rights reserved
  • SMF 2.0.19 | SMF © 2021, Simple Machines
    Privacy Policy
    | XHTML | RSS | WAP2