opnsense / core

OPNsense GUI, API and systems backend
https://opnsense.org/
BSD 2-Clause "Simplified" License
3.36k stars 753 forks source link

Feature Request: Offline Package Install Via CLI When Device Cannot Connect to Internet #7820

Open korgano opened 2 months ago

korgano commented 2 months ago

Important notices

Before you add a new report, we ask you kindly to acknowledge the following:

Is your feature request related to a problem? Please describe.

I purchased an Intel N100 MiniPC for the purpose of installing OPNSense on the device.

After installing OPNSense to the SSD, I discovered that due to the PC using the RTL8125b LAN chip, OPNSense could not detect the LAN ports, only the WiFi. After posting about the issue on r/OPNSense, I attempted to use the WiFi to connect to existing wireless networks.

All attempts using standard FreeBSD commands ifconfig [WIFI-INT] ssid [SSID] and ifconfig [WIFI-INT] nwkey [PASSWORD] via the shell failed. The interface did accept the SSID, but no connection was made for reasons that cannot be determined. Setting the WiFi interface to WAN or LAN had no effect. It is now impossible to connect to the Internet and execute pkg install os-realtek-re to update the drivers.

Online documentation has proven useless, as none of the OPNSense documentation covers such a scenario, and FreeBSD documentation is borderline useless due to OPNSense divergences in filenames.

Describe the solution you like

An addition to the CLI menu that would automatically load packages from a designated directory on an appropriately formatted USB drive, similar to how configurations can be imported.

Describe alternatives you considered

r/OPNSense users suggested ProxMox, but since I intend to use OPNSense in a Transparent Filtering Bridge configuration, I do not believe that is a viable solution.

Additional context

Apparently, OPNSense used to include vendor provided drivers in the ISO, then removed them. It might be wise to return to providing vendor drivers to prevent situations like this.

doktornotor commented 2 months ago

On some OPNsense box with working internet, run:

pkg fetch -o /tmp os-realtek-re realtek-re-kmod

Here are your packages:

# ls -l /tmp/All/
total 129
-rw-r--r--  1 root wheel   1192 Aug 21 09:08 os-realtek-re-1.0.pkg
-rw-r--r--  1 root wheel 124328 Aug 21 09:08 realtek-re-kmod-1100.00.pkg

SCP it off the box, copy to some USB stick, mount and install from there with pkg install

fichtner commented 2 months ago

More or less: https://github.com/opnsense/tools/issues/383

First and foremost we don't want to cram the basic install with things 95% of users won't need ever.

Secondly the Realtek FreeBSD vs. vendor situation has been very silly overall. We actually pioneered using the vendor driver as a replacement in the FreeBSD kernel for a while since 2017, but that was before FreeBSD had the vendor driver in the ports tree in 2020. Since 2022 we carry the FreeBSD driver again to avoid too many kernel modifications.

Keep in mind some people prefer the FreeBSD driver, some prefer the vendor driver. Most prefer neither. ;)

Cheers, Franco

doktornotor commented 2 months ago

Most prefer neither. ;)

Attached is a picture of the infamous crab cutting your ethernet wires...

image

korgano commented 2 months ago

I would like to point out that there is massive value in at least providing automation for the process of mounting the USB drive to upload the driver.

I have done my best to look up the proper commands to mount the USB, but I have run into the following issues: -OPNSense detects the drive, but mount commands do not work because it couldn't find /dev/da0 -OPNSense can find /dev/da0, but now gives Invalid fstype: Invalid Argument

gpart show output is as follows:

63            60628929           da0            MBR              (29G)
63                    8001                            - free -           (3.9M)
8064        60620928                1          fat32lba          (29G)

mount -t mbr /dev/da0 /mnt/usb_drive, mount -t MBR /dev/da0 /mnt/usb_drive, mount -t fat32 /dev/da0 /mnt/usb_drive, and mount -t fat32lba /dev/da0 /mnt/usb_drive have all resulted in Invalid fstype: Invalid Argument messages.

At the very least, any automation for disk mounting provided by OPNSense could have useful user experience text such as Unsupported fstype = [fstype name]. OPNSense supports fstypes: [list of fstypes]. That would at least allow to get a USB drive formatted properly for this kind of task.

doktornotor commented 2 months ago

I posted the above steps in order to get you up and running since that r/OPNsense thread you linked was completely useless.

There's nothing special about mounting UISB sticks in OPNsense, it works the same way as documented for FreeBSD Also, there is no automounting in OPNsense or FreeBSD by default. And most importantly, none of the commands you have posted uses a valid filesystem type for FAT32-formatted drives, hence you get "invalid argument:".