Netgate Discussion Forum
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Search
    • Register
    • Login

    How to automatically load a new configuration in every boot

    Scheduled Pinned Locked Moved General pfSense Questions
    15 Posts 3 Posters 1.6k Views
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • stephenw10S
      stephenw10 Netgate Administrator
      last edited by

      That's the main config file so it is loaded at each boot and also updated any time you make a change. No guarantees that won't break at upgrade etc...

      The ECL will actually look for config in all attached disks not just USB:
      https://github.com/pfsense/pfsense/blob/master/src/etc/ecl.php#L48

      So you can likely still use that. That would not require any changes to pfSense, only that a far32 formatted drive is present. It would load the config at every boot though overriding any changes made in the webgui.

      Steve

      U 1 Reply Last reply Reply Quote 0
      • U
        Ulysses_ @stephenw10
        last edited by

        Changes made with the web interface should be persistent. Is it safer if the entire /cf/conf/ directory becomes the mount point for the private drive?

        1 Reply Last reply Reply Quote 0
        • stephenw10S
          stephenw10 Netgate Administrator
          last edited by

          Neither is safe really. Both are untested and unsupported. It would be entirely down to you to decide if it's functional. 😉

          If it works then great but, as I say, it may well fail somewhere down the line when you update the firmware etc.

          Steve

          1 Reply Last reply Reply Quote 0
          • U
            Ulysses_
            last edited by

            Does it make any difference if you specify additional drives and mounting directories during installation? Or these too may not be honored in future versions?

            1 Reply Last reply Reply Quote 0
            • U
              Ulysses_
              last edited by Ulysses_

              By the way, a config.xml in the separate drive mounted at /myconfig does not seem to be read at all during boot. That is, after these commands in a brand new VM:

              mkdir /myconfig
              echo "/dev/ada1s1 /myconfig msdosfs rw,noatime 1 1" >> /etc/fstab
              mount /dev/ada1s1
              cp /cf/conf/config.xml /myconfig/
              sed -ic 's/bannedsite/nothing/g' /myconfig/config.xml
              

              Bannedsite is still banned in the DNS resolver after this and a reboot.

              EDIT: forgot the mount command above. But still the same problem.

              1 Reply Last reply Reply Quote 0
              • stephenw10S
                stephenw10 Netgate Administrator
                last edited by

                That's with the linked config file?

                Did that actually alter it as expected?

                Where/when is that script run?

                Steve

                U 1 Reply Last reply Reply Quote 0
                • U
                  Ulysses_ @stephenw10
                  last edited by Ulysses_

                  @stephenw10 said in How to automatically load a new configuration in every boot:

                  That's with the linked config file?

                  No, this is brand new, starting from scratch in a freshly installed pfsense. EDIT: Plus a few sites configured in the DNS resolver to point to the local host so they are effectively banned.

                  Did that actually alter it as expected?

                  There is no linked file and the actual config.xml file in the second drive has been modified as expected, but going to the DNS resolver after boot no modification appears there.

                  Where/when is that script run?

                  Commands run one by one in the web interface under Diagnostics.

                  N 1 Reply Last reply Reply Quote 0
                  • N
                    netblues @Ulysses_
                    last edited by

                    Just an untested idea.
                    What if you configure the xml rpc sync from master to slave, in a daisy chain fashion.
                    Changing something on master would make a ripple propagation to all.
                    The downside is that if one pf is missing the chain breaks..

                    1 Reply Last reply Reply Quote 0
                    • stephenw10S
                      stephenw10 Netgate Administrator
                      last edited by stephenw10

                      Ah OK check the boot log. Just after root is mounted you will see the ECL looking for config files.
                      If it finds one:

                      External config loader 1.0 is now starting... da0s1 -> found config.xml
                      Backing up old configuration...
                      Restoring [da0s1] /tmp/mnt/cf/config.xml...
                      Cleaning up...
                      

                      Steve

                      U 1 Reply Last reply Reply Quote 0
                      • U
                        Ulysses_ @stephenw10
                        last edited by

                        OK, it works as long as you do NOT mount the extra drive with a line in /etc/fstab. Or my line in /etc/fstab is wrong. Here it is again:

                        /dev/ada1s1 /myconfig msdosfs rw,noatime 1 1
                        

                        It is useful to have an extra drive mounted automatically for reasons other than config. Should a bug be filed for this?

                        1 Reply Last reply Reply Quote 0
                        • stephenw10S
                          stephenw10 Netgate Administrator
                          last edited by

                          There is almost certainly a feature request open for this already. It's a request most often asked by folks wanting to use a separate driver as a cache or for logs etc.
                          pfSense does not support a config running from multiple drives though and that's unlikely to change.

                          Steve

                          1 Reply Last reply Reply Quote 0
                          • U
                            Ulysses_
                            last edited by Ulysses_

                            Let's not mount that extra drive at boot then but well after the ECL does its thing. Where's a proper place to put the mount command? Would also need to remember to manually save (backup) any changes to the config to the extra drive or perhaps modify another script?

                            1 Reply Last reply Reply Quote 0
                            • First post
                              Last post
                            Copyright 2025 Rubicon Communications LLC (Netgate). All rights reserved.