Skip to main content

Defaults file (defaults.ini)

info

defaults.ini was introduced in Husarnet version 2.0.330.

The defaults.ini file allows you to set default values for Husarnet environment variables system-wide. Standard location of this file is:

  • /var/lib/husarnet/defaults.ini (Linux and MacOS)
  • C:\ProgramData\Husarnet\defaults.ini (Windows)

Both husarnet and husarnet-daemon read this file on startup and apply the settings accordingly. Note: if a variable is set in both the defaults file and the environment, the environment variable takes precedence.

Why use defaults.ini?

Defaults.ini is useful because it provides straightforward way of setting environment variables (without worrying about platform-specific ways of setting them, especially for services/daemons). Without this file, you'd need to modify individual systemd/launchd files on your machines, or dabble into Windows Registry / services.msc to change daemon behaviour.

File format

Defaults file follows the most basic INI file format, with three sections: [common], [daemon], [cli]. Each section contains key-value pairs, where keys are environment variable names (without the HUSARNET_ prefix) and values are the default values for those variables. Keys are case-insensitive in this context. Comments start with ;.

Initial defaults.ini file looks like this:

; consult the documentation before editing. See https://husarnet.com/docs/defaults-ini

; Husarnet INI file, which is read both by the Daemon and the CLI on startup
; this is convenient way of providing a default value for an environment variable used by Husarnet
; the values that are provided here are the defaults, which means env vars set directly on the running process
; (for example via /etc/default/husarnet on Linux) will override them.

[common]
instance_fqdn = beta.husarnet.com
; log_verbosity = info
; enable_hooks = false

[daemon]
; daemon_interface = hnet0

[cli]
; daemon_api_secret = some-secret

Managing with Husarnet CLI

info

Due to permission requirements, these commands have to be run with elevated privileges (sudo on Linux/MacOS or running Command Prompt/PowerShell as Administrator on Windows).

Use

husarnet defaults edit

to open the defaults file in the system's default text editor ($EDITOR on Linux/MacOS, Notepad on Windows). After saving and closing the file, you will need to restart the Husarnet daemon for changes to take effect.

Use

husarnet defaults reset

To reset the defaults file to its initial state (the one shown above). This will overwrite any changes you have made, so consider backing up the file first to avoid losing your configuration.

You can also manipulate the file directly without using the above commands.

Example usage scenarios

Switching to different Husarnet instance