How to block an app from accessing the internet on Linux
Updated
Short answer
The quickest one-off way is firejail --net=none app, which starts the app with no network at all. For a permanent rule, run the app under a dedicated group and add an iptables rule that rejects that group’s outgoing traffic. A per-app firewall such as PacketShield does the same with one click on the app in its live list.
Option 1: firejail (one launch, no network)
sudo apt install firejail # Debian/Ubuntu
sudo dnf install firejail # Fedora
firejail --net=none appnamefirejail runs the program in a sandbox without network access. It only applies to that launch: starting the app from its menu shortcut will still have internet.
Option 2: iptables rule for a dedicated group
sudo groupadd no-internet
sudo usermod -aG no-internet "$USER" # log out and back in
sudo iptables -A OUTPUT -m owner --gid-owner no-internet -j REJECT
sudo ip6tables -A OUTPUT -m owner --gid-owner no-internet -j REJECT
sg no-internet -c "appname"Every process started with that group loses internet access. iptables rules are not saved across reboots by default; use your distribution’s iptables-persistent or netfilter-persistent package to keep them.
With PacketShield: one click, applied however the app is launched
- Open PacketShield and find the app in the live list.
- Click Block on its row.
- To undo it, click Allow on the same row. Rules survive reboots.
PacketShield tracks the app’s processes with cgroup v2 and applies iptables/ip6tables rules to them, so the block holds no matter how the app is started. The free version includes 1 active block rule; PRO (one-time $19) removes the limit.
Frequently asked questions
How do I run a Linux program without internet access?
Use firejail --net=none program for a single launch, or a permanent per-app rule with iptables or PacketShield.
Can ufw block one application?
No. ufw works with ports and addresses. You need an owner/cgroup iptables rule or a per-app firewall.
Does the block survive a reboot?
firejail applies only to that launch, and plain iptables rules are lost unless you save them. PacketShield keeps its rules and restores them at boot.