How to create a new service that starts automatically in OpnSense?

Started by allebone, March 03, 2021, 08:56:38 PM

Previous topic - Next topic
Hi All,

I have a couple static arp entries set in /etc/rc.conf.
I can once the server is up start the service by typing 'service static_arp start' and the entries get added to OpnSense.

How can I make this service start on boot, and/or appear in the services in the GUI? I tried service static_arp enable but it didnt help.

Is there a way to make this automatic?

Kind regards
Peter


Thank you for posting this but I could not get it to work.

I created a file:
nano /usr/local/etc/rc.syshook.d/start/96-arpstartpete

I then chmod +x this file.

Inside file contains:
                                       
#!/bin/sh

service static_arp start


However when rebooting service does not start.

What have I done wrong?

Pete

What if you call static_arp directly like the example in the docs?

I cannot work out how to do this. I have tried but cant find where to run it from or how/what to do.

Pete

Maybe you need to put in your script:

/etc/rc.d/static_arp start

I tried but it would not work no matter what I did. I have followed instructions perfectly so cannot find a reason.

However I did find this instead which resolves the issue from:
https://forum.opnsense.org/index.php?topic=7641.0

"Well, the best way is through the DHCP after some further testing, because in rc.linkup there is a call to interfaces_staticarp_configure().

The DHCP can be "dummy-disabled" in this case with the following config:

    Enable DHCP server on the LAN interface = true
    Deny unknown clients = true
    Range = Single IP in interface subnet (will not be used)


Note that Static ARP must not be true (checked)

Then, under DHCP Static Mappings for this interface. configure the static ARP entries.

The dummy range IP will never be used because the multicast MACs won't send DHCP requests and everyone else will be denied.

A bit hackish but should also survive upgrades."


Indeed this does work and reboot preserves the arp entry I am trying to make so it fixes it for me.