<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://wiki.nixos.org/w/index.php?action=history&amp;feed=atom&amp;title=Portmaster</id>
	<title>Portmaster - Revision history</title>
	<link rel="self" type="application/atom+xml" href="https://wiki.nixos.org/w/index.php?action=history&amp;feed=atom&amp;title=Portmaster"/>
	<link rel="alternate" type="text/html" href="https://wiki.nixos.org/w/index.php?title=Portmaster&amp;action=history"/>
	<updated>2026-08-19T04:45:31Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.45.1</generator>
	<entry>
		<id>https://wiki.nixos.org/w/index.php?title=Portmaster&amp;diff=34501&amp;oldid=prev</id>
		<title>WitteShadovv: Add first draft of Portmaster package and module entry</title>
		<link rel="alternate" type="text/html" href="https://wiki.nixos.org/w/index.php?title=Portmaster&amp;diff=34501&amp;oldid=prev"/>
		<updated>2026-08-18T13:03:19Z</updated>

		<summary type="html">&lt;p&gt;Add first draft of Portmaster package and module entry&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;&amp;#039;&amp;#039;&amp;#039;Portmaster&amp;#039;&amp;#039;&amp;#039; is a free and open source application firewall developed by [https://safing.io Safing].&amp;lt;ref&amp;gt;https://safing.io/&amp;lt;/ref&amp;gt; It monitors and controls network connections per application, so rules follow the program rather than the port. A package and a service module are available on the unstable channel and will ship with NixOS 26.11.&lt;br /&gt;
