Score:1

How to block network connection to all `root` process?

us flag

My system is debian 10 with nftables.
output of nethogs as below:

? root     192.168.2.10:59100-172.217.27.138:443 
? root     192.168.2.10:59086-172.217.27.138:443 
? root     192.168.2.10:59082-172.217.27.138:443 
? root     192.168.2.10:59062-172.217.27.138:443 
? root     192.168.2.10:59058-172.217.27.138:443 
? root     192.168.2.10:59054-172.217.27.138:443 
? root     192.168.2.10:59030-172.217.27.138:443 
? root     192.168.2.10:59026-172.217.27.138:443
? root     192.168.2.10:42314-27.19.249.194:443  
? root     192.168.2.10:49788-216.58.200.234:443 

I ss -pl | grep 59100 but got nothing,then I plan to block all root process to network connection.
How to do it?

jp flag
This seems like *an XY problem*. If I get it right, you don't understand what these connections are and try to solve it simply by blocking them. But there's a problem with this approach: root might need Internet access for e.g. system updates, and if there are malicious connections from root, it's already game over.
kittygirl avatar
us flag
@EsaJokinen,I want to block root all the time,except update.
Score:2
jp flag

With iptables, this would be rather easy with the owner match extension:

sudo iptables -A OUTPUT -p all -m owner --uid-owner 0 -j DROP

Likewise, nftables has matching by socket UID / GID:

sudo nft add rule filter output meta skuid 0 counter
kittygirl avatar
us flag
I add `log prefix "drop root: " meta skuid 0 counter drop` in nftables rule,seemed works fine. ps.What's the meaning of `meta`?
kittygirl avatar
us flag
Cound I use `!` or `not` to set only one user pass,such as `log prefix "drop root: " meta ! skuid 1000 counter drop`?
mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.