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

    Any way to "ninja edit" interface assignments?

    Scheduled Pinned Locked Moved General pfSense Questions
    7 Posts 3 Posters 734 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.
    • M
      mattlach
      last edited by

      Hey everyone,

      I am in the process of taking down my pfSense router/firewall box for overhaul and upgrade.

      In the mean time I am just imaging it over to a KVM virtual machine on another box, with IOMMU passed through NIC's.

      The problem? The interface names changed and it erased all of my vlans and a lot of their configs on first boot. (luckily I had the image handy and could start over)

      The problem is this:

      The bare metal box has four network interfaces.

      • igb0 and igb1 (on board); and
      • ix0 and ix1 (discrete NIC card)

      igb0 is configured as WAN and ix1 is configured as LAN.

      Well, ix1 is not used in and of itself, but rather it has 10-20 child VLAN interfaces that are used. (ix1.1, ix1.2, ix1.3, etc.)

      The temporary VM (KVM on a Linux box) also has:

      • igb0 and igb1 (on board); and
      • ix0 and ix1 (discrete NIC card)

      However, one of the igb and one of the ix devices are in active use, meaning only one of each can be IOMMU forwarded to the guest.

      The result? The guest has an igb0 and an ix0, but no ix1.

      After imaging the drive over to the KVM box, and booting for the first time, pfSense throws a little hissy fit that it can't find ix1, and demands that interfaces be assigned on boot. Doing so erased all of my VLAN's (and I think (but not sure) all of the firewall and routing rules I have set up between them.

      So, I imaged the VM and tried again. I was forced to temporarily forward both IX devices from the host (interrupting what it was doing) to the guest, such that there was an ix1 for pfsense to see during boot.

      Then I could change the interface assignment for each of the VLAN's, to ix0.1, ix0.2, ix0.3 etc.

      Then shut down the VM, and remove the second ix device from being forwarded.

      So, I was able to solve it. It was a little bit inconvenient as I needed to interrupt the host, but it worked.

      But what if I had a mission critical host? Or what if I just didn't have the same NIC, so ix devices didn't show up at all?

      I guess my question is, is there a way to edit the interface assignments before first boot of the changed system, so this does not happen?

      I presume there must be some way of doing this, but I just don't know what it is. I'd appreciate any suggestions on how to better do this next time.

      Thank you,
      Matt

      S 1 Reply Last reply Reply Quote 0
      • S
        SteveITS Galactic Empire @mattlach
        last edited by

        @mattlach Iโ€™ve edited the config file and restored before. It can be done on pfSense:
        https://docs.netgate.com/pfsense/en/latest/config/xml-configuration-file.html#edit-in-place

        Itโ€™s normal that it stops at boot if interfaces change. There should be a VLAN option on the console though IIRC.

        Pre-2.7.2/23.09: Only install packages for your version, or risk breaking it. Select your branch in System/Update/Update Settings.
        When upgrading, allow 10-15 minutes to restart, or more depending on packages and device speed.
        Upvote ๐Ÿ‘ helpful posts!

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

          Yup if you have a bunch of VLANs like that it's often easier to edit the config file directly. Of course that is always open to human error, so be sure to have a recovery plan in place! ๐Ÿ˜‰

          1 Reply Last reply Reply Quote 1
          • M
            mattlach @SteveITS
            last edited by

            @SteveITS
            Interesting.

            So you actually edit it on the drive, or do you export the config, edit and reimport?

            I imagine it is just an XML formatted file?

            I should probably just be able to search for - for example - ix1.1, and replace it with ix0.1?

            And do the same for all the VLANS?

            Much appreciated,
            Matt

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

              I would export it, edit it and reimport it. Doing that reloads everything as required.

              If you're moving to different hardware then you would apply a basic setup on that then import the edited config.

              Yeah, if the old hardware was using, for example, em NICs and the new has igb then you would switch out the interface definitions and the VLAN config.

              So you'd have to swap em for igb in potentially three places:

              		<lan>
              			<enable></enable>
              			<if>igb1</if>
              			<descr><![CDATA[LAN]]></descr>
              			<ipaddr>192.168.226.1</ipaddr>
              			<subnet>24</subnet>
              			<spoofmac></spoofmac>
              		</lan>
              
              		<opt11>
              			<descr><![CDATA[VLAN50]]></descr>
              			<if>igb1.50</if>
              			<enable></enable>
              			<ipaddr>10.10.50.10</ipaddr>
              			<subnet>26</subnet>
              			<spoofmac></spoofmac>
              		</opt11>
              
              		<vlan>
              			<if>igb1</if>
              			<tag>50</tag>
              			<pcp></pcp>
              			<descr><![CDATA[VLAN50]]></descr>
              			<vlanif>igb1.50</vlanif>
              		</vlan>
              
              1 Reply Last reply Reply Quote 1
              • S
                SteveITS Galactic Empire @mattlach
                last edited by

                @mattlach said in Any way to "ninja edit" interface assignments?:

                just be able to search for - for example - ix1.1, and replace it with ix0.1?

                If memory serves there was a way to two to get into trouble with a global search and replace...encoded values/passwords maybe? Also changing ix0 to ix1 is fine unless you also needed to change ix1 to ix2 in which case do that first. :)

                I would search a bit more restrictively, like "<if>igb1" in Steve's example, and/or review each replacement.

                Pre-2.7.2/23.09: Only install packages for your version, or risk breaking it. Select your branch in System/Update/Update Settings.
                When upgrading, allow 10-15 minutes to restart, or more depending on packages and device speed.
                Upvote ๐Ÿ‘ helpful posts!

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

                  Yup you need to manually check each replacement because there's a significant chance you might find the string em0 for example in the certs fields.

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