&lt;br /&gt;
== Installation ==&lt;br /&gt;
&lt;br /&gt;
==== System setup ====&lt;br /&gt;
&lt;br /&gt;
Add the following to your system configuration:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;nix&amp;quot;&amp;gt;&lt;br /&gt;
services.portmaster.enable = true;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This starts the &amp;lt;code&amp;gt;portmaster.service&amp;lt;/code&amp;gt; daemon, installs the desktop client into the system environment, and loads the &amp;lt;code&amp;gt;nfnetlink_queue&amp;lt;/code&amp;gt; kernel module. The desktop client starts in the background with graphical sessions and authenticates against the package&amp;#039;s read-only binary directory, so it works without any further setup. When the service stops, leftover iptables rules are cleaned up automatically.&lt;br /&gt;
&lt;br /&gt;
For all module options, refer to {{nixos:option|services.portmaster}}.&lt;br /&gt;
&lt;br /&gt;
== Configuration ==&lt;br /&gt;
&lt;br /&gt;
==== Basic ====&lt;br /&gt;
&lt;br /&gt;
Global settings can be managed declaratively through {{nixos:option|services.portmaster.settings}}:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;nix&amp;quot;&amp;gt;&lt;br /&gt;
services.portmaster = {&lt;br /&gt;
  enable = true;&lt;br /&gt;
  settings = {&lt;br /&gt;
    &amp;quot;core/log/level&amp;quot; = &amp;quot;warning&amp;quot;;&lt;br /&gt;
    &amp;quot;dns/nameservers&amp;quot; = [&lt;br /&gt;
      &amp;quot;dot://dns.quad9.net?ip=9.9.9.9&amp;amp;name=Quad9&amp;amp;blockedif=empty&amp;quot;&lt;br /&gt;
    ];&lt;br /&gt;
  };&lt;br /&gt;
};&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Settings are merged from three sources, where later sources override earlier ones: &amp;lt;code&amp;gt;settings&amp;lt;/code&amp;gt;, then &amp;lt;code&amp;gt;settingsFile&amp;lt;/code&amp;gt;, then &amp;lt;code&amp;gt;secretsFile&amp;lt;/code&amp;gt;. Use &amp;lt;code&amp;gt;secretsFile&amp;lt;/code&amp;gt; for values that must not be copied to the world-readable Nix store.&lt;br /&gt;
&lt;br /&gt;
{{note|When any of these options or declarative profiles are used, the module owns Portmaster&amp;#039;s runtime &amp;lt;code&amp;gt;config.json&amp;lt;/code&amp;gt;. Global settings changed only through the UI are replaced at the next service start, so keep all global settings in your NixOS configuration.}}&lt;br /&gt;
&lt;br /&gt;
Portmaster stores its mutable state, configuration, and logs under {{nixos:option|services.portmaster.stateDir}}, which defaults to &amp;lt;code&amp;gt;/var/lib/portmaster&amp;lt;/code&amp;gt;. Changing it does not migrate existing state.&lt;br /&gt;
&lt;br /&gt;
Set &amp;lt;code&amp;gt;services.portmaster.settings.devmode&amp;lt;/code&amp;gt; to &amp;lt;code&amp;gt;true&amp;lt;/code&amp;gt; only when you need unrestricted browser or debugging access to the local API at &amp;lt;code&amp;gt;http://127.0.0.1:817&amp;lt;/code&amp;gt;. The packaged desktop client does not need it.&lt;br /&gt;
&lt;br /&gt;
==== Advanced ====&lt;br /&gt;
&lt;br /&gt;
Application profiles can be declared in your NixOS configuration. The module derives fingerprints from packages using regular expressions that ignore the Nix store hash and the package version, and that also match Nix generated &amp;lt;code&amp;gt;.program-wrapped&amp;lt;/code&amp;gt; executables. Profiles therefore keep working across rebuilds and package updates. They are imported through Portmaster&amp;#039;s local API, and rebuilds update existing profiles in place instead of creating duplicates.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;nix&amp;quot;&amp;gt;&lt;br /&gt;
services.portmaster = {&lt;br /&gt;
  enable = true;&lt;br /&gt;
  profilePrefix = &amp;quot;[NixOS] &amp;quot;;&lt;br /&gt;
&lt;br /&gt;
  profiles = {&lt;br /&gt;
    Firefox = {&lt;br /&gt;
      packages = [ pkgs.firefox ];&lt;br /&gt;
      settings.filter.defaultAction = &amp;quot;permit&amp;quot;;&lt;br /&gt;
    };&lt;br /&gt;
&lt;br /&gt;
    Vesktop = {&lt;br /&gt;
      fingerprints = [&lt;br /&gt;
        {&lt;br /&gt;
          type = &amp;quot;env&amp;quot;;&lt;br /&gt;
          key = &amp;quot;CHROME_DESKTOP&amp;quot;;&lt;br /&gt;
          operation = &amp;quot;equals&amp;quot;;&lt;br /&gt;
          value = &amp;quot;vesktop.desktop&amp;quot;;&lt;br /&gt;
        }&lt;br /&gt;
      ];&lt;br /&gt;
    };&lt;br /&gt;
  };&lt;br /&gt;
};&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Some packages start their real executable outside &amp;lt;code&amp;gt;bin&amp;lt;/code&amp;gt;. Describe those layouts explicitly:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;nix&amp;quot;&amp;gt;&lt;br /&gt;
services.portmaster.profiles.Brave.packages = [&lt;br /&gt;
  {&lt;br /&gt;
    package = pkgs.brave;&lt;br /&gt;
    directory = &amp;quot;opt/brave.com/brave&amp;quot;;&lt;br /&gt;
  }&lt;br /&gt;
];&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
A package entry accepts &amp;lt;code&amp;gt;package&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;type&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;storeNameRegex&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;directory&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;name&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;wrapped&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;strictHead&amp;lt;/code&amp;gt;, and &amp;lt;code&amp;gt;strictLast&amp;lt;/code&amp;gt; fields. Manual fingerprints support the types &amp;lt;code&amp;gt;path&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;cmdline&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;env&amp;lt;/code&amp;gt;, and &amp;lt;code&amp;gt;tag&amp;lt;/code&amp;gt; with the operations &amp;lt;code&amp;gt;equals&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;prefix&amp;lt;/code&amp;gt;, and &amp;lt;code&amp;gt;regex&amp;lt;/code&amp;gt;. The &amp;lt;code&amp;gt;packages&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;fingerprints&amp;lt;/code&amp;gt; lists are merged, and at least one of them must be non-empty.&lt;br /&gt;
&lt;br /&gt;
{{warning|Package name matching is a convenience, not a security boundary against local Nix users. Anyone who can add arbitrary store paths can create a derivation with a matching name. Use manually chosen fingerprints when that threat is relevant to your setup.}}&lt;br /&gt;
&lt;br /&gt;
Fingerprints are alternatives: a process matches when any fingerprint matches, so broad regular expressions can match unintended applications. Removing a profile declaration does not remove a profile that Portmaster has already imported. Changing fingerprints changes the derived profile identity, which can leave the previous imported profile behind.&lt;br /&gt;
&lt;br /&gt;
== Tips and tricks ==&lt;br /&gt;
&lt;br /&gt;
* Use &amp;lt;code&amp;gt;profilePrefix&amp;lt;/code&amp;gt; to make module managed profiles easy to recognize in the Portmaster UI.&lt;br /&gt;
* The binary self-updater is disabled in the NixOS package because Nix owns the installed files. Intelligence and filter list data updates keep working and are stored under &amp;lt;code&amp;gt;stateDir&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
== Troubleshooting ==&lt;br /&gt;
&lt;br /&gt;
==== Port 53 conflicts ====&lt;br /&gt;
&lt;br /&gt;
Portmaster runs its own local nameserver on port 53 of localhost.&amp;lt;ref name=&amp;quot;osint&amp;quot;&amp;gt;https://docs.safing.io/portmaster/architecture/os-integration&amp;lt;/ref&amp;gt; The module does not disable [[systemd-resolved]] or other DNS services for you. If another service already listens on port 53, resolve the conflict yourself, for example by disabling systemd-resolved or its stub listener.&lt;br /&gt;
&lt;br /&gt;
DNS queries that arrive through systemd-resolved cannot be attributed to the originating process, which weakens per-application filtering.&amp;lt;ref name=&amp;quot;osint&amp;quot; /&amp;gt; Setups using systemd-networkd have also seen VPN provided split DNS zones fail to resolve.&amp;lt;ref&amp;gt;https://github.com/safing/portmaster/issues/655&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== firewalld ====&lt;br /&gt;
&lt;br /&gt;
The Portmaster service declares a systemd conflict with &amp;lt;code&amp;gt;firewalld.service&amp;lt;/code&amp;gt;. The two cannot run at the same time.&lt;br /&gt;
&lt;br /&gt;
==== First start ====&lt;br /&gt;
&lt;br /&gt;
Portmaster downloads its intelligence and filter list data on first start, so the first run needs a working network connection. If the download fails, filtering can be impaired until the data is fetched. Restarting the service retries the download.&lt;br /&gt;
&lt;br /&gt;
==== Declarative profiles fail to import ====&lt;br /&gt;
&lt;br /&gt;
The import runs in a separate unit, &amp;lt;code&amp;gt;portmaster-managed-profiles.service&amp;lt;/code&amp;gt;, which waits up to 60 seconds for the Portmaster API to become ready. Check its status and the reason for a rejected profile with:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;console&amp;quot;&amp;gt;&lt;br /&gt;
# journalctl -u portmaster-managed-profiles&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Logs ====&lt;br /&gt;
&lt;br /&gt;
The daemon logs to the journal and to &amp;lt;code&amp;gt;logs&amp;lt;/code&amp;gt; under &amp;lt;code&amp;gt;stateDir&amp;lt;/code&amp;gt;:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;console&amp;quot;&amp;gt;&lt;br /&gt;
# journalctl -u portmaster&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== See also ==&lt;br /&gt;
&lt;br /&gt;
* [https://safing.io/portmaster/ Portmaster upstream] – official website&lt;br /&gt;
* [https://docs.safing.io/ Portmaster documentation] – upstream manual, including OS integration details&lt;br /&gt;
* [https://github.com/safing/portmaster safing/portmaster] – source repository&lt;br /&gt;
* [https://nixos.org/manual/nixos/unstable/#module-services-portmaster NixOS manual chapter] – module documentation with more configuration examples&lt;br /&gt;
* [[OpenSnitch]] – another application firewall available on NixOS&lt;br /&gt;
&lt;br /&gt;
== References ==&lt;br /&gt;
&lt;br /&gt;
[[Category:Applications]]&lt;br /&gt;
[[Category:Security]]&lt;br /&gt;
[[Category:Networking]]&lt;/div&gt;</summary>
		<author><name>WitteShadovv</name></author>
	</entry>
</feed>