mirror of
https://github.com/netblue30/firejail.git
synced 2026-05-15 14:16:14 -06:00
[GH-ISSUE #108] Support for --net=local #69
Labels
No labels
LTS merge
LTS merge
bug
bug
converted-to-discussion
doc-todo
documentation
duplicate
enhancement
file-transfer
firecfg
firejail-in-firejail
firetools
graphics
help wanted
information_old
installation
invalid
modif
moved
needinfo
networking
notabug
notourbug
old-version
overlayfs
packaging
profile-request
pull-request
question
question_old
removal
runtime-permissions
sandbox-ipc
security
stale
wiki
wiki
wontfix
wordpress
workaround
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference: github-starred/firejail#69
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @netblue30 on GitHub (Oct 28, 2015).
Original GitHub issue: https://github.com/netblue30/firejail/issues/108
Currently, --net=none creates a network namespace with only a new loopback interface. Implemente a --net=local option that would create a network namespace with only the existing loopback interface. Reported on wordpress.com
@netblue30 commented on GitHub (Oct 31, 2015):
The problem is an interface cannot belong to more than one network namespace. The feature cannot be implemented without Linux kernel modifications.
@pitchforks commented on GitHub (Nov 8, 2015):
Is it possible to have explicit blacklisting of existing network interfaces then? This would achieve the same result if one blacklisted all interfaces except the loopback. Or is this impossible due to same Linux kernel technical restrictions, despite being worded differently?
@netblue30 commented on GitHub (Nov 9, 2015):
No, blacklisting will not work because of the way they set the namespace inside the kernel. I'll try to build a proxy and move the network traffic between the two loopback interfaces (the one on the host, and the one in the sandbox). I think it should work.
@Sidnioulz commented on GitHub (Jan 30, 2016):
One approach could be to create a veth pair to redirect all within-sandbox traffic to the host, and use an iptables rule to route all that traffic to 127.0.0.1? Or to another specific IP/port. I do that to redirect all my sandboxes' network traffic to my host's default gateway, providing transparent networking with bandwidth control.
@biergaizi commented on GitHub (Jul 13, 2017):
Two years later, and there's still no progress on it? I'd like to make a bitcoin donation to make this feature implemented 😆
@chiraag-nataraj commented on GitHub (Jun 7, 2018):
As far as I know, it's been another year now @biergaizi 😉
@guillaume-uH57J9 commented on GitHub (Nov 10, 2022):
socat to the rescue!
An alternative solution is to configure your service to be accessible via a socket file, then setup a sandbox with --net=none, and finally run socat IN the sanxbox to listen on the sandbox's loopback interface, and redirect the connection to the socket file.
If that service is torsocks, you'll need to add --whitelist=/run/tor, and run this within the sandbox:
socat TCP-LISTEN:9050,fork,bind=localhost UNIX-CONNECT:/run/tor/socksEdit: add --whitelits mention
@ssokolow commented on GitHub (Dec 31, 2023):
What if we just want to keep a buggy Stable Diffusion frontend from re-downloading hundreds or thousands of megabytes of data model every time it's started but still need to access the web UI it exposes over a TCP socket?
(Bear in mind these things tend to be hellishly confusing messes of pseudo-containerized Python as soon as you need to customize their behaviour beyond choosing whether to bind to localhost or listen on all interfaces.)
I've seen multiple places (eg. this Unix & Linux StackExchange question) where people want this, but nobody seems to just provide a simple "here's an example complete solution" for the approaches suggested in #3439.
@rusty-snake commented on GitHub (Dec 31, 2023):
--dns=0.0.0.0or--hosts-file=...can be used to stop at DNS level.ncatwhen using--net=none.Something as simple as
@kmk3 commented on GitHub (Jan 4, 2024):
Could it work by doing
nolocalin reverse?549d59f55d/etc/net/nolocal.net (L1-L36)549d59f55d/etc/net/nolocal6.net (L1-L41)@rusty-snake commented on GitHub (Jan 4, 2024):
As long you do not need loopback traffic between Sandbox and host.
@krichter722 commented on GitHub (Aug 10, 2024):
Summary so far: The people knowing solutions or make very elaborate suggestions making me think they can easily come up a solution have made the following suggestions:
--netfilter to block everything ecept 127.0.0.1 (--netfilter requires --net)(https://github.com/netblue30/firejail/issues/3439#issuecomment-866847256)--net with a bridge or tap iface (or --netns)(https://github.com/netblue30/firejail/issues/3439)There are other great suggestions, those are just the ones that I'm sure the authors know how to make them work.
I on behalf of all other users seeking the answers (I found tons of posts asking a solution for this use case) would be very thankful for any instruction how to configure
firejailto limit traffic to localhost that goes beyond an abstract suggestion how to achieve this.@rusty-snake commented on GitHub (Aug 10, 2024):
There are different scenarios that needs to be supported:
127.0.0.1:1234 host. Client is in the sandbox and needs to connect to the server on127.0.0.1:1234 sandboxfrom127.0.0.1 host/sandbox.127.0.0.1:1234 host. Client is in the sandbox and needs to connect to the server, using a different subnet isn't a problem.127.0.0.1:1234 sandbox. Client is in on the host and needs to connect to the server on127.0.0.1:1234 hostfrom127.0.0.1 host/sandbox.127.0.0.1:1234 sandbox. Client is in on the host and needs to connect to the server, using a different subnet isn't a problem.127.0.0.1:xxxx host.In the first and third case the target (client) resp. source (server) IP address matters. This can be the case when the admin interface is only exposed for connections from localhost or if the http
Hostheader is relevant.@mxmlnkn commented on GitHub (Sep 26, 2024):
My workaround for this problem was to simply start the server and also a browser inside the firejail. E.g.:
This then becomes reminiscent of an Electron-based application. You can browse the HTTP server but anything else, such as browsing the Internet will not work, just as desired. This is sufficient for my use case, but for other use cases such as locally running databases, it probably is not sufficient.
I think this was a red herring and does not work. My understanding is not complete, but I tried my luck with iptables rules for the netfilter and failed. It seems to me that it always "spins up" a separate loopback device as soon as any network sandboxing is spun up. And this means that this newly spun-up
lodevice cannot be reached via 127.0.0.1 from outside the firejail.@ssokolow commented on GitHub (Sep 26, 2024):
Except that all my browsers are installed via Flatpak and I'd rather not install a whole other browser just for that purpose.
(Tightening down and babysitting the sandboxing privileges for non-containerized applications is a pain, so I only use Firejail for things not available through Flatpak yet.)
@l8l commented on GitHub (Mar 23, 2025):
I would also very much appreciate this feature. I am running a local database on localhost that I want to query with a program that must otherwise be cut off from the internet. Would like to run something like
firejail --net=local --noprofile myprogramfor that. Is something like this possible already or any progress in this regard?EDIT: I found a workaround that at least works for my case:
The apps that joined the server can then send requests to it while being cut off from the internet.
Adapted from this post https://unix.stackexchange.com/questions/478131/firejail-only-let-a-program-access-localhost
However, in this way the server can itself not communicate with the outside world, which might be desired in some cases.
@biollas commented on GitHub (Nov 1, 2025):
Another vote for this feature which has been in demand for at least a decade by the looks of it.