0

What is the least convoluted way to do it? To start a process with no networking, unshare -n -r does the job reliably.

7
  • 1
    I'm not sure there's a good way to do this. You can't move a process into another network namespace, so you can't accomplish the exact equivalent of your unshare command. Standard iptables or nftables does not have the ability to block traffic by pid. This answer suggests moving the process into a cgroup and then blocking network access for that cgroup. Commented Jan 22, 2024 at 23:23
  • 3
    Does this answer your question? how to unshare network for current process Commented Jan 22, 2024 at 23:51
  • Can't say it's least convoluted, but it's the nearest goal, since it does as what is asked. Commented Jan 22, 2024 at 23:53
  • @A.B Thank you for the link! I will attempt that method and report back. :) Commented Jan 23, 2024 at 11:39
  • 4
    Does this answer your question? Block network access of a process? Commented Jan 23, 2024 at 14:55

0

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.